September 21, 2011 – 9:42 am
Let me share some tips with you, my dear reader
All the graphics you see are generated by combinations of 7 blocks

With addition of a possibility to flip each block horizontally
var flip:Number = Math.random();
if (flip<0.45)
{
flip = -1;
}
else
{
flip = 1;
}
block.scaleX = block.scaleX * flip;
A circle distribution with random blocksNumber and random diameter
for (var i:int = 0; i < blocksNumber; i++)
{
block.x = diameter * Math.cos(angleRadians(360 / blocksNumber * i));
block.y = diameter * Math.sin(angleRadians(360 / blocksNumber * i));
//rotate the block to face the center
block.rotation = Math.atan2(0 - block.y,0 - block.x) * 57.2;
}
function angleRadians(angle:Number):Number
{
return (angle * Math.PI) / 180;
}
And a touch of antique color limted between 0xCCCCCC and 0xFFFF33
var antiqueColor:ColorTransform = block.transform.colorTransform;
antiqueColor.color = Math.random() * (0xFFFF33 - 0xCCCCCC) + 0xCCCCCC;
block.transform.colorTransform = antiqueColor;
Posted in Flash, Tips |
No Comments »