-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction.js
More file actions
226 lines (188 loc) · 5.04 KB
/
function.js
File metadata and controls
226 lines (188 loc) · 5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
function defBack(num){
if(num % 2 == 0)background(255);
else background(155,155,0);
}
function mouseCircle(){
for (var y = 0; y <= windowHeight; y += 20) {
for (var x = 0; x <= windowWidth; x += 20) {
// 対象のセルとカーソル位置との距離を計算する
var d = dist(x, y, mouseX, mouseY);
var sz = d * 0.03;
ellipse(x, y, sz, sz);
}
}
}
function splashBrush(){
for(var i=0; i<25; i++){
var size = random(0,50);
fill(0, 0, 0, random(100));
noStroke();
ellipse(
mouseX + random(-45,45),
mouseY + random(-45,45),
size,size
);
}
}
function circle1(){
while (n < 20){
circle(mouseX, mouseY, n*10, n*10);
n++;
}
}
function rot(){
angle += 0.05;
var cx = windowWidth /2;
var cy = windowHeight / 2;
fill(0,0,0,200);
line(cx, cy, cx+ 150*cos(angle), cy+150*sin(angle));
ellipse(cx + 150*cos(angle), cy + 150*sin(angle), 20,20);
ellipse(cx + 50*cos(angle), cy + 50*sin(angle), 20,20);
}
function rot2(){
angle2 += 0.05;
var cx = windowWidth * 2 /3;
var cy = windowHeight * 2 / 3;
fill(0,0,0,200);
line(cx, cy, cx+ 0*cos(angle), cy+150*sin(angle));
ellipse(cx + 0*cos(angle2), cy + 150*sin(angle2), 20,20);
}
function Lissajous(){
var cx = windowWidth /4;
var cy = windowHeight*2 / 4;
var a = 7;
var b = 2;
fill(0,0,0,200);
ellipse(cx + 200*cos(angle + a), cy + 150*sin(angle + b), 2,2);
}
function funcsin(){
fill(0);
for(var x = 0; x < windowWidth; x++){
var y = windowHeight /2 + sin(x*0.01) * mouseY;
ellipse(x, y, 2,2);
}
}
function chaseFace(){
fill(255);
ellipse(width*2/5,height/2,100,100);
ellipse(width*3/5,height/2,100,100);
fill(0);
ox1 = width*2/5;
ox2 = width* 3/5;
oy= height/2;
var angleface = atan2(mouseY - height/2, mouseX - width*2/5);
ellipse(ox1 + cos(angleface) * 20, oy + sin(angleface) * 20, 50,50);
var angleface2 = atan2(mouseY - oy, mouseX - ox2);
ellipse(ox2 + cos(angleface2) * 20, oy + sin(angleface2) * 20, 50,50);
fill(255);
ellipse(ox1 + cos(angleface) * 20 + 10, oy + sin(angleface) * 20 -7 , 7,7);
ellipse(ox2 + cos(angleface2) * 20 + 10, oy + sin(angleface2) * 20-7, 7,7);
}
function changeColor(){
fill(random(255),random(255),random(255),random(255));
}
function makeshape(x,y,width,height){
var num = random(100);
noStroke();
fill(255);
rect(x,y,width,height);
randomColor(changeFlg);
if(num < 30) ellipse(x+width/2,y+height/2,width,height);
else rect(x,y,width,height)
}
function randomBack(){
background(floor(random(256)),floor(random(256)),floor(random(256)));
}
function randomColor(flg){
if(flg){
color = [floor(random(256)),floor(random(256)),floor(random(256))];
changeFlg=false;}
fill(color[0],color[1],color[2]);
}
function moveCircle(basex,basey){//点状の円が収縮する
for(var p=0; p<100; p++){
theta = p/100*2*PI;
/*size = sqrt(x**2 + y**2);
corx= x / size;
cory= y / size;
console.log(cos(corx),sin(cory));*/
r = sin(frameCount/20)*100;
fill(color[0],color[1],color[2]);
ellipse(basex + r*cos(theta), basey + r*sin(theta),4,4);
}
fill(0);
textSize(29);
text('want you change color??', 50, 50);
}
function spreadCircle(){//飛び散る波形
//start
if(onemoveFlg){
loc=[mouseX,mouseY,frameCount];
onemoveFlg=false;
}
for(var p=0; p<100; p++){
theta = p/100*2*PI;
r = (frameCount-loc[2])*40;
fill(color[0],color[1],color[2]);
ellipse(loc[0] + r*cos(theta), loc[1] + r*sin(theta),4,4);
}
//end
if(frameCount-loc[2] >= 60){
spreadFlg=false;
}
}
function designSquare(x,y,r){
}
function scaleSquare(x,y,r,flg){//(x,y,辺の長さ, 0;縮小, 1:拡大)
if(r>60 || r<0){
if(flg==0)r=0;
else r=60;
flg = (flg+1)%2;
} else if(flg==1){
x-=0.5;
y-=0.5;
r+=1;
} else if(flg==0){
x+=0.5;
y+=0.5;
r-=1;
}
return [x,y,r,flg];
}
function rotateSq(){
noStroke();
fill(31,127,255);
//中心原点四角形作成
rectMode(CENTER);
// rotation
rotateX(frameCount/20);
rotateY(frameCount/15);
rotateZ(frameCount/30);
rect(0, 0, width/3, height/3);
}
function rotateTwo(){
push();
{
rotateY(frameCount/60);
//make circle
push();
translate(-width/6, 0, 0);
rotateY(frameCount/30);
sphere(height/5);
pop();
//make cube
push();
translate(width/6,0,0);
rotateY(frameCount/30);
box(height/4);
pop();
}
pop();
}
function changeColor2(){
var num = floor(random(3));
if(num==0)color[0]= (color[0]+51)%255;
else if(num==1)color[1]= (color[1]+51)%255;
else if(num==2)color[2]= (color[2]+51)%255;
else color=[255,255,255];
}