円状に回ってるやつ(processing)
円が回ってるやつ(processing)
float x,y; int i, speed, cycle; String texX, texY; void setup(){ size(300, 300); colorMode(RGB, 100); x = 0; y = 0; i = 0; speed = 360; //低い程速い cycle = speed*2; } void draw() { background(100); float calc_pi; calc_pi = PI/speed*i; x = 130 + cos(calc_pi) * 100; y = 130 - sin(calc_pi) * 100; i++; if(i == cycle) i = 0; draw_back(); draw_line(); draw_circle(); draw_text(); } void draw_back() //後ろの円や線を表示 { ellipseMode(CENTER); stroke(80); strokeWeight(5); noFill(); ellipse(130, 130, 200, 200); line(30, 270, 230, 270); line(270, 30, 270, 230); } void draw_circle() //動く円と座標を表示 { ellipseMode(CENTER); noStroke(); fill(0); ellipse(x, y, 15, 15); ellipse(x, 270, 15, 15); ellipse(270, y, 15, 15); } void draw_line() //円と円を結ぶ線 { stroke(85); strokeWeight(2); line(x, y, x, 270); line(x, y, 270, y); } void draw_text() //テキスト表示 { stroke(0); texX = "x = " + nf(x/100-1.3,1,3); texY = "y = " + nf(y/100-1.3,1,3); text(texX, 10, 20); text(texY, 10, 40); }