![]()  | 
| Processing example: simple animation of sin() | 
int x = 0;
void setup(){
  size(400, 300);
  background(200);
  stroke(0);
}
void draw() {
  
  x += 1;
  if(x > width){
    x = 0;
    background(200);
  }
  
  int center = height/2;
  float angle = x * 4 * PI /width;
  int l = (int)(sin(angle)*height/2);
  line(x, center, x, l + center); 
}

No comments:
Post a Comment