@@ -5,10 +5,12 @@ const examples: Example[] = [
5
5
code : '(cos(x * t / 5) + sin(y * t / 5)) / 2' ,
6
6
} ,
7
7
{
8
+ // Radial waves
8
9
code : '(cos(sqrt(x * x + y * y) - t) + 1) / 2' ,
9
10
grid : 'hex' ,
10
11
} ,
11
12
{
13
+ // Floral pattern
12
14
code : '(cos(sin(x * y) + t * 0.66) + 1) / 2' ,
13
15
} ,
14
16
{
@@ -18,13 +20,16 @@ const examples: Example[] = [
18
20
code : 'sqrt(x*x + y*y) > (cos(x + t) + 1) / 2 * 5 ? noise(x + t, y + t) * 0.3 : 1' ,
19
21
} ,
20
22
{
23
+ // 2d waves
21
24
code : 'cos(x + t) > y * 0.3 + 0.5 ? (cos(x + t) + 1) / 4 + 0.5 : 0' , // 'cos(x + t) > y * 0.3 + 0.5 ? 0.8 : 0',
22
25
} ,
23
26
{
24
- code : 'cos(t * 0.5) * 0.5 + 0.5' , // pulse
27
+ // Simple pulse
28
+ code : 'cos(t * 0.5) * 0.5 + 0.5' ,
25
29
animate : 'opacity' ,
26
30
} ,
27
31
{
32
+ // Spinning
28
33
code : 'sin(0.5 * x + y * t * 0.8) * sin(t / 4)' ,
29
34
grid : 'triangular' ,
30
35
} ,
@@ -33,7 +38,7 @@ const examples: Example[] = [
33
38
grid : 'hex' ,
34
39
} ,
35
40
{
36
- code : ' sin(t) * sin(x) + cos(t) * cos(y)' ,
41
+ code : 'sin(t) * sin(x) + cos(t) * cos(y)' ,
37
42
grid : 'triangular' ,
38
43
animate : 'opacity' ,
39
44
} ,
@@ -42,24 +47,28 @@ const examples: Example[] = [
42
47
grid : 'hex' ,
43
48
} ,
44
49
{
50
+ // Windmill
45
51
code : 'sin(3 * atan2(y,x) + t)' ,
46
52
grid : 'hex' ,
47
53
} ,
48
54
{
55
+ // Rain
49
56
code : '1 - (((x + 3) * (x + 4) + y + t * 0.3 * (1 + x * x % 5) * 3) % 36) / 12' ,
50
57
animate : 'opacity' ,
51
58
} ,
52
59
{
60
+ // Diagonal wave
53
61
code : '1 / abs((x + y) + (t * 4) % 70 - 35)' ,
54
62
} ,
55
63
{
56
64
code : 'abs(sin(t / 3 * x / 2) * exp(1 - sqrt(pow(x / 2, 2) + pow(y / 2, 2))))' ,
57
65
} ,
58
66
{
67
+ // Spinning circle
59
68
code : '(3 / sqrt(((x * 1.5) - 6 * cos(t * 0.5)) ** 2 + ((y * 1.5) - 6 * sin(t * 0.5)) ** 2)) ** 2.5' ,
60
69
grid : 'hex' ,
61
70
} ,
62
- /*
71
+ /*
63
72
https://news.ycombinator.com/item?id=41478068
64
73
65
74
// This script recognizes 17 regions and paints each region according to
@@ -102,8 +111,48 @@ const examples: Example[] = [
102
111
*/
103
112
{
104
113
code : '(abs(x)<5)*(1-t%1)**.3*((c,d)=>c&1&~(c+1?268656721+(d<5)*180268851>>d%5*6+c/2:d==2))((y>4)-5*(x>2)+(y>0)-(y<0)+5*(x<-2)-(y<-4)+5,t%10|0)'
114
+ } ,
115
+ {
116
+ // Spiral wave
117
+ // // Calculate the distance from the center
118
+ // const distance = Math.sqrt(x * x + y * y);
119
+
120
+ // // Calculate the angle (in radians) of the point from the center
121
+ // const angle = Math.atan2(y, x);
122
+
123
+ // // Parameters to adjust the spiral effect
124
+ // const spiralTightness = 0.5;
125
+ // const waveFrequency = 2;
126
+ // const contractionSpeed = 0.1;
127
+
128
+ // // Create a smoother spiral effect
129
+ // const spiral = distance + angle * spiralTightness;
130
+
131
+ // // Use sine to create a wave effect, and make it contract over time
132
+ // const wave = Math.sin(spiral * waveFrequency - t * contractionSpeed);
133
+
134
+ // // Apply a smooth falloff based on distance from center
135
+ // const falloff = 1 / (1 + distance * 0.2);
136
+
137
+ // // Combine wave and falloff, then normalize to 0-1 range
138
+ // return (wave * falloff + 1) / 2;
139
+ code : '(sin(sqrt(x * x + y * y) + atan2(y, x) * 1 - t) * 1 / (1 + sqrt(x * x + y * y) * 0.2) + 1) / 2'
140
+ } ,
141
+ {
142
+ // Checkered pulse
143
+ code : '(sqrt(x*x + y*y) < 6) ? (i % 2 ? 1:-1) * (sin(t * 0.6)) : 0' ,
144
+ grid : 'triangular' ,
145
+ } ,
146
+ // Diamond waves
147
+ {
148
+ code : '(sin(abs(x) + abs(y) - t * 0.6) + 1) / 2' ,
149
+ grid : 'hex' ,
150
+ } ,
151
+ {
152
+ // Christmas tree
153
+ code : 'ceil(((abs(t * 0.7)^2)*7) % 120) === i ? 0 : ((abs(y-6) - abs(x*2.3)) * (cos(t * 0.2) * 0.3 + 0.5))' ,
105
154
}
106
- ] ;
155
+ ]
107
156
108
157
export function getRandomExample ( ) : Example {
109
158
return {
0 commit comments