블로그 이미지
Leeway is... the freedom that someone has to take the action they want to or to change their plans.
maetel

Notice

Recent Post

Recent Comment

Recent Trackback

Archive

calendar

1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
  • total
  • today
  • yesterday

Category

2007. 8. 30. 03:29 Code/Processing

//finn interaction test wave
//ref. http://www.shiffman.net/itp/classes/nature/week04_s06/sine/

int xs = 5;
int w;

float th = 0.0f;
float a = 60.0;
float p = 400.0f;
float dx;
float[] y;

void setup(){
  size(320,240);
  frameRate(30);
  colorMode(RGB,255,255,255,80);
  smooth();
  w = width+8;
  dx = (TWO_PI/p)*xs;
  y = new float[w/xs];
}

void draw(){
  background(0);
  calcWave();
  renderWave();
}

void calcWave(){
  th += 0.02;
  float x = th;
  for (int i=0; i<y.length; i++){
    y[i]=a*sin(x);
    x+=dx;
  }
}

void renderWave(){
  for (int x=0; x<y.length; x++){
    noStroke();
    fill(255,0,0);
    ellipseMode(CENTER);
    ellipse(x*xs,width/2+y[x],5,5);
  }
}

'Code > Processing' 카테고리의 다른 글

stair  (0) 2006.08.11
clock  (0) 2006.06.19
posted by maetel