forked from: Hello World!!!
// forked from nitoyon's Hello World!!!
package
{
import flash.display.*;
import flash.text.*;
import flash.filters.*;
import flash.geom.*;
import caurina.transitions.Tweener;
[SWF(width="465", height="465", backgroundColor="0xEEEEEE", frameRate="30")]
public class Foo extends Sprite{
private var bd:BitmapData;
public function Foo():void{
var tf:TextField = new TextField();
tf.textColor = 0x402014;
tf.text = "Hello\nWorld!!!";
tf.autoSize = "left";
bd = new BitmapData(tf.width, tf.height, false, 0x3399ff);
bd.draw(tf);
bd.applyFilter(bd, bd.rect, new Point(), new BlurFilter());
bd.draw(tf);
var w:int = bd.width;
var h:int = bd.height;
for(var i:int = 0; i < bd.width; i++){
for(var j:int = 0; j < bd.height; j++){
Tweener.addTween(
randomize(addChild(
new Circle(bd.getPixel(i, j),i*10+j*i*0.6, -0.2, 0.15)), i, j),
{
x : i * 10 + 10,
y : j * 10 + 50,
rotationY : 0,
alpha : 1.0,
transition : "easeoutcubic",
delay : i * 0.02 + j * 0.2,
time : 0.45
}
);
}
}
}
private function randomize(d:DisplayObject, i:int, j:int):DisplayObject{
d.x = i * 10 - 20;
d.y = j * 10 + 50;
rotationY: 90,
d.alpha = 0;
return d;
}
}
}
import flash.display.Sprite;
class Circle extends Sprite{
public function Circle(color:uint, h:int, s:Number, l:Number):void
{
var _hsl:Array = toHSL(color);
_hsl[0] += h;
_hsl[1] += s;
_hsl[2] += l;
graphics.beginFill(hsl.apply(null, _hsl));
graphics.drawCircle(0, 0, 6);
graphics.endFill();
}
}
function hsl (h:Number, s:Number, l:Number, a:Number = 0.0):uint
{ var r:Number = 0, g:Number = 0, b:Number = 0, cmin:Number, cmax:Number; if (s < 0) s = 0; if (s > 1) s = 1; if (l < 0) l = 0; if (l > 1) l = 1; h = h % 360; if (h < 0) h = h + 360; if (l <= 0.5) { cmin = l * ( 1 - s ); cmax = 2 * l - cmin; } else { cmax = l * ( 1 - s ) + s; cmin = 2 * l - cmax; }; r = _h2v(h + 120, cmin, cmax) * 0xFF; g = _h2v(h, cmin, cmax) * 0xFF; b = _h2v(h - 120, cmin, cmax) * 0xFF; a *= 0xFF; return a << 24 | r << 16 | g << 8 | b << 0; }
function _h2v (h:Number, min:Number, max:Number):Number
{ h = h % 360; if (h < 0) h = h + 360; if (h < 60) return min + (max - min) * h / 60; if (h >= 60 && h < 180) return max; if (h >= 180 && h < 240) return min + (max - min) * (240 - h) / 60; return min; }
function toHSL(color:uint):Array {
var h:Number = 0, s:Number = 0, l:Number = 0, cmin:Number, cmax:Number, c:Number;
var r:Number = (color >> 16 & 0xFF) / 255;
var g:Number = (color >> 8 & 0xFF) / 255;
var b:Number = (color >> 0 & 0xFF) / 255;
if ( r >= g ) cmax = r; else cmax = g; if ( b > cmax) cmax = b; if ( r <= g ) cmin = r; else cmin = g; if ( b < cmin) cmin = b;
l = (cmax + cmin) / 2; c = cmax - cmin;
if ( c != 0 ) { if ( l <= 0.5 ) s = c / (cmax + cmin); else s = c / ( 2 - (cmax + cmin));
if ( r == cmax) { h = ( g - b ) / c; }
else { if (g == cmax) { h = 2 + ( b - r ) / c; } else { if ( b == cmax ) h = 4 + ( r - g ) / c; } }
h = h * 60; if ( h < 0 ) h = h + 360;
}
return [h, s, l];
}