Actionscript:
-
var xp:Number = 0;
-
var yp:Number = 0;
-
var t:Number = 0;
-
var a:Number = 100;
-
var b:Number = 10;
-
x = stage.stageWidth / 2;
-
y = stage.stageHeight / 2;
-
-
graphics.lineStyle(0,0x000000);
-
addEventListener(Event.ENTER_FRAME, onRun);
-
function onRun(evt:Event):void {
-
var p:Number = ((a + b)/b)*t
-
xp = (a + b) * Math.cos(t) - b * Math.cos(p);
-
yp = (a + b) * Math.sin(t) - b * Math.sin(p);
-
if (t == 0){
-
graphics.moveTo(xp, yp);
-
}else{
-
graphics.lineTo(xp, yp);
-
}
-
t += 0.05;
-
}
I've messed with Epicycloids in the past - browsing mathworld I decided to create this snippet. It will draw a curve like this:
Actionscript:
-
var xp:Number = 0;
-
var yp:Number = 0;
-
var t:Number = 0;
-
var a:Number = 200;
-
x = stage.stageWidth / 2;
-
y = stage.stageHeight / 2;
-
-
graphics.lineStyle(0,0x000000);
-
addEventListener(Event.ENTER_FRAME, onRun);
-
function onRun(evt:Event):void {
-
xp = a * Math.cos(t) - (a * Math.pow(Math.sin(t),2))/Math.sqrt(2);
-
yp = a * Math.cos(t) * Math.sin(t);
-
if (t == 0){
-
graphics.moveTo(xp, yp);
-
}else{
-
graphics.lineTo(xp, yp);
-
}
-
t += 0.05;
-
}
While surfing mathworld I stumbled upon the equation for something called the Fish Curve. This snippet will draw something like this:
Posted in Math, misc | Tagged actionscript, as3, flash |
Actionscript:
-
var xp:Number = 0;
-
var yp:Number = 0;
-
var t:Number = 0;
-
var r:Number = 200;
-
x = stage.stageWidth / 2;
-
y = stage.stageHeight / 2;
-
-
graphics.lineStyle(0,0x000000);
-
addEventListener(Event.ENTER_FRAME, onRun);
-
function onRun(evt:Event):void {
-
r = 200 * Math.cos(t / 10);
-
xp = r * Math.pow(Math.cos(t), 3);
-
yp = r * Math.pow(Math.sin(t), 3);
-
if (t == 0){
-
graphics.moveTo(xp, yp);
-
}else{
-
graphics.lineTo(xp, yp);
-
}
-
t += 0.1;
-
}
While browsing mathworld I decided to do a variation on this curve . The above snippet will draw something like this:
Posted in Math, misc | Tagged actionscript, as3, flash |
I've been working on a project for the led facade at medialab prado. The project has an online component that allows users to name colors, these names are then searched on twitter and displayed on the led facade. Right now our color database has about 530 colors about 20% of which are in spanish. We're lookiing to get more colors named particularly in spanish. If you feel up to it, you can enter and name colors, simply pick a color, enter your name and name the color... here for spanish
and here for english.
If you did it correctly you'll see your color show up in our list of colors here