I began my coding experiment exploring the ability to code in easing principles to multiple objects within a code. In this particular code, three objects follow in offset of the original (which is controlled by the placement of the mouse. The location of the mouse also controls the hue of the background (based on a hue array). The color of the third object (also a circle) is affected inversely by the location than the lead circle is. If you try it you will understand ....
arduino is your duino,
Willie & Sam
//assignment_1_Willie Franklin
int wide = 1000;
int high = 700;
int d = 60;
float x1 = random(wide);
float y1 = random(high);
float easing1 = .03;
float x2 = random(wide);
float y2 = random(high);
float easing2 = .05;
float x3 = random(wide);
float y3 = random(high);
float easing3 = .07;
void setup() {
size (wide, high);
smooth() ;
colorMode(RGB, height, height, height);
strokeWeight(3);
noCursor();
}
void draw() {
if (mousePressed == true) {
fill(mouseY, mouseX, height);
} else {
fill(0);
}
background (pmouseX, pmouseY, height);
// circle 1
stroke (#484B4A);
noFill();
rectMode(CENTER);
rect(x1, y1, d+15, d+15);
x1 += (mouseX - x1) *easing1;
y1 += (mouseY - y1) *easing1;
// circle 2
noStroke () ;
fill(pmouseY, pmouseX, width);
ellipse(x2, y2, d+10, d+10);
x2 += (mouseX - x2) *easing2;
y2 += (mouseY - y2) *easing2;
// circle 3
stroke (#FFFFFF);
noFill();
rectMode(CENTER);
rect(x3, y3, d+5, d+5);
x3 += (mouseX - x3) *easing3;
y3 += (mouseY - y3) *easing3;
// dot on cursor
noStroke();
fill(height, height, mouseX);
ellipse (mouseX, mouseY, d, d);
}
No comments:
Post a Comment