回答編集履歴
2
別案
test
CHANGED
@@ -64,3 +64,43 @@
|
|
64
64
|
circle(x3, y, r);
|
65
65
|
}
|
66
66
|
```
|
67
|
+
|
68
|
+
---
|
69
|
+
|
70
|
+
あるいは先にすべて白で描いておいて、後から上書きしてもいいでしょう。
|
71
|
+
```Processing
|
72
|
+
int x1 = 100, x2 = 250, x3 = 400;
|
73
|
+
int y = 100;
|
74
|
+
int r = 50; // 円の半径
|
75
|
+
|
76
|
+
|
77
|
+
void setup() {
|
78
|
+
size(500, 300); // setupでいい
|
79
|
+
|
80
|
+
ellipseMode(RADIUS); // rを円の半径とするならRADIUSに
|
81
|
+
}
|
82
|
+
|
83
|
+
void draw() {
|
84
|
+
background(255); // つどクリアしないと描画がガビガビになる
|
85
|
+
|
86
|
+
fill(255);
|
87
|
+
circle(x1, y, r);
|
88
|
+
circle(x2, y, r);
|
89
|
+
circle(x3, y, r);
|
90
|
+
|
91
|
+
if (dist(mouseX, mouseY, x1, y) < r) { // 便利な組み込み関数
|
92
|
+
fill(255, 0, 0);
|
93
|
+
circle(x1, y, r);
|
94
|
+
}
|
95
|
+
|
96
|
+
if (dist(mouseX, mouseY, x2, y) < r) {
|
97
|
+
fill(255, 245, 36);
|
98
|
+
circle(x2, y, r);
|
99
|
+
}
|
100
|
+
|
101
|
+
if (dist(mouseX, mouseY, x3, y) < r) {
|
102
|
+
fill(0, 0, 255);
|
103
|
+
circle(x3, y, r);
|
104
|
+
}
|
105
|
+
}
|
106
|
+
```
|
1
便利な
test
CHANGED
@@ -21,7 +21,7 @@
|
|
21
21
|
[ellipse() / Reference / Processing.org](https://processing.org/reference/ellipse_.html)
|
22
22
|
[ellipseMode() / Reference / Processing.org](https://processing.org/reference/ellipseMode_.html)
|
23
23
|
|
24
|
-
難しい計算をしなくても
|
24
|
+
難しい計算をしなくても便利な組み込み関数があります。
|
25
25
|
[dist() / Reference / Processing.org](https://processing.org/reference/dist_.html)
|
26
26
|
|
27
27
|
楕円でなく円の場合は専用関数があります。
|
@@ -42,7 +42,7 @@
|
|
42
42
|
void draw() {
|
43
43
|
background(255); // つどクリアしないと描画がガビガビになる
|
44
44
|
|
45
|
-
if (dist(mouseX, mouseY, x1, y) < r) { //
|
45
|
+
if (dist(mouseX, mouseY, x1, y) < r) { // 便利な組み込み関数
|
46
46
|
fill(255, 0, 0);
|
47
47
|
} else {
|
48
48
|
fill(255);
|