This project was extremely intimidating because I didn’t even know where to begin, but after becoming more comfortable with implementing mouseX/mouseY and min/max, it was actually pretty fun. My composition consists of simple geometric shapes, however, the various changes in scale, angle of rotation, position, and color create different compositions depending on your mouse movement.
Maggie – Dynamic Drawingvar blueSqSmall = {
x: 31,
y: 51,
w: 39,
h: 39
};
var greenSqSmall = {
x: 70,
y: 51,
w: 39,
h: 39
};
var yellowCircle = {
x: 50,
y: 130,
w: 39,
h: 39
};
var pinkCircle = {
x: 89,
y: 130,
w: 39,
w: 39
};
function setup() {
createCanvas(370, 500);
background(220);
text("p5.js vers 0.9.0 test.", 10, 15);
}
function draw() {
background(255,255,255);
strokeWeight(3.5);
if (mouseIsPressed) {
background(0);
}
fill(248, 64,0);
rect(31, 51, 78 + mouseX*.08, 224 + mouseY/80);
if (mouseX > width/2) {
fill(255,209,0);
rect(31, 51, 78 + mouseX*.08, 224 + mouseY/80);
}
bottombound = min(mouseY, 236);
fill(40,44,147);
rect(31, bottombound, 39, 39);
fill(255,209,0);
ellipse(yellowCircle.x, bottombound, yellowCircle.w, yellowCircle.h);
if (mouseX > width/2) {
fill(248, 64,0);
ellipse(yellowCircle.x, bottombound, yellowCircle.w, yellowCircle.h);
}
fill(0,164,82);
rect(greenSqSmall.x, bottombound, greenSqSmall.w, greenSqSmall.h);
fill(255,185,200);
ellipse(pinkCircle.x, bottombound, pinkCircle.w, pinkCircle.h);
fill(255,185,200);
rect(31,275, 136,184);
fill(40,44,147);
rect (31,343,68,116 + mouseY/4);
fill(255,209,0);
ellipse(99,343,136,136);
if (mouseX > width/2) {
fill(248, 64,0);
ellipse(99,343,136,136);
}
fill(0,164,82);
push();
translate(99,343);
rotate(radians(mouseY));
arc(0,0,136,136, PI, 0, CHORD);
pop();
fill(0, 164, 82);
ellipse(139, 184, 60,60);
fill(255,209,0);
rect(108, 215, 60, 60, 80, 0, 0, 0);
fill(40,44,147);
rect(168, 138, 171, 137);
ellipse(253,136,171,171);
if (mouseY>height/2) {
fill(255,185,200);
ellipse(253,136,171,171);
}
fill(255,209,0);
push();
translate(253,136);
rotate(radians(mouseY));
arc(0,0,172,172, PI+2, 2, CHORD);
pop();
line(31, 134, 339, 134);
fill(255, 185,200);
ellipse(255, 136, 84, 84);
if (mouseY>height/2) {
fill(40,44,147);
ellipse(255, 136, 84, 84);
}
fill(248, 64,0);
push();
translate(255,136);
rotate(radians(-mouseX));
arc(0,0,84,84, 0, PI, CHORD);
pop();
line(340, 459, 340, 275);
fill(248,64,0);
ellipse(262,370, min(mouseX,188), min(mouseX,188));
line(167, 275,341,459);
fill(255,255,255);
ellipse(65 + mouseX, 459, 70, 70);
fill(255,185,200);
quad(226, 328, 217, 337, 262, 385, 271, 376);
fill(255,209,0);
quad(277,382, 268, 391, 286, 410, 295, 401);
}