xxxxxxxxxx
var i=0;
var inc=0;
function setup() {
createCanvas(windowWidth,windowHeight);
}
function draw() {
background(250,2);
// colorMode(HSB,255);
//for(var j=3;j<16;j++){
//push();
for(var h=40;h<width;h+=140){
for(var n=40;n<height;n+=140){
push();
translate(h,n);
rotate(frameCount);
pop();
var maxRad=map(noise(inc),0,1,200,50);
var minRad=map(noise(inc),0,1,50,200);
var a=map(sin(i),-1,1,minRad,maxRad);
var b=map(cos(i),0,1,maxRad,minRad);
var colR=map(h,0,width,frameCount/100,150);
var colB=map(n,0,height,20,250);
stroke(colR,colR,colB);
star(h, n, a, b,8);
}
}
//pop();
// }
i+=.01;
inc+=0.01;
/*push();
translate(width * 0.5, height * 0.5);
rotate(frameCount / 50.0);
star(0, 0, 80, 100, 40);
pop();
push();
translate(width * 0.8, height * 0.5);
rotate(frameCount / -100.0);
star(0, 0, 30, 70, 5);
pop();*/
}
function star(x, y, radius1, radius2, npoints) {
let angle = TWO_PI / npoints;
let halfAngle = angle / 2.0;
noFill();
// stroke(200,0,0);
beginShape();
for (let a = 0; a < TWO_PI; a += angle) {
let sx = x + cos(a) * radius2;
let sy = y + sin(a) * radius2;
curveVertex(sx, sy);
sx = x + cos(a + halfAngle) * radius1;
sy = y + sin(a + halfAngle) * radius1;
curveVertex(sx, sy);
}
endShape(CLOSE);
}