function setup() {
createCanvas(500, 500);
text("p5.js vers 0.9.0 test.", 10, 15);
}
function draw() {
//setting up the background color
let firstColor = color(45,0,85); //first color to be blended from
let secondColor = color(219,146,7); //second color to be blended from
bldval = map(mouseX, 0,width,0,1,true); //the blending proportion
bColor = lerpColor(firstColor,secondColor,bldval); // the background color based on mouseX
background(bColor); //setting background
//vertical and horizontal rectangle
noStroke()
rectColor = lerpColor(secondColor,firstColor,bldval);
move = map(mouseY,0,height,300,320,true); //constraining the position of the horizintal rectangle
fill(rectColor);
rect(mouseX-40,0,80,height); //vertical rectangle
rect(0,move-40,width,80); //horizontal rectangle
//circle on top right moving to top left
fill(255);
ellipse(450 - mouseX,100,30,30);
fill(rectColor);
crcWidth = 100 - mouseX/2;
crcHeight = 200 - mouseX/2;
push();
translate(450 - mouseX,100);
rotate(0+mouseX);
ellipse(0,0,crcWidth,crcHeight);
pop();
//rotating white circles around mouse X and mouse Y
push();
fill(255)
translate(mouseX,mouseY);
rotate(mouseX/10);
ellipse(0,-30,+10,10);
ellipse(0,30,-10,10);
}
I enjoyed doing this. The hardest idea was possibly to start the project. After that it was pretty quick.