Skip to content

Commit 70c4152

Browse files
bennettfarkasclaude
andcommitted
Add stream exploration duplicates at /1, /2, /3
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8c56f0c commit 70c4152

3 files changed

Lines changed: 786 additions & 0 deletions

File tree

1/index.html

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Stream — Ripple</title>
7+
<style>
8+
* { margin: 0; padding: 0; box-sizing: border-box; }
9+
html, body { width: 100%; height: 100%; overflow: hidden; background: #ffffff; }
10+
canvas { display: block; width: 100vw; height: 100vh; }
11+
</style>
12+
</head>
13+
<body>
14+
<canvas id="c"></canvas>
15+
<script>
16+
(() => {
17+
const canvas = document.getElementById('c');
18+
const gl = canvas.getContext('webgl', { antialias: true, alpha: false });
19+
if (!gl) { document.body.textContent = 'WebGL not supported'; return; }
20+
21+
function resize() {
22+
const dpr = window.devicePixelRatio || 1;
23+
canvas.width = window.innerWidth * dpr;
24+
canvas.height = window.innerHeight * dpr;
25+
canvas.style.width = window.innerWidth + 'px';
26+
canvas.style.height = window.innerHeight + 'px';
27+
gl.viewport(0, 0, canvas.width, canvas.height);
28+
}
29+
window.addEventListener('resize', resize);
30+
resize();
31+
32+
const vsSource = `
33+
attribute vec2 aPos;
34+
varying vec2 vUV;
35+
void main() {
36+
vUV = aPos * 0.5 + 0.5;
37+
gl_Position = vec4(aPos, 0.0, 1.0);
38+
}
39+
`;
40+
41+
const fsSource = `
42+
precision highp float;
43+
varying vec2 vUV;
44+
uniform float uTime;
45+
uniform vec2 uResolution;
46+
uniform vec2 uMouse;
47+
48+
// Ashima Arts simplex 2D noise
49+
vec3 mod289(vec3 x){ return x - floor(x*(1.0/289.0))*289.0; }
50+
vec2 mod289(vec2 x){ return x - floor(x*(1.0/289.0))*289.0; }
51+
vec3 permute(vec3 x){ return mod289(((x*34.0)+10.0)*x); }
52+
float snoise(vec2 v){
53+
const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439);
54+
vec2 i = floor(v + dot(v, C.yy));
55+
vec2 x0 = v - i + dot(i, C.xx);
56+
vec2 i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
57+
vec4 x12 = x0.xyxy + C.xxzz; x12.xy -= i1;
58+
i = mod289(i);
59+
vec3 p = permute(permute(i.y + vec3(0.0, i1.y, 1.0)) + i.x + vec3(0.0, i1.x, 1.0));
60+
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
61+
m = m*m; m = m*m;
62+
vec3 x = 2.0*fract(p*C.www) - 1.0;
63+
vec3 h = abs(x) - 0.5;
64+
vec3 ox = floor(x + 0.5);
65+
vec3 a0 = x - ox;
66+
m *= 1.79284291400159 - 0.85373472095314*(a0*a0+h*h);
67+
vec3 g; g.x = a0.x*x0.x + h.x*x0.y; g.yz = a0.yz*x12.xz + h.yz*x12.yw;
68+
return 130.0 * dot(m, g);
69+
}
70+
71+
// Cubic bezier for center line
72+
float bezier1D(float t, float p0, float p1, float p2, float p3) {
73+
float u = 1.0 - t;
74+
return u*u*u*p0 + 3.0*u*u*t*p1 + 3.0*u*t*t*p2 + t*t*t*p3;
75+
}
76+
77+
// S-curve center y as function of x(t)
78+
// Control points: start upper-left (y=0.25), dip (y=0.72), rise (y=0.22), end upper-right (y=0.32)
79+
float getCenterY(float x) {
80+
// Invert x->t approximately by iteration (x is monotonic along curve)
81+
// Control points in x: -0.05, 0.30, 0.70, 1.05
82+
float t = x; // initial guess (close since x control points span ~0..1)
83+
for (int i = 0; i < 6; i++) {
84+
float ex = bezier1D(t, -0.05, 0.30, 0.70, 1.05);
85+
float dex = 3.0*(1.0-t)*(1.0-t)*(0.30-(-0.05)) + 6.0*(1.0-t)*t*(0.70-0.30) + 3.0*t*t*(1.05-0.70);
86+
t = t - (ex - x) / max(dex, 0.001);
87+
t = clamp(t, 0.0, 1.0);
88+
}
89+
return bezier1D(t, 0.25, 0.72, 0.22, 0.32);
90+
}
91+
92+
// Stream half-width as function of x
93+
float getHalfWidth(float x) {
94+
// Wider on left, narrow in center (~x=0.45), medium on right
95+
float center = 0.45;
96+
float squeeze = 1.0 - 0.55 * exp(-((x - center)*(x - center)) / 0.035);
97+
float taper = 1.0 - 0.25 * x;
98+
return 0.10 * squeeze * taper;
99+
}
100+
101+
// Warm palette: top=red-orange, mid=gold, bottom=magenta
102+
vec3 warmColor(float v) {
103+
vec3 top = vec3(0.92, 0.25, 0.10);
104+
vec3 mid = vec3(0.96, 0.67, 0.12);
105+
vec3 bottom = vec3(0.80, 0.16, 0.48);
106+
if (v < 0.5) return mix(top, mid, v * 2.0);
107+
return mix(mid, bottom, (v - 0.5) * 2.0);
108+
}
109+
110+
// Cool palette: top=lime, mid=green, bottom=teal (blue on top visually)
111+
vec3 coolColor(float v) {
112+
vec3 top = vec3(0.55, 0.78, 0.16);
113+
vec3 mid = vec3(0.06, 0.60, 0.40);
114+
vec3 bottom = vec3(0.0, 0.63, 0.63);
115+
if (v < 0.5) return mix(top, mid, v * 2.0);
116+
return mix(mid, bottom, (v - 0.5) * 2.0);
117+
}
118+
119+
void main() {
120+
vec2 uv = vUV;
121+
float aspect = uResolution.x / uResolution.y;
122+
123+
float x = uv.x;
124+
float y = uv.y;
125+
126+
// Noise-modulated center line — subtle life
127+
float noiseScale = 1.8;
128+
float centerNoise = snoise(vec2(x * noiseScale + 0.3, uTime * 0.10)) * 0.028
129+
+ snoise(vec2(x * noiseScale * 2.5 + 5.0, uTime * 0.14 + 3.0)) * 0.014
130+
+ snoise(vec2(x * 5.0 - uTime * 0.18, 12.0)) * 0.005;
131+
// Magnetic attraction — stream bends toward cursor
132+
float mdx = x - uMouse.x;
133+
float attract = 0.04 * exp(-(mdx * mdx) / 0.03);
134+
float bendY = (uMouse.y - getCenterY(x)) * attract;
135+
// Ripple — subtle turbulence near cursor
136+
float mDistSq = (x - uMouse.x) * (x - uMouse.x) + (y - uMouse.y) * (y - uMouse.y);
137+
float ripple = 0.010 * exp(-mDistSq / 0.020) * snoise(vec2(x * 10.0 - uTime * 0.4, y * 10.0));
138+
// Ambient ripple — subtle turbulence everywhere
139+
float ambientRipple = snoise(vec2(x * 8.0 - uTime * 0.3, y * 6.0 + uTime * 0.15)) * 0.005
140+
+ snoise(vec2(x * 12.0 + uTime * 0.2, y * 10.0 - uTime * 0.1)) * 0.003;
141+
float centerY = getCenterY(x) + centerNoise + bendY + ripple + ambientRipple;
142+
143+
// Half width with gentle breathing
144+
float hw = getHalfWidth(x);
145+
float widthNoise = snoise(vec2(x * 3.0 + 10.0, uTime * 0.12 + 7.0)) * 0.010
146+
+ snoise(vec2(x * 6.0 - uTime * 0.08, 20.0)) * 0.004;
147+
hw += widthNoise;
148+
hw = max(hw, 0.01);
149+
150+
// Signed distance from center (in y), normalized by half-width
151+
float dist = (y - centerY) / hw;
152+
153+
// Gaussian falloff for soft edges
154+
float sigma = 0.7;
155+
float gauss = exp(-(dist * dist) / (2.0 * sigma * sigma));
156+
157+
// Extra softness at edges - wider gaussian for the outermost part
158+
float outerSigma = 1.0;
159+
float outerGauss = exp(-(dist * dist) / (2.0 * outerSigma * outerSigma));
160+
161+
// Blend: use tighter gaussian for color intensity, outer for alpha presence
162+
float alpha = mix(outerGauss, gauss, 0.5);
163+
164+
// Add subtle noise to alpha for organic feel
165+
float alphaNoise = snoise(vec2(x * 5.0 + uTime * 0.05, y * 5.0 * aspect + uTime * 0.03)) * 0.08;
166+
alpha = clamp(alpha + alphaNoise * alpha, 0.0, 1.0);
167+
168+
alpha = pow(alpha, 0.55);
169+
alpha *= smoothstep(0.0, 0.03, alpha);
170+
171+
// Vertical position within stream: 0=top, 1=bottom
172+
float vPos = clamp(dist * 0.5 + 0.5, 0.0, 1.0);
173+
174+
// Add noise to vertical position for more organic color variation
175+
float vNoise = snoise(vec2(x * 3.0 + uTime * 0.07 + 20.0, y * 4.0 * aspect - uTime * 0.04)) * 0.13;
176+
vPos = clamp(vPos + vNoise, 0.0, 1.0);
177+
178+
// Color: blend warm and cool based on x
179+
vec3 warm = warmColor(vPos);
180+
vec3 cool = coolColor(vPos);
181+
182+
// Smooth transition from warm to cool
183+
float warmCoolMix = smoothstep(0.38, 0.55, x);
184+
// Add subtle noise to transition boundary
185+
float transNoise = snoise(vec2(x * 2.0 + 50.0, y * 3.0 * aspect + uTime * 0.05)) * 0.08;
186+
warmCoolMix = clamp(warmCoolMix + transNoise, 0.0, 1.0);
187+
188+
vec3 color = mix(warm, cool, warmCoolMix);
189+
190+
// No center darkening — keep colors clean
191+
192+
// Boost saturation slightly
193+
float lum = dot(color, vec3(0.299, 0.587, 0.114));
194+
color = mix(vec3(lum), color, 1.15);
195+
196+
// Composite over white
197+
vec3 white = vec3(1.0);
198+
vec3 final = mix(white, color, alpha * 0.96);
199+
200+
gl_FragColor = vec4(final, 1.0);
201+
}
202+
`;
203+
204+
function createShader(type, source) {
205+
const s = gl.createShader(type);
206+
gl.shaderSource(s, source);
207+
gl.compileShader(s);
208+
if (!gl.getShaderParameter(s, gl.COMPILE_STATUS)) {
209+
console.error(gl.getShaderInfoLog(s));
210+
gl.deleteShader(s);
211+
return null;
212+
}
213+
return s;
214+
}
215+
216+
const vs = createShader(gl.VERTEX_SHADER, vsSource);
217+
const fs = createShader(gl.FRAGMENT_SHADER, fsSource);
218+
const prog = gl.createProgram();
219+
gl.attachShader(prog, vs);
220+
gl.attachShader(prog, fs);
221+
gl.linkProgram(prog);
222+
if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) {
223+
console.error(gl.getProgramInfoLog(prog));
224+
return;
225+
}
226+
gl.useProgram(prog);
227+
228+
const aPos = gl.getAttribLocation(prog, 'aPos');
229+
const uTime = gl.getUniformLocation(prog, 'uTime');
230+
const uRes = gl.getUniformLocation(prog, 'uResolution');
231+
const uMouse = gl.getUniformLocation(prog, 'uMouse');
232+
233+
const buf = gl.createBuffer();
234+
gl.bindBuffer(gl.ARRAY_BUFFER, buf);
235+
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([-1,-1, 1,-1, -1,1, 1,1]), gl.STATIC_DRAW);
236+
gl.enableVertexAttribArray(aPos);
237+
gl.vertexAttribPointer(aPos, 2, gl.FLOAT, false, 0, 0);
238+
239+
let mx = 0.5, my = 0.5, smx = 0.5, smy = 0.5;
240+
document.addEventListener('mousemove', function(e) {
241+
mx = e.clientX / window.innerWidth;
242+
my = 1.0 - e.clientY / window.innerHeight;
243+
});
244+
245+
let startTime = performance.now();
246+
247+
function draw() {
248+
const t = (performance.now() - startTime) / 1000.0;
249+
smx += (mx - smx) * 0.08;
250+
smy += (my - smy) * 0.08;
251+
gl.uniform1f(uTime, t);
252+
gl.uniform2f(uRes, canvas.width, canvas.height);
253+
gl.uniform2f(uMouse, smx, smy);
254+
gl.drawArrays(gl.TRIANGLE_STRIP, 0, 4);
255+
requestAnimationFrame(draw);
256+
}
257+
258+
draw();
259+
})();
260+
</script>
261+
</body>
262+
</html>

0 commit comments

Comments
 (0)