/ p5 / re-code 03

Hommage to Zdeňek Sýkora

/*
 * Untitled, Hommage to Zdeňek Sýkora (1920 - 2011)
 * 
 * Kof / Kryštof Pešek 2012
 *
 */
 
var theta = [];
var moznosti = [0,90,180,270];
var rot = [1,2,4];
var r;

function preload(){
 plny = loadImage("plny.png");
}
 
function setup(){
 createCanvas(576,704,P2D);
 imageMode(CENTER);
 for (var i = 0 ; i < 3000 ; i ++){
 theta[i] = moznosti[int(random(4))];
 }
}
 
function draw(){
 background(0);
 r = plny.width;
 
 var idx = 0;
 for(var y = 0;y <= height/plny.height;y++){
 for(var x = 0;x <= width/plny.width;x++){
 push();
 translate(x*r+plny.width/2,y*r+plny.height/2);
 rotate(radians(theta[idx]));
 theta[idx] += 0.004*degrees(frameCount/200.0*atan2(mouseY-y*r,mouseX-x*r));
 image (plny,0,0);
 pop();
 idx += 1;
 }
 }
}