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 coppieee ( http://wonderfl.net/user/coppieee )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/wvxN
*/
/**
* 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;
import frocessing.color.ColorHSV;
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 function update():void{
drawStep();
transformStep();
renderStep();
fadeStep();
}
private var _colorHSV:ColorHSV = new ColorHSV();
public function drawStep():void {
_colorHSV.h++;
drawHere.setPixel( Math.random()*480, Math.random()*480, _colorHSV.value);
}
private var _theta:Number = 0;
public function transformStep():void
{
//ベクトルを制すものは世界を制す!
_theta += Math.PI / 180 * 2;
var L:Point = new Point(100,0);
var R:Point = new Point(Math.cos(_theta), Math.sin(_theta));
var V:Point = L.add(R);
var rho:Number = Math.acos((L.x * V.x + L.y * V.y) / (L.length * V.length));
mat = new Matrix();
mat.translate(-240,-240);
mat.scale(1.008*V.length/L.length,1.008*V.length/L.length);
mat.rotate(Math.PI / 180 * 0.5 + rho);
mat.translate(240,240);
}
private var _t:int = 0;
public function renderStep():void{
//canvas.draw(drawHere, mat, null,BlendMode.LIGHTEN);
//http://wonderfl.net/code/456753e8056320b07b093fb7244383a01bdf3e1d
//を勝手に参考。(というかコピペ。)
canvas.draw(drawHere, mat, null,(_t++ % 3) !== 0 ? BlendMode.LIGHTEN : BlendMode.DARKEN);
}
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));
}
/**
* ---------------------------------------
* 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();
}
}
}