Owen Fox Project 4

var i;
//a constant used for positioning
var c = 100;
//another constant used to manipulate framecount
var f = 50;

function setup() {
    createCanvas(640, 480);
}

function draw() {
	background("#00cc44");
  for (var i = 0; i < 60; i+=1) {
    //each of these sections seperates by white spice does two things
    //one, they draw a set of rectangles rotated according to the value of i
    //two, they draw a set of rectangles that roate according to framecount
    rectMode(CENTER);
    noStroke();
    fill("#00e64d");
    push();
    rotate(radians(i));
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate(radians(-i));
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate((i * radians(frameCount))/f);
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate((-i * radians(frameCount))/f);
    rect(width/2,height/2,2,2*c);
    pop();

    fill("#4dff88");
    push();
    translate(0,2*c);
    push();
    rotate(radians(i));
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate(radians(-i));
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate((i * radians(frameCount))/f);
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate((-i * radians(frameCount))/f);
    rect(width/2,height/2,2,2*c);
    pop();
    pop();

    fill("#4dff88");
    push();
    translate(0,-2*c);
    push();
    rotate(radians(i));
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate(radians(-i));
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate((i * radians(frameCount))/f);
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate((-i * radians(frameCount))/f);
    rect(width/2,height/2,2,2*c);
    pop();
    pop();

    fill("#1aff66");
    push();
    translate(0,c);
    scale(1,-1);
    push();
    rotate(radians(i));
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate(radians(-i));
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate((i * radians(frameCount))/f);
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate((-i * radians(frameCount))/f);
    rect(width/2,height/2,2,2*c);
    pop();
    pop();

    fill("#1aff66");
    push();
    translate(0,-c);
    scale(1,-1);
    push();
    rotate(radians(i));
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate(radians(-i));
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate((i * radians(frameCount))/f);
    rect(width/2,height/2,2,2*c);
    pop();
    push();
    rotate((-i * radians(frameCount))/f);
    rect(width/2,height/2,2,2*c);
    pop();
    pop();

  }
}

Leave a Reply