jjpeng project 3
function setup() {
createCanvas(640, 480);
}
function draw() {
background(158, 189, 204);
// makes the ellipse size depend on the position of the mouse
var w = mouseX / 5;
var h = mouseY / 5;
// makes blue of ellipse depend on mouseX and be at least 140
// makes red of ellipse depend on mouseY and be at least 180
var colorX = mouseX / 10 + 140;
var colorY = mouseY / 5 + 180;
// square rotation depends on mouseX, rows alternate between
// clockwise and counter clockwise
var cwR = mouseX / 5;
var ccwR = 360 - mouseX / 5;
// square sides are at least 50 and depend on mouseY
var squareSide = 50 + mouseY / 10;
var squareMove = mouseX / 10 - 60
// squares
fill(255);
stroke(255);
// row 1
push();
rectMode(CENTER);
translate(160 + squareMove, 120);
rotate(radians(cwR));
rect(0, 0, squareSide, squareSide);
pop();
push();
rectMode(CENTER);
translate(320 + squareMove, 120);
rotate(radians(ccwR));
rect(0, 0, squareSide, squareSide);
pop();
push();
rectMode(CENTER);
translate(480 + squareMove, 120);
rotate(radians(ccwR));
rect(0, 0, squareSide, squareSide);
pop();
// row 2
push();
rectMode(CENTER);
translate(160 - squareMove, 240);
rotate(radians(ccwR));
rect(0, 0, squareSide, squareSide);
pop();
push();
rectMode(CENTER);
translate(320 - squareMove, 240);
rotate(radians(cwR));
rect(0, 0, squareSide, squareSide);
pop();
push();
rectMode(CENTER);
translate(480 - squareMove, 240);
rotate(radians(ccwR));
rect(0, 0, squareSide, squareSide);
pop();
// row 3
push();
rectMode(CENTER);
translate(160 + squareMove, 360);
rotate(radians(cwR));
rect(0, 0, squareSide, squareSide);
pop();
push();
rectMode(CENTER);
translate(320 + squareMove, 360);
rotate(radians(ccwR));
rect(0, 0, squareSide, squareSide);
pop();
push();
rectMode(CENTER);
translate(480 + squareMove, 360);
rotate(radians(ccwR));
rect(0, 0, squareSide, squareSide);
pop();
// ellipse colors
fill(colorY, 240, colorX);
stroke(colorY, 240, colorX);
// ellipses
// row 1
ellipse(64, 0, h, w);
ellipse(192, 0, h, w);
ellipse(320, 0, h, w);
ellipse(448, 0, h, w);
ellipse(576, 0, h, w);
// row 2
ellipse(0, 120, w, h);
ellipse(128, 120, w, h);
ellipse(256, 120, w, h);
ellipse(384, 120, w, h);
ellipse(512, 120, w, h);
ellipse(640, 120, w, h);
// row 3
ellipse(64, 240, h, w);
ellipse(192, 240, h, w);
ellipse(320, 240, h, w);
ellipse(448, 240, h, w);
ellipse(576, 240, h, w);
// row 4
ellipse(0, 360, w, h);
ellipse(128, 360, w, h);
ellipse(256, 360, w, h);
ellipse(384, 360, w, h);
ellipse(512, 360, w, h);
ellipse(640, 360, w, h);
// row 5
ellipse(64, 480, h, w);
ellipse(192, 480, h, w);
ellipse(320, 480, h, w);
ellipse(448, 480, h, w);
ellipse(576, 480, h, w);
}
I wanted to capture a few common movements with my dynamic drawing (rotation, translation, growth/shrinking, color change). I also wanted to create a repetitive pattern that changed depending on what row it was in. My initial inspirations were a pattern with dots.