アットウィキロゴ

配列とマウスイベント

実行結果


操作方法

  1. JARファイルを実行したら、ウィンドウ内でマウスポインタを動かす。
  2. マウスポインタを追尾するグラデーション状の円が描画されます。

ソースコード

int[] posx = new int[10];
int[] posy = new int[10];
 
void setup(){
  for(int i=0;i<10;i++){
    posx[i] = 0;
    posy[i] = 0;
  }
 
 
  size(400,400);
  noCursor();
  noStroke();
}
 
void draw(){
  for(int i=9;i>0;i--){
    posx[i] = posx[i-1];
    posy[i] = posy[i-1];
  }
  posx[0] = mouseX;
  posy[0] = mouseY;
 
  background(0);
 
  for(int i=9;i>=0;i--){
    fill(250 - 25*i);
    ellipse(posx[i],posy[i],20-i,20-i);
  }
}


最終更新:2009年01月29日 16:30
ツールボックス

下から選んでください:

新しいページを作成する
ヘルプ / FAQ もご覧ください。