Move Your Mouse Left & Right Across the Stage to Have Different Effects
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 adkOHTAH ( http://wonderfl.net/user/adkOHTAH )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/8yxX
*/
// forked from mattsplatt's forked from: forked from: fladdict challenge for amateurs (み)
// forked from hanjuqu's forked from: fladdict challenge for amateurs (み)
// forked from checkmate's fladdict challenge for amateurs
/**
* Move Your Mouse Left & Right Across the Stage to Have Different Effects
*/
/**
* 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.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
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;
public var randomTranslate1:Number = Math.random()*10;
public var randomTranslate2:Number = Math.random()*15;
public function update(): void
{
drawStep();
renderStep();
fadeStep();
}
public function drawStep(): void
{
drawHere.setPixel(Math.random() * 480, Math.random() * 480, 0xffffffff);
}
private var scale:Number;
public function transformStep(): Matrix
{
mat = new Matrix();
mat.translate(-240, -240);
scale = Math.cos(Math.pow(getTimer(), 2) * Math.PI * 2 * .1);
mat.scale(scale, scale);
mat.rotate(Math.random() + .75);
mat.translate(240, 240);
return mat;
}
public function renderStep(): void
{
canvas.draw(drawHere, transformStep(), null, BlendMode.ADD);
}
public function fadeStep(): void
{
if(mouseX >= 50)
{
canvas.colorTransform(drawHere.rect, new ColorTransform(Math.random() * 0.1 + 0.6, Math.random() * 0.4 + 0.6, Math.random() * 0.4 + 0.6, 1, 0, 0, 0, 0));
}
else if(mouseX <= 50)
{
canvas.colorTransform(drawHere.rect, new ColorTransform(Math.random() * 0.1 + 0.1, Math.random() * 0.1 + 0.2, Math.random() * 0.7 + 0.5, 1, 1, 1, 0, 0));
}
else if(mouseX > 100)
{
canvas.colorTransform(drawHere.rect, new ColorTransform(Math.random() * 100 + 100, Math.random() * 0.1 + 0.2, Math.random() * 0.3 + 0.5, 1, 1, 1, 0, 0));
}
}
/**
* ---------------------------------------
* 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();
}
}
}