xxxxxxxxxx
82
function setup() {
createCanvas(400, 400);
background(5);
// background detailing
noStroke();
fill(15);
ellipse(width/2, height/2, 350,350);
fill(25);
ellipse(width/2, height/2, 280,280);
fill(30);
ellipse(width/2, height/2, 200,200);
fill(35);
ellipse(width/2, height/2, 120,120);
}
// starting shape
function draw() {
// small star shape
noStroke();
fill(0, 0, 255);
triangle(200, 160, 190, 200, 210, 200);
triangle(200, 240, 190, 200, 210, 200);
triangle(160, 200, 200, 190, 200, 210);
triangle(240, 200, 200, 190, 200, 210);
}
// generates star forms
function mousePressed () {
// change color along the red-blue spectrum
let R_color = random(0,255);
let B_color = random(0,255);
noStroke();
fill(R_color, 0, B_color);
// change size
let dh = random(-160, 160); // change in height
let dw = random(-90,90); // change in width
// star
push();
blendMode(HARD_LIGHT);
triangle(200, 160-dh, 190-dw, 200, 210+dw, 200);
triangle(200, 240+dh, 190-dw, 200, 210+dw, 200);
triangle(160-dh, 200, 200, 190-dw, 200, 210+dw);
triangle(240+dh, 200, 200, 190-dw, 200, 210+dw);
pop();
if (dh > 100) {
triangle(40,40, 200,160, 160,200);
triangle(360,40, 200,160, 240,200);
triangle(40,360, 200,240, 160,200);
triangle(360,360, 200,240, 240,200);
}
}
// clears canvas when key is pressed
function keyPressed() {
clear();
background(5);
noStroke();
fill(15);
ellipse(width/2, height/2, 350,350);
fill(25);
ellipse(width/2, height/2, 280,280);
fill(30);
ellipse(width/2, height/2, 200,200);
fill(35);
ellipse(width/2, height/2, 120,120);
}