float x=0,y=0; //オブジェクトx,y座標 float t; //角度 int R; //円の半径 void setup(){ background(255); size(400,400); t = 0; R = 10; noStroke(); fill(0); } void draw() { R += 1; t += 0.1; x = mouseX + R*cos(t); y = mouseY + R*sin(t); ellipse(x,y,5,5); if( x >= width || y>= height){ //x,yが範囲を超えたらR=0,t=0にする R = 0; t = 0; } } void mousePressed() { noLoop(); // ボタンを押すと動きが止まる } void mouseReleased() { loop(); // ボタンが離されたら動き出す }