回答編集履歴
2
リンク切れ
test
CHANGED
@@ -1,145 +1,73 @@
|
|
1
1
|
> 何かキーを押して再生や停止をすること
|
2
2
|
|
3
|
-
|
4
|
-
|
5
3
|
一時停止 `player.pause();`
|
6
|
-
|
7
4
|
再開 `player.play();` or `player.loop();`
|
8
|
-
|
9
5
|
を`keyPressed()`で好きなキーに割り当てればいいでしょう。
|
10
|
-
|
11
|
-
|
12
6
|
|
13
7
|
> レコードのようなものを画面に映し出し
|
14
8
|
|
15
|
-
|
16
|
-
|
17
9
|
レコードっぽい画像を表示するのが手っ取り早いでしょう。
|
18
|
-
|
19
10
|
画像の表示・回転は参考ページがたくさんあります。
|
20
11
|
|
21
|
-
[画像を回転するには | 自己啓発。人生について考える](http://mslabo.sakura.ne.jp/WordPress/make/processing%E3%80%80%E9%80%86%E5%BC%95%E3%81%8D%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/%E7%94%BB%E5%83%8F%E3%82%92%E5%9B%9E%E8%BB%A2%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF/)
|
22
|
-
|
23
|
-
の「画像中央を中心に360°回転させる例:」等がちょうどよさそうです。
|
24
|
-
|
25
|
-
|
12
|
+
[画像を回転するには | 自己啓発。人生について考える](https://web.archive.org/web/20230903182856/https://mslabo.sakura.ne.jp/WordPress/make/processing%E3%80%80%E9%80%86%E5%BC%95%E3%81%8D%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/%E7%94%BB%E5%83%8F%E3%82%92%E5%9B%9E%E8%BB%A2%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF/)の「画像中央を中心に360°回転させる例:」等がちょうどよさそうです。
|
26
13
|
|
27
14
|
> mp3ファイルが再生されると回転し、停止すると回転が止まる
|
28
15
|
|
29
|
-
|
30
|
-
|
31
16
|
`player.isPlaying()`で今の再生状態が取れます。
|
32
|
-
|
33
17
|
draw内にあるであろう回転角度の変更部分を、**再生中だけ**増やすようにすればいいでしょう。
|
34
|
-
|
35
|
-
|
36
18
|
|
37
19
|
---
|
38
20
|
|
39
|
-
|
40
|
-
|
41
21
|
追記 参考コード
|
42
|
-
|
43
22
|
ENTERキーでトグル動作 本題でないところ全カット
|
44
23
|
|
45
|
-
|
46
|
-
|
47
24
|
```Processing
|
48
|
-
|
49
25
|
import ddf.minim.*;
|
50
26
|
|
51
|
-
|
52
|
-
|
53
27
|
Minim minim;
|
54
|
-
|
55
28
|
AudioPlayer player;
|
56
|
-
|
57
29
|
PImage img;
|
58
|
-
|
59
30
|
float deg; // 回転角度
|
60
|
-
|
61
31
|
float delta = 33.3 * 360.0 / 60; // 1秒間に回る角度
|
62
32
|
|
63
|
-
|
64
|
-
|
65
33
|
void setup() {
|
66
|
-
|
67
34
|
size(600, 400);
|
68
|
-
|
69
35
|
minim = new Minim(this);
|
70
|
-
|
71
36
|
player = minim.loadFile("おんがく.mp3");
|
72
|
-
|
73
37
|
img = loadImage("れこーど.png");
|
74
|
-
|
75
38
|
}
|
76
39
|
|
77
|
-
|
78
|
-
|
79
40
|
void draw() {
|
80
|
-
|
81
41
|
rotateImage((width - img.width) / 2, (height - img.height) / 2, img, deg);
|
82
42
|
|
43
|
+
if (player.isPlaying()) {
|
44
|
+
deg += delta / frameRate;
|
45
|
+
if (deg > 360) deg -= 360;
|
46
|
+
}
|
47
|
+
}
|
83
48
|
|
49
|
+
void keyPressed() {
|
50
|
+
println("keyPressed");
|
84
51
|
|
52
|
+
if (key == ENTER || key == RETURN) {
|
85
|
-
if (player.isPlaying()) {
|
53
|
+
if (player.isPlaying()) {
|
86
|
-
|
87
|
-
|
54
|
+
player.pause();
|
88
|
-
|
55
|
+
} else {
|
89
|
-
|
56
|
+
player.loop();
|
90
|
-
|
57
|
+
}
|
91
58
|
}
|
92
59
|
|
60
|
+
// 省略
|
93
61
|
}
|
94
62
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
i
|
104
|
-
|
105
|
-
if (player.isPlaying()) {
|
106
|
-
|
107
|
-
player.pause();
|
108
|
-
|
109
|
-
} else {
|
110
|
-
|
111
|
-
player.loop();
|
112
|
-
|
113
|
-
}
|
114
|
-
|
115
|
-
}
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
// 省略
|
120
|
-
|
63
|
+
//http://mslabo.sakura.ne.jp/WordPress/make/processing%E3%80%80%E9%80%86%E5%BC%95%E3%81%8D%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/%E7%94%BB%E5%83%8F%E3%82%92%E5%9B%9E%E8%BB%A2%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF/
|
64
|
+
void rotateImage(int x, int y, PImage img, float deg) {
|
65
|
+
pushMatrix();
|
66
|
+
translate(x + img.width / 2, y + img.height / 2);
|
67
|
+
rotate(radians(deg));
|
68
|
+
imageMode(CENTER);
|
69
|
+
image(img, 0, 0);
|
70
|
+
imageMode(CORNER);
|
71
|
+
popMatrix();
|
121
72
|
}
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
//http://mslabo.sakura.ne.jp/WordPress/make/processing%E3%80%80%E9%80%86%E5%BC%95%E3%81%8D%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/%E7%94%BB%E5%83%8F%E3%82%92%E5%9B%9E%E8%BB%A2%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF/
|
126
|
-
|
127
|
-
void rotateImage(int x, int y, PImage img, float deg) {
|
128
|
-
|
129
|
-
pushMatrix();
|
130
|
-
|
131
|
-
translate(x + img.width / 2, y + img.height / 2);
|
132
|
-
|
133
|
-
rotate(radians(deg));
|
134
|
-
|
135
|
-
imageMode(CENTER);
|
136
|
-
|
137
|
-
image(img, 0, 0);
|
138
|
-
|
139
|
-
imageMode(CORNER);
|
140
|
-
|
141
|
-
popMatrix();
|
142
|
-
|
143
|
-
}
|
144
|
-
|
145
73
|
```
|
1
追記 参考コード
test
CHANGED
@@ -31,3 +31,115 @@
|
|
31
31
|
`player.isPlaying()`で今の再生状態が取れます。
|
32
32
|
|
33
33
|
draw内にあるであろう回転角度の変更部分を、**再生中だけ**増やすようにすればいいでしょう。
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
---
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
追記 参考コード
|
42
|
+
|
43
|
+
ENTERキーでトグル動作 本題でないところ全カット
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
```Processing
|
48
|
+
|
49
|
+
import ddf.minim.*;
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
Minim minim;
|
54
|
+
|
55
|
+
AudioPlayer player;
|
56
|
+
|
57
|
+
PImage img;
|
58
|
+
|
59
|
+
float deg; // 回転角度
|
60
|
+
|
61
|
+
float delta = 33.3 * 360.0 / 60; // 1秒間に回る角度
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
void setup() {
|
66
|
+
|
67
|
+
size(600, 400);
|
68
|
+
|
69
|
+
minim = new Minim(this);
|
70
|
+
|
71
|
+
player = minim.loadFile("おんがく.mp3");
|
72
|
+
|
73
|
+
img = loadImage("れこーど.png");
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
void draw() {
|
80
|
+
|
81
|
+
rotateImage((width - img.width) / 2, (height - img.height) / 2, img, deg);
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
if (player.isPlaying()) {
|
86
|
+
|
87
|
+
deg += delta / frameRate;
|
88
|
+
|
89
|
+
if (deg > 360) deg -= 360;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
void keyPressed() {
|
98
|
+
|
99
|
+
println("keyPressed");
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
if (key == ENTER || key == RETURN) {
|
104
|
+
|
105
|
+
if (player.isPlaying()) {
|
106
|
+
|
107
|
+
player.pause();
|
108
|
+
|
109
|
+
} else {
|
110
|
+
|
111
|
+
player.loop();
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
// 省略
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
//http://mslabo.sakura.ne.jp/WordPress/make/processing%E3%80%80%E9%80%86%E5%BC%95%E3%81%8D%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/%E7%94%BB%E5%83%8F%E3%82%92%E5%9B%9E%E8%BB%A2%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF/
|
126
|
+
|
127
|
+
void rotateImage(int x, int y, PImage img, float deg) {
|
128
|
+
|
129
|
+
pushMatrix();
|
130
|
+
|
131
|
+
translate(x + img.width / 2, y + img.height / 2);
|
132
|
+
|
133
|
+
rotate(radians(deg));
|
134
|
+
|
135
|
+
imageMode(CENTER);
|
136
|
+
|
137
|
+
image(img, 0, 0);
|
138
|
+
|
139
|
+
imageMode(CORNER);
|
140
|
+
|
141
|
+
popMatrix();
|
142
|
+
|
143
|
+
}
|
144
|
+
|
145
|
+
```
|