Animated Sketch from Recitation 5
void setup(){ size(1300, 700); } //colors //(196, 37, 27) red //(247,214,55) yellow void draw() { background(142, 159, 167); noFill(); strokeWeight(15); stroke(196, 37, 27, 100); int a = 100; int b = 1100; int c = 800; int d = -700; for (int i = 0; i <= 15; i++){ a = a + 30; b = b + 30; c = c + 30; d = d + 30; bezier(0,0, a+mouseX,b+mouseY, c-mouseX,d-mouseY, 1300,700); } }
Post Recitation HW:
Step One
void setup() { size(600,600); background(255); } void draw() { noFill(); strokeWeight(20); ellipseMode(CENTER); ellipse(width/2,height/2,300,300); }
Step Two
float size = 100; float sizeSpeed = 3; void setup() { size(600,600); } void draw() { background(255); noFill(); strokeWeight(20); ellipseMode(CENTER); ellipse(width/2,height/2,size,size); size = size + sizeSpeed; if (size > 325 || size < 100) { sizeSpeed = -sizeSpeed; } }
Step Three
float size = 100; float sizeSpeed = 3; int hue = 0; int hueSpeed = 2; void setup() { size(600,600); } void draw() { background(255); noFill(); colorMode(HSB); strokeWeight(20); stroke(hue,255,255); ellipseMode(CENTER); ellipse(width/2,height/2,size,size); size = size + sizeSpeed; if (size > 325 || size < 100) { sizeSpeed = -sizeSpeed; } hue = hue + hueSpeed; if (hue > 360 || hue < 0) { hueSpeed = -hueSpeed; //can also do this //hue=0; } }
Step Four
float size = 100; float sizeSpeed = 3; int hue = 0; int hueSpeed = 2; int x = 300; int y = 300; void setup() { size(600,600); } void draw() { background(255); noFill(); colorMode(HSB); strokeWeight(20); stroke(hue,255,255); ellipseMode(CENTER); ellipse(x,y,size,size); size = size + sizeSpeed; if (size > 325 || size < 100) { sizeSpeed = -sizeSpeed; } hue = hue + hueSpeed; if (hue > 360 || hue < 0) { hueSpeed = -hueSpeed; //can also do this //hue=0; } if (keyPressed){if (key==CODED){ if(keyCode==UP){ y = y-10; } if (keyCode==DOWN){ y = y+10; } if(keyCode==RIGHT){ x = x+10; } if (keyCode==LEFT){ x = x-10; } } } if (x>width){ x = width; } if (x<0){ x = 0; } if (y>height){ y = height; } if (y<0){ y = 0; } }