forked from: forked from: 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.
/**
* Copyright mabo99 ( http://wonderfl.net/user/mabo99 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/5v52
*/
// forked from kazmaro's forked from: fladdict challenge for amateurs
// 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 {
public var canvas:BitmapData;
public var drawHere:BitmapData;
public var mat:Matrix;
private var bitmap:Bitmap;
public function Beginner() {
canvas = new BitmapData(550,400,false,0xFFFFFF);
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();
}
public function update():void{
drawStep();
transformStep();
renderStep();
fadeStep();
}
//private var size_stage:uint = 100;
public function drawStep():void {
for (var i:int = 0; i < 700; ++i){
drawHere.setPixel( stage.mouseX + (Math.random()-0.5)*200, stage.mouseY + (Math.random()-0.5)*200, Math.random()*0xFFFFFF);
//trace(i);
}
}
public function transformStep():void {
var scale_change:Number = 1.2;
var noise_rotate:Number = 0.2;
mat = new Matrix();
mat.translate(-stage.mouseX,-stage.mouseY);
mat.scale(scale_change, scale_change);
mat.rotate((Math.random()-0.5)*noise_rotate);
mat.translate(stage.mouseX, stage.mouseY);
}
public function renderStep():void{
canvas.draw(drawHere, mat, null, BlendMode.NORMAL);
}
public function fadeStep():void{
var mul:Number = 1.1;
var alpha:Number = 0.7;
var ct:ColorTransform = new ColorTransform(mul,mul,mul,alpha,0,0,0,0)
canvas.colorTransform(drawHere.rect, ct);
}
}
}