Skip to content

Commit d92bc41

Browse files
committed
update
1 parent 2b9acb6 commit d92bc41

3 files changed

Lines changed: 94 additions & 1 deletion

File tree

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<div class="note-inner">
7777
<div class="note-title">Note</div>
7878
<div class="note-body">
79-
If you're free at 15:00, lets have lunch together. Meet me at the university. 🇱🇧
79+
If you're free at 15:00, lets have lunch together. Meet me at the university. 🇱🇧 🍽️
8080
</div>
8181
<div class="note-sign">- Alfred</div>
8282
</div>

script.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const modalOk = $("#modalOk");
1616
const valentine = $("#valentine");
1717
const heartsRoot = $("#hearts");
1818
let llCleanup = null;
19+
let heartDone = false;
1920

2021
function sleep(ms) {
2122
return new Promise((r) => setTimeout(r, ms));
@@ -196,13 +197,64 @@ function drawHeartAnimated(canvas, onDone) {
196197
}
197198
ctx.stroke();
198199
ctx.restore();
200+
heartDone = true;
199201
onDone?.();
200202
}
201203
}
202204

203205
requestAnimationFrame(frame);
204206
}
205207

208+
function drawHeartFull(canvas) {
209+
if (!canvas) return;
210+
const ctx = setupCanvasHiDPI(canvas);
211+
const w = canvas.clientWidth || 920;
212+
const h = canvas.clientHeight || 520;
213+
214+
const pts = computeImplicitHeartPoints(1200);
215+
const padding = 34;
216+
let minX = Infinity,
217+
maxX = -Infinity,
218+
minY = Infinity,
219+
maxY = -Infinity;
220+
for (const p of pts) {
221+
if (p.x < minX) minX = p.x;
222+
if (p.x > maxX) maxX = p.x;
223+
if (p.y < minY) minY = p.y;
224+
if (p.y > maxY) maxY = p.y;
225+
}
226+
const spanX = Math.max(1e-6, maxX - minX);
227+
const spanY = Math.max(1e-6, maxY - minY);
228+
const scale = Math.min((w - padding * 2) / spanX, (h - padding * 2) / spanY);
229+
const ox = w / 2 - ((minX + maxX) / 2) * scale;
230+
const oy = h / 2 + ((minY + maxY) / 2) * scale;
231+
232+
const toCanvas = (p) => ({ cx: ox + p.x * scale, cy: oy - p.y * scale });
233+
234+
const gradient = ctx.createLinearGradient(0, 0, w, h);
235+
gradient.addColorStop(0, "#ff4d8d");
236+
gradient.addColorStop(0.6, "#7c5cff");
237+
gradient.addColorStop(1, "#ff7ab0");
238+
239+
drawAxes(ctx, w, h);
240+
ctx.save();
241+
ctx.lineWidth = 4;
242+
ctx.lineCap = "round";
243+
ctx.lineJoin = "round";
244+
ctx.strokeStyle = gradient;
245+
ctx.shadowColor = "rgba(124,92,255,0.30)";
246+
ctx.shadowBlur = 10;
247+
ctx.beginPath();
248+
const pStart = toCanvas(pts[0]);
249+
ctx.moveTo(pStart.cx, pStart.cy);
250+
for (let i = 1; i < pts.length; i++) {
251+
const pi = toCanvas(pts[i]);
252+
ctx.lineTo(pi.cx, pi.cy);
253+
}
254+
ctx.stroke();
255+
ctx.restore();
256+
}
257+
206258
function initLLRunAway() {
207259
// Make LL move across the website (viewport), not just inside the paper.
208260
// We'll keep the original LL button as a placeholder in the layout,
@@ -413,3 +465,13 @@ window.addEventListener("load", () => {
413465
runSequence();
414466
});
415467

468+
// Keep the graph crisp when the viewport changes (mobile rotation, etc.).
469+
let resizeRaf = 0;
470+
window.addEventListener("resize", () => {
471+
if (!heartDone) return;
472+
if (document.body.classList.contains("is-valentine")) return;
473+
if (!graph?.isConnected) return;
474+
cancelAnimationFrame(resizeRaf);
475+
resizeRaf = requestAnimationFrame(() => drawHeartFull(graph));
476+
});
477+

styles.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,8 @@ canvas#graph {
279279
display: block;
280280
border-radius: 12px;
281281
background: linear-gradient(180deg, rgba(12, 16, 48, 0.04), rgba(12, 16, 48, 0.0));
282+
aspect-ratio: 920 / 520;
283+
max-height: 48vh;
282284
}
283285

284286
.graph-caption {
@@ -474,6 +476,9 @@ canvas#graph {
474476
opacity: 0;
475477
transition: transform 700ms cubic-bezier(.2,.85,.2,1), opacity 700ms ease;
476478
pointer-events: auto;
479+
max-height: 86vh;
480+
overflow: auto;
481+
-webkit-overflow-scrolling: touch;
477482
}
478483
.valentine.is-on .note {
479484
transform: translateY(0) scale(1);
@@ -502,4 +507,30 @@ canvas#graph {
502507
text-align: right;
503508
}
504509

510+
/* Mobile layout tweaks */
511+
@media (max-width: 520px) {
512+
.stage { padding-top: 14px; }
513+
.scene { height: 94vh; }
514+
515+
.envelope { top: 26px; }
516+
517+
.paper-face { padding: 18px 16px 16px; }
518+
.paper-title { font-size: 16px; }
519+
.fn-text { font-size: 12px; padding: 8px 10px; }
520+
.graph-wrap { padding: 10px; }
521+
.graph-caption { font-size: 11px; }
522+
523+
.next-btn { right: 14px; bottom: 14px; padding: 10px 12px; }
524+
525+
.paper-back { padding: 26px 18px 18px; }
526+
.back-title { font-size: 22px; }
527+
.big-letters { letter-spacing: 0.08em; }
528+
529+
.choices { flex-direction: column; width: 100%; }
530+
.choice { width: 100%; max-width: 320px; }
531+
532+
.note-inner { padding: 18px 16px 16px; }
533+
.note-body { line-height: 1.22; }
534+
}
535+
505536

0 commit comments

Comments
 (0)