Week 2 Tut­o­r­i­a­l

by Chris Green
  • Show Sketch
/* @peep sketchcode */
 
int x1 = 200;
int y1 = 0;
int x2 = 200;
int y2 = 400;
int r = 70;
int g = 255;
int b = 100;
int ri = 0;
int bi = 0;
int gi = 0;
 
float r = 0.0 ;
float c = 0.0;
 
int y1i = 0;
int y2i = 0;
 
void setup(){
  size(400,400);
  stroke(127, 0, 0);
  noFill();
  frameRate(60);
  rectMode(CENTER);
 
}
 
void draw(){
 
  background(r,g,b);
  bezier(0,0,x1,y1,x2,y2,400,400);
  bezier(0,400,x1,y1,x2,y2,400,0);
 
  if(r>=255){ri=1;}
  if(r<=0){ri=0;}
  if(ri==1){r-=1;}
  if(ri==0){r+=1;}
 
  if(b>=255){bi=1;}
  if(b<=0){bi=0;}
  if(bi==1){b-=2;}
  if(bi==0){b+=1;}
 
  if(g>=255){gi=1;}
  if(g<=0){gi=0;}
  if(gi==1){g-=1;}
  if(gi==0){g+=2;}
 
 
  if(y1>=400){y1i=1;}
  if(y1<=0){y1i=0;}
  if(y1i==1){y1-=1;}
  if(y1i==0){y1+=1;}
 
  if(y2>=400){y2i=1;}
  if(y2<=0){y2i=0;}
  if(y2i==1){y2-=1;}
  if(y2i==0){y2+=1;}
  c+=1;
  translate(200, 200);
  r=c*TWO_PI/360;
  rotate(r);
  fill(r/2,g/2,b/2,150);
  rect(0,0,100,100);
}

Comments

Nobody has said anything yet.