/*Katrina Hu
15104-C
kfh@andrew.cmu.edu
Project-03-Dynamic Drawing*/
var sunW = 50
var sunH = 50
function setup() {
createCanvas(640, 480);
}
function draw() {
//change background color
background (191 - mouseY, 228 - mouseY, 255 - mouseY);
noStroke();
//change sun size
if (mouseY < height / 2.5) {
sunW = height / 3 - mouseY;
sunH = height / 3 - mouseY;
}
else {
sunW = 10
sunH = 10;
}
//draw sun
//sun moves by mouseY
fill (255, 247, 158);
ellipse (300 - mouseY, 200 - mouseY, sunW, sunH);
//draw houses
//color of house lightens by mouseY/3
//shape of house changes
fill(79 + mouseY / 3, 68 + mouseY / 3, 61 + mouseY / 3);
rect(50, 380, 100 + mouseY / 25, 100);
rect(200, 380, 100 + mouseY / 25, 100);
rect(350, 380, 100 + mouseY / 25, 100);
rect(500, 380, 100 + mouseY / 25, 100);
triangle(100, 330, 30, 380, 170, 380);
triangle(250, 330, 180, 380, 320, 380);
triangle(400, 330, 330, 380, 470, 380);
triangle(550, 330, 480, 380, 620, 380);
}
This project changes four different aspects of image elements – size, shape, position, and color. It was a fun project to do, as it was interesting to experiment with how mouse position would affect these elements.