Combining Shapes from the Past
When writing my recent article about Combining Vectors in Flash the Overlapping Circles example reminded me of the entries I made for the now legendary Bit-101 “25 Lines Contest” back in 2002. I tried looking for all of the old contest entries but they seem to have been erased from the web.
Fortunately I found a few different versions of the entries I posted back in 2002 still loitering on my hard drive in an abandoned folder thought to be lost long ago. So without much further ado, here are two files that probably haven’t been seen by anyone in the last five years!
Here’s the code for my first entry called “Goin’ Mobile”
//
curPos = new Array();
newPos = new Array();
function drawCircle (x, y, r) {
moveTo(x, y-r);
curveTo(x+r*.9322, y-r*.9322, x+r, y);
curveTo(x+r*.9322, y+r*.9322, x, y+r);
curveTo(x-r*.9322, y+r*.9322, x-r, y);
curveTo(x-r*.9322, y-r*.9322, x, y-r);
}
function genRandPos (arry) {
for (i=0; i<20; i++){
arry[i] = [Math.floor(Math.random()*550), Math.floor(Math.random()*400)];
}
}
onMouseDown = function(){
curPos[0] ? clearInterval(myTimer) : genRandPos(curPos);
myTimer = setInterval(genRandPos, 15000, newPos);
genRandPos(newPos);
}
onEnterFrame = function(){
clear();
beginFill(0, 100);
for (i=0; i<20; i++){
curPos[i] = [curPos[i][0]+((newPos[i][0]-curPos[i][0])/36), curPos[i][1]+((newPos[i][1]-curPos[i][1])/36)];
drawCircle(curPos[i][0]+4, curPos[i][1]+4, 12+i*15);
}
beginFill(0xFFFFFF, 100);
for (i=0; i<20; i++){
drawCircle(curPos[i][0], curPos[i][1], 5+i*15);
}
}
onMouseDown();
//
//
If you run the above code you’ll get a SWF file similar to the following:
And here's the code for my second entry titled "Eye Blender""
//
fill = [[0xFFFF00, 0xFF8800, 0xFF0000, 0x8800FF], [100, 100, 100, 100], [0, 100, 150, 255]];
v = {points:20, pointR:100, curveR:250, gradR:190, speed:20000, funkify:20, x:275, y:200};
var deltaAlpha = 2*Math.PI/v.points;
function rand () {
r = Math.floor((r+Math.random()*200-100))/2;
return(r);
}
function draw() {
matrix = { matrixType:"box", x:v.x-v.gradR+rand(), y:v.y-v.gradR+rand(), w:2*v.gradR, h:2*v.gradR, r:0};
twist+=v.points/v.speed;
clear();
beginGradientFill( "radial", fill[0], fill[1], fill[2], matrix );
alpha = twist*v.points*deltaAlpha;
moveTo(v.x+(v.pointR)*Math.cos(alpha), v.y+(v.pointR)*Math.sin(alpha));
for (i=1; i<=v.points; i++){
alpha = (i*twist*deltaAlpha);
aX = (v.pointR)*Math.cos(alpha);
aY = (v.pointR)*Math.sin(alpha);
alpha = (i*twist*deltaAlpha*v.funkify);
bX = (v.pointR-v.curveR)*Math.cos(alpha);
bY = (v.pointR-v.curveR)*Math.sin(alpha);
curveTo(v.x+bx, v.y+by, v.x+aX, v.y+aY);
}
}
onEnterFrame = draw;
onMouseDown = function(){
onEnterFrame = onEnterFrame ? null : draw;
}
//
//
If you run the above code you will get something like this: