xxxxxxxxxx
function setup() {
createCanvas(windowWidth*0.5, windowHeight*0.7);
background(0);
randomSeed(99);
frameRate(60);
}
function splot(x,y,c1, c2, c3)
{
loadPixels();
for(var i = max(floor(x-width/4),0); i < min(floor(x+width/4),width); i+=1) {
for(var j = max(floor(y-width/4),0); j < min(floor(y+width/4),height); j+=1) {
var px = i;
var py = j;
var xp = i-x;
var yp = j-y;
xp /= height;
yp /= height;
d = 4*sqrt(xp*xp+yp*yp);
xp += d*noise((px+x)/300,(py+y)/300)-d/2;
yp += d*noise((py+y)/300,(px+x)/300)-d/2;
d = sqrt(xp*xp+yp*yp);
if(d < 0.03) {
set(px,py,color(c1,c2,c3,255));
set(width-px,py,color(c1,c2,c3,255));
set(px,height-py,color(c1,c2,c3,255));
set(width-px,height-py,color(c1,c2,c3,255));
}
}
}
updatePixels();
}
function draw() {
var x = random(width);
var y = random(height);
var dx = (x - width/2)/(height/2);
var dy = (y - height/2)/(height/2);
var d = sqrt(dx*dx+dy*dy)/2;
if(d<0.4) splot(x,y,255*d,0,0);
else if(d<0.7) splot(x,y,0,127*d,0);
else splot(x,y,10*d,10*d,10*d);
if(keyIsPressed || mouseIsPressed) {
clear();
}
}