Every frame you get screen caputre of the stage.
* Generate new frame image with using last frames screen capture.
* This is a starting point of recursive generative art.
/**
* Copyright sacrifs ( http://wonderfl.net/user/sacrifs )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/irLu
*/
// forked from checkmate's fladdict challenge for amateurs
/**
* Every frame you get screen caputre of the stage.
* Generate new frame image with using last frames screen capture.
* This is a starting point of recursive generative art.
*/
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.ColorTransform;
import flash.geom.Matrix;
import flash.geom.Point;
public class Beginner extends Sprite {
/**
* Overwrite this update function.
* Every frame the function is invoked with two bitmaps.
* First one contains reference to the stage bitmap.
* Second one contains static copy of stage.
*/
public var canvas:BitmapData;
public var drawHere:BitmapData;
public var mat:Matrix;
private var vx:Number = 0;
private var vy:Number = 0;
public function update():void{
drawStep();
transformStep();
renderStep();
fadeStep();
}
public function drawStep():void {
//drawHere.setPixel(stage.mouseX, stage.mouseY, 0x11111111);
drawHere.setPixel( Math.random()*480, Math.random()*480, 0xffffffff);
}
public function transformStep():void
{
mat = new Matrix();
//mat.translate(-240,-240);
//mat.scale(1.005,1.005);
//mat.rotate(0.05);
//mat.translate(240,240);
mat.translate(-240+vx,-240+vy);
((int(Math.random() * 100) + 1) % 100) ? mat.scale(0.952, 0.952) : mat.scale(1.02, 1.02);
mat.rotate(0.2952);
mat.translate(240+vx, 240+vy);
vx += Math.random() * 0.4 - 0.2;
vy += Math.random() * 0.4 - 0.2;
if(vx > 2){vx = 2;}else if(vx < -2){vx = -2;}
if(vy > 2){vy = 2;}else if(vy < -2){vy = -2;}
}
public function renderStep():void{
//canvas.draw(drawHere, mat, null,BlendMode.SCREEN);
canvas.draw(drawHere, mat, null,BlendMode.ADD);
canvas.scroll(-Math.round(vx), -Math.round(vy));
}
import flash.filters.BlurFilter;
public function fadeStep():void
{
//canvas.colorTransform(drawHere.rect, new ColorTransform(Math.random()*0.4+0.6,Math.random()*0.4+0.6,Math.random()*0.4+0.6,1,0,0,0,0));
canvas.colorTransform(drawHere.rect, new ColorTransform(0.963,0.912,0.3,0.96,0,0,0,0));
canvas.applyFilter(canvas, drawHere.rect, new Point(), new BlurFilter(2, 2, 1));
if(int(Math.random() * 100 + 1) % 100 == 0){drawHere.dispose();}
}
/**
* ---------------------------------------
* DO NOT CHANGE FOLLOWING CODES
* DO NOT ACCESS FOLLOWING PROPERTIES DIRECTLY
* ---------------------------------------
*/
private var bitmap:Bitmap;
public function Beginner() {
canvas = new BitmapData(480,480,false,0x000000);
bitmap = new Bitmap(canvas);
addChild(bitmap);
addEventListener(Event.ENTER_FRAME, _update);
}
public function _update(e:Event):void{
if(drawHere)
drawHere.dispose();
drawHere = canvas.clone();
update();
}
}
}