forked from: Ink Tween
// forked from peko's Ink Tween
// forked from Hitokita's 初Tweener
package{
import caurina.transitions.properties.CurveModifiers;
import caurina.transitions.properties.DisplayShortcuts;
import caurina.transitions.properties.FilterShortcuts;
import flash.display.*;
import flash.events.Event;
import flash.filters.*;
import flash.geom.*;
import flash.net.URLRequest;
import flash.system.LoaderContext;
import flash.utils.setInterval;
import flash.utils.setTimeout;
public class Field extends Sprite{
private var canvas:Bitmap = new Bitmap(new BitmapData(stage.stageWidth,stage.stageHeight,true));
private const IMAGE_URL:String = "http://img-fotki.yandex.ru/get/3506/gasubasu.23/0_a6be_d4007aaf_XL";
private var image:Bitmap;
private var imageData:BitmapData;
public function Field() {
FilterShortcuts.init();
DisplayShortcuts.init();
CurveModifiers.init();
addChild(canvas);
setInterval(drawCanvas, 30);
// var s:Stats = new Stats();
// s.alpha = 0.25;
// addChild(s);
var req:URLRequest = new URLRequest(IMAGE_URL);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
loader.load( req, new LoaderContext(true));
// take a capture after 10 sec
//Wonderfl.capture_delay( 10 );
//setTimeout(function():void{Wonderfl.capture(stage);},20000);
}
public function loadComplete(e:Event = null):void {
e.target.removeEventListener(Event.COMPLETE, loadComplete);
image = e.target.loader.content as Bitmap;
imageData = image.bitmapData;
Fooler.colorSource = imageData;
for (var i:uint = 0; i<50; i++){
var f:Fooler = new Fooler();
addChild(f);
f.foolAround();
}
}
private function drawCanvas():void {
canvas.bitmapData.draw(this);
/*
canvas.bitmapData.applyFilter(canvas.bitmapData, canvas.bitmapData.rect, new Point(0), new BlurFilter(
2,2,2
));
canvas.bitmapData.applyFilter(canvas.bitmapData, canvas.bitmapData.rect, new Point(), new ColorMatrixFilter([
1.01, 0, 0, 0, 0,
0, 1.01, 0, 0, 0,
0, 0, 1.01, 0, 0,
0, 0, 0, 1, 0
]));
*/
}
}
}
import flash.display.*;
import caurina.transitions.Tweener;
class Fooler extends Sprite {
private var tx:Number;
private var ty:Number;
private var bx:Number;
private var by:Number;
public static var foolers:Array = [];
public static var colorSource:BitmapData;
function Fooler() {
x = Math.random()*450;
y = Math.random()*450;
// alpha = 0;
draw();
foolers.push(this);
}
public function draw():void{
blendMode = Math.random()>0.75 ? "overlay" : "normal";
var g:Graphics = graphics;
g.clear();
g.beginFill(colorSource.getPixel(x,y+200), Math.random());
g.drawCircle(0,0,4);
g.endFill();
};
public function foolAround():void {
bx = Math.random()*stage.stageWidth;
by = Math.random()*stage.stageHeight;
tx = Math.random()*stage.stageWidth;
ty = Math.random()*stage.stageHeight;
var z:Number = Math.random();
Tweener.addTween(this, {
x: tx,
y: ty,
_bezier: [{x:bx, y:by}],
_scale:z*10,
alpha: 1-z,
time: Math.random()*3/z,
// delay: Math.random()*3,
_Blur_blurX: Math.abs(z*20),
_Blur_blurY: Math.abs(z*20),
_Blur_quality:2,
transition: 'linear',
onUpdateParams:[this],
onUpdate:function(...args):void {Fooler(args[0]).draw()},
onComplete: foolAround
});
}
}