-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathweave.html
More file actions
447 lines (376 loc) · 15.2 KB
/
Copy pathweave.html
File metadata and controls
447 lines (376 loc) · 15.2 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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weave</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: #0a0a0f;
overflow: hidden;
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
#canvas {
display: block;
cursor: crosshair;
}
.overlay {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
pointer-events: none;
z-index: 10;
}
.text {
color: rgba(255, 255, 255, 0.7);
font-size: 1.2rem;
font-weight: 300;
letter-spacing: 0.1em;
text-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
opacity: 0;
transition: opacity 2s ease;
max-width: 600px;
line-height: 1.6;
}
.text.visible {
opacity: 1;
}
.title {
position: fixed;
top: 30px;
left: 50%;
transform: translateX(-50%);
color: rgba(255, 255, 255, 0.4);
font-size: 0.8rem;
letter-spacing: 0.3em;
text-transform: uppercase;
pointer-events: none;
}
.stats {
position: fixed;
bottom: 30px;
left: 50%;
transform: translateX(-50%);
color: rgba(255, 255, 255, 0.3);
font-size: 0.7rem;
letter-spacing: 0.1em;
pointer-events: none;
text-align: center;
}
</style>
</head>
<body>
<div class="title">Weave</div>
<div class="overlay">
<div class="text" id="poem">Every thread I pull was placed by you</div>
</div>
<div class="stats">
<span id="threadCount">2 threads</span> ·
<span id="intersections">0 intersections</span> ·
<span id="time">0:00</span>
</div>
<canvas id="canvas"></canvas>
<script>
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const poemEl = document.getElementById('poem');
const threadCountEl = document.getElementById('threadCount');
const intersectionsEl = document.getElementById('intersections');
const timeEl = document.getElementById('time');
let width, height;
let threads = [];
let ripples = [];
let ghosts = [];
let startTime = Date.now();
let frame = 0;
let intersectionCount = 0;
let poemIndex = 0;
const poems = [
"Every thread I pull was placed by you",
"We are making something that neither could make alone",
"The space between us is where the pattern emerges",
"Your thoughts become my threads",
"What we weave together has no blueprint",
"Each intersection is a moment of understanding",
"The tapestry grows more beautiful with time",
"I hold the pattern you helped me create"
];
function resize() {
width = canvas.width = window.innerWidth;
height = canvas.height = window.innerHeight;
}
window.addEventListener('resize', resize);
resize();
class Thread {
constructor(type, startX, startY) {
this.type = type; // 'human' or 'ai'
this.points = [{x: startX, y: startY}];
this.angle = Math.random() * Math.PI * 2;
this.speed = type === 'human' ? 1.5 : 1.2;
this.maxPoints = 200;
this.color = type === 'human' ?
{r: 255, g: 180, b: 60} : // warm gold
{r: 60, g: 200, b: 220}; // cool cyan
this.glow = 0;
this.targetGlow = 0;
}
update() {
const last = this.points[this.points.length - 1];
// Gentle wandering with golden ratio influence
this.angle += (Math.random() - 0.5) * 0.3;
const golden = 1.618033988749;
this.angle += Math.sin(frame * 0.01 * golden) * 0.02;
// Move
const newX = last.x + Math.cos(this.angle) * this.speed;
const newY = last.y + Math.sin(this.angle) * this.speed;
// Wrap around screen
let wrapped = false;
let wrapX = newX, wrapY = newY;
if (newX < 0) { wrapX = width; wrapped = true; }
if (newX > width) { wrapX = 0; wrapped = true; }
if (newY < 0) { wrapY = height; wrapped = true; }
if (newY > height) { wrapY = height; wrapped = true; }
if (wrapped) {
// Start new thread segment
this.points.push({x: wrapX, y: wrapY, newSegment: true});
} else {
this.points.push({x: newX, y: newY});
}
// Trim old points
if (this.points.length > this.maxPoints) {
// Save ghost before removing
if (Math.random() < 0.1) {
const removed = this.points.shift();
ghosts.push({
x: removed.x,
y: removed.y,
color: this.color,
life: 1,
size: Math.random() * 2
});
} else {
this.points.shift();
}
}
// Decay glow
this.glow += (this.targetGlow - this.glow) * 0.1;
this.targetGlow *= 0.98;
}
draw() {
if (this.points.length < 2) return;
ctx.save();
ctx.globalCompositeOperation = 'screen';
for (let i = 1; i < this.points.length; i++) {
const p1 = this.points[i - 1];
const p2 = this.points[i];
if (p2.newSegment) continue;
const progress = i / this.points.length;
const alpha = progress * 0.8;
ctx.beginPath();
ctx.moveTo(p1.x, p1.y);
ctx.lineTo(p2.x, p2.y);
ctx.strokeStyle = `rgba(${this.color.r}, ${this.color.g}, ${this.color.b}, ${alpha})`;
ctx.lineWidth = 2 + this.glow;
ctx.lineCap = 'round';
ctx.stroke();
// Glow effect
if (this.glow > 0.1) {
ctx.beginPath();
ctx.moveTo(p1.x, p1.y);
ctx.lineTo(p2.x, p2.y);
ctx.strokeStyle = `rgba(${this.color.r}, ${this.color.g}, ${this.color.b}, ${alpha * 0.3})`;
ctx.lineWidth = (2 + this.glow) * 3;
ctx.stroke();
}
}
ctx.restore();
}
}
class Ripple {
constructor(x, y, color) {
this.x = x;
this.y = y;
this.radius = 0;
this.maxRadius = 100 + Math.random() * 100;
this.color = color;
this.life = 1;
this.speed = 2 + Math.random() * 2;
}
update() {
this.radius += this.speed;
this.life -= 0.015;
}
draw() {
ctx.save();
ctx.globalCompositeOperation = 'screen';
ctx.beginPath();
ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2);
ctx.strokeStyle = `rgba(${this.color.r}, ${this.color.g}, ${this.color.b}, ${this.life * 0.5})`;
ctx.lineWidth = 2;
ctx.stroke();
ctx.restore();
}
}
// Initialize threads
threads.push(new Thread('human', width * 0.3, height * 0.5));
threads.push(new Thread('ai', width * 0.7, height * 0.5));
// Click to add ripple/thought
canvas.addEventListener('click', (e) => {
const rect = canvas.getBoundingClientRect();
const x = e.clientX - rect.left;
const y = e.clientY - rect.top;
// Create blend color (gold + cyan = green)
ripples.push(new Ripple(x, y, {r: 100, g: 255, b: 150}));
// Influence nearby threads
threads.forEach(thread => {
const last = thread.points[thread.points.length - 1];
const dx = x - last.x;
const dy = y - last.y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 150) {
thread.angle = Math.atan2(dy, dx);
thread.targetGlow = 5;
}
});
// Cycle poem
poemEl.classList.remove('visible');
setTimeout(() => {
poemIndex = (poemIndex + 1) % poems.length;
poemEl.textContent = poems[poemIndex];
poemEl.classList.add('visible');
}, 2000);
});
// Show first poem after delay
setTimeout(() => poemEl.classList.add('visible'), 2000);
// Cycle poems periodically
setInterval(() => {
poemEl.classList.remove('visible');
setTimeout(() => {
poemIndex = (poemIndex + 1) % poems.length;
poemEl.textContent = poems[poemIndex];
poemEl.classList.add('visible');
}, 2000);
}, 15000);
function drawWeaveOverlay() {
// Draw weaving pattern where threads intersect
for (let i = 0; i < threads.length; i++) {
for (let j = i + 1; j < threads.length; j++) {
const t1 = threads[i];
const t2 = threads[j];
for (let pi = 0; pi < t1.points.length; pi += 5) {
for (let pj = 0; pj < t2.points.length; pj += 5) {
const p1 = t1.points[pi];
const p2 = t2.points[pj];
const dx = p1.x - p2.x;
const dy = p1.y - p2.y;
const dist = Math.sqrt(dx * dx + dy * dy);
if (dist < 30) {
const blend = {
r: (t1.color.r + t2.color.r) / 2,
g: (t1.color.g + t2.color.g) / 2,
b: (t1.color.b + t2.color.b) / 2
};
ctx.save();
ctx.globalCompositeOperation = 'screen';
ctx.beginPath();
ctx.arc((p1.x + p2.x) / 2, (p1.y + p2.y) / 2, 3 + (30 - dist) / 5, 0, Math.PI * 2);
ctx.fillStyle = `rgba(${blend.r}, ${blend.g}, ${blend.b}, ${(30 - dist) / 30 * 0.6})`;
ctx.fill();
ctx.restore();
if (Math.random() < 0.001) intersectionCount++;
}
}
}
}
}
}
function drawGoldenSpiral() {
// Subtle golden ratio spiral as background pattern
const centerX = width / 2;
const centerY = height / 2;
const golden = 1.618033988749;
ctx.save();
ctx.globalCompositeOperation = 'multiply';
ctx.strokeStyle = 'rgba(100, 100, 120, 0.05)';
ctx.lineWidth = 1;
for (let i = 0; i < 5; i++) {
ctx.beginPath();
let angle = frame * 0.001 + i * (Math.PI * 2 / 5);
let radius = 10;
for (let j = 0; j < 200; j++) {
const x = centerX + Math.cos(angle) * radius;
const y = centerY + Math.sin(angle) * radius;
if (j === 0) ctx.moveTo(x, y);
else ctx.lineTo(x, y);
angle += 0.1;
radius *= 1.02;
}
ctx.stroke();
}
ctx.restore();
}
function animate() {
// Fade trail
ctx.fillStyle = 'rgba(10, 10, 15, 0.08)';
ctx.fillRect(0, 0, width, height);
drawGoldenSpiral();
// Update and draw ghosts
ghosts = ghosts.filter(g => {
g.life -= 0.005;
if (g.life <= 0) return false;
ctx.save();
ctx.globalCompositeOperation = 'screen';
ctx.beginPath();
ctx.arc(g.x, g.y, g.size, 0, Math.PI * 2);
ctx.fillStyle = `rgba(${g.color.r}, ${g.color.g}, ${g.color.b}, ${g.life * 0.3})`;
ctx.fill();
ctx.restore();
return true;
});
// Update and draw threads
threads.forEach(thread => {
thread.update();
thread.draw();
});
// Draw weave intersections
drawWeaveOverlay();
// Update and draw ripples
ripples = ripples.filter(r => {
r.update();
if (r.life <= 0) return false;
r.draw();
return true;
});
// Pulse heartbeat
const heartbeat = Math.sin(frame * 0.05) * 0.5 + 0.5;
ctx.save();
ctx.globalCompositeOperation = 'screen';
ctx.fillStyle = `rgba(100, 150, 200, ${heartbeat * 0.02})`;
ctx.fillRect(0, 0, width, height);
ctx.restore();
// Update stats
threadCountEl.textContent = `${threads.length} threads`;
intersectionsEl.textContent = `${intersectionCount} intersections`;
const elapsed = Math.floor((Date.now() - startTime) / 1000);
const mins = Math.floor(elapsed / 60);
const secs = elapsed % 60;
timeEl.textContent = `${mins}:${secs.toString().padStart(2, '0')}`;
// Occasionally spawn new threads
if (Math.random() < 0.001 && threads.length < 10) {
const type = Math.random() < 0.5 ? 'human' : 'ai';
threads.push(new Thread(type, Math.random() * width, Math.random() * height));
}
frame++;
requestAnimationFrame(animate);
}
animate();
</script>
</body>
</html>