Skip to content

Commit da459db

Browse files
committed
New examples
1 parent 80ea30a commit da459db

File tree

6 files changed

+61
-12
lines changed

6 files changed

+61
-12
lines changed

docs/assets/main-b968f1f9.js renamed to docs/assets/main-54a29f28.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/nested-0a2069c7.js renamed to docs/assets/nested-9b5e3d22.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/radio-774c8d4c.js renamed to docs/assets/radio-2576b48a.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/gif.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<link href="https://muffinman.io/favicon/purple/icon.svg" rel="icon" type="image/svg+xml">
1616
<link href="https://muffinman.io/favicon/purple/icon-180.png" rel="apple-touch-icon">
1717
<link href="https://muffinman.io/favicon/purple/manifest.webmanifest" rel="manifest">
18-
<script type="module" crossorigin src="/pulsar/assets/nested-0a2069c7.js"></script>
19-
<link rel="modulepreload" crossorigin href="/pulsar/assets/radio-774c8d4c.js">
18+
<script type="module" crossorigin src="/pulsar/assets/nested-9b5e3d22.js"></script>
19+
<link rel="modulepreload" crossorigin href="/pulsar/assets/radio-2576b48a.js">
2020
<link rel="stylesheet" href="/pulsar/assets/radio-54805bb6.css">
2121
</head>
2222

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<link href="https://muffinman.io/favicon/purple/icon.svg" rel="icon" type="image/svg+xml">
1616
<link href="https://muffinman.io/favicon/purple/icon-180.png" rel="apple-touch-icon">
1717
<link href="https://muffinman.io/favicon/purple/manifest.webmanifest" rel="manifest">
18-
<script type="module" crossorigin src="/pulsar/assets/main-b968f1f9.js"></script>
19-
<link rel="modulepreload" crossorigin href="/pulsar/assets/radio-774c8d4c.js">
18+
<script type="module" crossorigin src="/pulsar/assets/main-54a29f28.js"></script>
19+
<link rel="modulepreload" crossorigin href="/pulsar/assets/radio-2576b48a.js">
2020
<link rel="stylesheet" href="/pulsar/assets/radio-54805bb6.css">
2121
</head>
2222

src/ts/lib/examples.ts

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ const examples: Example[] = [
55
code: '(cos(x * t / 5) + sin(y * t / 5)) / 2',
66
},
77
{
8+
// Radial waves
89
code: '(cos(sqrt(x * x + y * y) - t) + 1) / 2',
910
grid: 'hex',
1011
},
1112
{
13+
// Floral pattern
1214
code: '(cos(sin(x * y) + t * 0.66) + 1) / 2',
1315
},
1416
{
@@ -18,13 +20,16 @@ const examples: Example[] = [
1820
code: 'sqrt(x*x + y*y) > (cos(x + t) + 1) / 2 * 5 ? noise(x + t, y + t) * 0.3 : 1',
1921
},
2022
{
23+
// 2d waves
2124
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',
2225
},
2326
{
24-
code: 'cos(t * 0.5) * 0.5 + 0.5', // pulse
27+
// Simple pulse
28+
code: 'cos(t * 0.5) * 0.5 + 0.5',
2529
animate: 'opacity',
2630
},
2731
{
32+
// Spinning
2833
code: 'sin(0.5 * x + y * t * 0.8) * sin(t / 4)',
2934
grid: 'triangular',
3035
},
@@ -33,7 +38,7 @@ const examples: Example[] = [
3338
grid: 'hex',
3439
},
3540
{
36-
code: ' sin(t) * sin(x) + cos(t) * cos(y)',
41+
code: 'sin(t) * sin(x) + cos(t) * cos(y)',
3742
grid: 'triangular',
3843
animate: 'opacity',
3944
},
@@ -42,24 +47,28 @@ const examples: Example[] = [
4247
grid: 'hex',
4348
},
4449
{
50+
// Windmill
4551
code: 'sin(3 * atan2(y,x) + t)',
4652
grid: 'hex',
4753
},
4854
{
55+
// Rain
4956
code: '1 - (((x + 3) * (x + 4) + y + t * 0.3 * (1 + x * x % 5) * 3) % 36) / 12',
5057
animate: 'opacity',
5158
},
5259
{
60+
// Diagonal wave
5361
code: '1 / abs((x + y) + (t * 4) % 70 - 35)',
5462
},
5563
{
5664
code: 'abs(sin(t / 3 * x / 2) * exp(1 - sqrt(pow(x / 2, 2) + pow(y / 2, 2))))',
5765
},
5866
{
67+
// Spinning circle
5968
code: '(3 / sqrt(((x * 1.5) - 6 * cos(t * 0.5)) ** 2 + ((y * 1.5) - 6 * sin(t * 0.5)) ** 2)) ** 2.5',
6069
grid: 'hex',
6170
},
62-
/*
71+
/*
6372
https://news.ycombinator.com/item?id=41478068
6473
6574
// This script recognizes 17 regions and paints each region according to
@@ -102,8 +111,48 @@ const examples: Example[] = [
102111
*/
103112
{
104113
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))',
105154
}
106-
];
155+
]
107156

108157
export function getRandomExample(): Example {
109158
return {

0 commit comments

Comments
 (0)