/* Anthony Ra
Section-A
ahra@andrew.cmu.edu
Project-03-DynamicDrawing */
/* assigning altering variables */
var tor = 150;
var tot = 3;
var torr = 100;
var tort = 5;
var torrr = 30;
var tortt = 0.5;
var dir = 1;
var speed = 2;
var speedd = 5;
function setup() {
createCanvas(640, 480, WEBGL);
frameRate(100);
noCursor();
}
function draw () {
/* altering color of background */
var r = map(mouseX, 0, height, 220, 215);
var g = map(mouseX, 0, height, 255, 0);
var b = map(mouseX, 0, height, 0, 255);
background(r, g, b);
noStroke();
rotateX(mouseX * 0.01);
rotateY(mouseY * 0.01);
ambientLight(40, 210, 60);
ambientMaterial(90, 200, 100);
speed = mouseX / 20;
torus(tor + speed*dir, tot + speed*dir);
/* movement of larger torus */
noStroke();
rotateX(mouseX * 0.01);
rotateY(mouseY * 0.01);
ambientLight(150, 30, 50);
ambientMaterial(100, 50, 100);
speed = mouseX / 20;
torus(torr + speed*dir, tort + speed*dir);
/* movement of smaller torus */
noStroke();
rotateX(mouseX * 0.01);
rotateY(mouseY * 0.01);
ambientLight(50);
ambientMaterial(150);
speedd = mouseX / 10;
torus(torrr + speedd*dir, tortt + speedd*dir);
}
This process was definitely a bit more challenging than the previous projects because I was thinking more about which lines of code was going to work rather than what I wanted my end product to look like. Something new that I played with is the implementation of 3-dimensional shapes and its movement along the mouse. I felt that toruses best represented the different angles that can be controlled by the mouse.