-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
288 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// 条件式の練習(市松模様) | ||
|
||
void setup() { | ||
size(600, 600); | ||
background(200, 200, 200); | ||
noStroke(); | ||
} | ||
|
||
void mouseMoved() { | ||
// もし | ||
// mouseX が 300 未満かつ mouseY が 300 未満(キャンバス左上) | ||
// または | ||
// mouseX が 300 より大きいかつ mouseY が 300 より大きい(キャンバス右下) | ||
// とき | ||
if (mouseX < 300 && mouseY < 300 | ||
|| mouseX > 300 && mouseY > 300) { | ||
// 塗りを黒色に | ||
fill(0, 0, 0); | ||
} | ||
else { | ||
// それ以外は白色 | ||
fill(255, 255, 255); | ||
} | ||
|
||
ellipse(mouseX, mouseY, 100, 100); | ||
} | ||
|
||
void draw() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// 条件式の練習(十字) | ||
|
||
void setup() { | ||
size(600, 600); | ||
background(200, 200, 200); | ||
noStroke(); | ||
} | ||
|
||
void mouseMoved() { | ||
// もし | ||
// mouseX が 100 より大きいかつ 200 未満 | ||
// または | ||
// mouseX が 300 より大きいかつ 400 未満 | ||
// または | ||
// mouseX が 500 より大きいかつ 600 未満 | ||
// のとき | ||
if (mouseX > 200 && mouseX < 400 | ||
|| mouseY > 200 && mouseY < 400) { | ||
// 塗りを黒色に | ||
fill(0, 0, 0); | ||
} | ||
else { | ||
// それ以外は白色 | ||
fill(255, 255, 255); | ||
} | ||
|
||
ellipse(mouseX, mouseY, 100, 100); | ||
} | ||
|
||
void draw() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 条件式の練習(ジャンガリアンハムスターの背中の筋) | ||
|
||
void setup() { | ||
size(600, 600); | ||
background(200, 200, 200); | ||
noStroke(); | ||
} | ||
|
||
void mouseMoved() { | ||
// もし | ||
// mouseX が 200 より大きいかつ 400 未満 | ||
// のとき | ||
if (mouseX > 200 && mouseX < 400) { | ||
// 塗りを黒色に | ||
fill(0, 0, 0); | ||
} | ||
else { | ||
// それ以外は白色 | ||
fill(255, 255, 255); | ||
} | ||
|
||
ellipse(mouseX, mouseY, 100, 100); | ||
} | ||
|
||
void draw() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 条件式の練習(ハーフ&ハーフ) | ||
|
||
void setup() { | ||
size(600, 600); | ||
background(200, 200, 200); | ||
noStroke(); | ||
} | ||
|
||
void mouseMoved() { | ||
// もし | ||
// mouseX が 300 未満 | ||
// のとき | ||
if (mouseX < 300) { | ||
// 塗りを黒色に | ||
fill(0, 0, 0); | ||
} | ||
else { | ||
// それ以外は白色 | ||
fill(255, 255, 255); | ||
} | ||
|
||
ellipse(mouseX, mouseY, 100, 100); | ||
} | ||
|
||
void draw() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// 条件式の練習(斜め) | ||
|
||
void setup() { | ||
size(600, 600); | ||
background(200, 200, 200); | ||
noStroke(); | ||
} | ||
|
||
void mouseMoved() { | ||
// もし | ||
// mouseX + mouseY が 600 未満 | ||
// のとき | ||
if (mouseX + mouseY < 600) { | ||
// 塗りを黒色に | ||
fill(0, 0, 0); | ||
} | ||
else { | ||
// それ以外は白色 | ||
fill(255, 255, 255); | ||
} | ||
|
||
ellipse(mouseX, mouseY, 100, 100); | ||
} | ||
|
||
void draw() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// 条件式の練習(梅干し弁当) | ||
|
||
void setup() { | ||
size(600, 600); | ||
background(200, 200, 200); | ||
noStroke(); | ||
} | ||
|
||
void mouseMoved() { | ||
// もし | ||
// mouseX が 200 より大きい | ||
// かつ | ||
// mouseX が 400 未満 | ||
// かつ | ||
// mouseY が 200 より大きい | ||
// かつ | ||
// mouseY が 400 未満 | ||
// のとき | ||
if (mouseX > 200 | ||
&& mouseX < 400 | ||
&& mouseY > 200 | ||
&& mouseY < 400) { | ||
// 塗りを黒色に | ||
fill(0, 0, 0); | ||
} | ||
else { | ||
// それ以外は白色 | ||
fill(255, 255, 255); | ||
} | ||
|
||
ellipse(mouseX, mouseY, 100, 100); | ||
} | ||
|
||
void draw() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// 条件式の練習(シマウマ模様) | ||
|
||
void setup() { | ||
size(600, 600); | ||
background(200, 200, 200); | ||
noStroke(); | ||
} | ||
|
||
void mouseMoved() { | ||
// もし | ||
// mouseX が 100 より大きいかつ 200 未満 | ||
// または | ||
// mouseX が 300 より大きいかつ 400 未満 | ||
// または | ||
// mouseX が 500 より大きいかつ 600 未満 | ||
// のとき | ||
if (mouseX > 100 && mouseX < 200 | ||
|| mouseX > 300 && mouseX < 400 | ||
|| mouseX > 500 && mouseX < 600) { | ||
// 塗りを黒色に | ||
fill(0, 0, 0); | ||
} | ||
else { | ||
// それ以外は白色 | ||
fill(255, 255, 255); | ||
} | ||
|
||
ellipse(mouseX, mouseY, 100, 100); | ||
} | ||
|
||
void draw() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// 2色ペン(右ボタンで別の色) | ||
|
||
void setup() { | ||
size(600, 600); | ||
background(255, 255, 255); | ||
|
||
strokeWeight(3); | ||
} | ||
|
||
void mouseDragged() { | ||
// もし押されたボタンが左なら | ||
if (mouseButton == LEFT) { | ||
// 線の色を黒色に | ||
stroke(0, 0, 0); | ||
} | ||
// もしそれ以外で、押されたボタンが右なら | ||
else if (mouseButton == RIGHT) { | ||
// 線の色を赤色に | ||
stroke(255, 0, 0); | ||
} | ||
|
||
// 線を引く | ||
line(pmouseX, pmouseY, mouseX, mouseY); | ||
} | ||
|
||
void draw() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
void setup() { | ||
size(600, 600); | ||
background(200, 200, 200); | ||
} | ||
|
||
void mouseDragged() { | ||
// 現在のミリ秒が2で割り切れるとき | ||
if (millis() % 2 == 0) { | ||
// 塗りを赤色に | ||
fill(255, 0, 0); | ||
} | ||
// そうでないとき | ||
else { | ||
// 塗りを白色に | ||
fill(255, 255, 255); | ||
} | ||
|
||
ellipse(mouseX, mouseY, 100, 100); | ||
} | ||
|
||
void draw() { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// 秒数によって色が変わるペン | ||
|
||
void setup() { | ||
size(600, 600); | ||
background(255, 255, 255); | ||
|
||
noStroke(); | ||
} | ||
|
||
void mouseDragged() { | ||
// もし秒数を3で割った余りが0なら | ||
// 例:0, 3, 6, 9, ... | ||
if (second() % 3 == 0) { | ||
// 塗りを黒色に | ||
fill(0, 0, 0); | ||
} | ||
// もしそれ以外で、秒数を3で割った余りが1なら | ||
// 例:1, 4, 7, 10, ... | ||
else if (second() % 3 == 1) { | ||
// 塗りを赤色に | ||
fill(255, 0, 0); | ||
} | ||
// もしそれ以外なら | ||
else { | ||
// 塗りを青色に | ||
fill(0, 0, 255); | ||
} | ||
|
||
// 円を描く | ||
ellipse(mouseX, mouseY, 20, 20); | ||
} | ||
|
||
void draw() { | ||
} |