/*
Eliza Pratt
Section E
elpratt@andrew.cmu.edu
Project-03
*/
function setup() {
createCanvas(640, 480);
}
function draw() {
noStroke();
//creates color variables for background based on mouse position
var bG = (mouseX/width) * 255;
var bB = (mouseY/height) * 255;
background(100, bG, bB);
//block of color that moves with mouseX
fill(200, bG, bB);
rect(0, 0, mouseX, 480);
//starting positions for vertical and horizontal lines
var y1 = 45;
var x1 = 0;
//variables for line weight and angle based on mouse position
var hWidth = (mouseY/width) * 45
var angle = (mouseX/width) * 360
fill(255);
////////ROTATING LINES///////
push();
//transforms vertical lines to rotate about the center
translate(width/2, height/2);
rotate(radians(angle));
//draws vertical lines
for(var i = 0; i < 20; i++) {
fill(0);
rect(x1 -50 - width/2, 0, hWidth, 800);
x1+=50;
}
pop();
/////////HORIZONTAL LINES////////
for(var i = 0; i < 9; i++) {
rect(width/2, y1, width, hWidth);
y1+=50;
}
}
Compared to the last two weeks, I found this project to be the most challenging since it was so open ended. While this sketch was originally intended to be a grid with fixed horizontal and rotating vertical lines, I ended up with this just by commenting out the “recMode(CENTER) and letting the black lines do as they please! This turned out way cooler than I expected and I was pleasantly surprised with how the colors go together.