From b524ae91d32608676849e15cdfd22c56fea289be Mon Sep 17 00:00:00 2001 From: BlackAngelTV Date: Fri, 2 Oct 2026 17:47:10 +0200 Subject: [PATCH] feat(pages): add an animated Tux 404 page The previous 404 reused hero styles that only load on the home page, so it rendered almost unstyled. Give it a self-contained scene instead: Tux unplugs an RJ45 cable from a switch, then drops it on the floor where it settles. --- p/404.php | 194 ++++++++++++++++++++++- p/assets/js/not-found.js | 323 +++++++++++++++++++++++++++++++++++++++ p/assets/styles/404.css | 110 +++++++++++++ 3 files changed, 621 insertions(+), 6 deletions(-) create mode 100644 p/assets/js/not-found.js create mode 100644 p/assets/styles/404.css diff --git a/p/404.php b/p/404.php index a02c94f..3e5440e 100644 --- a/p/404.php +++ b/p/404.php @@ -1,6 +1,11 @@ -
-

Page introuvable

-

Cette page n'existe pas ou a été déplacée.

-
- Retour à l'accueil +
+
+ +

Cette page a été débranchée

+

Tux a tiré un peu fort sur le câble RJ45… La page demandée n'existe pas ou a été déplacée. Le reste du réseau tient bon.

+ +
+ +
diff --git a/p/assets/js/not-found.js b/p/assets/js/not-found.js new file mode 100644 index 0000000..bd269d7 --- /dev/null +++ b/p/assets/js/not-found.js @@ -0,0 +1,323 @@ +/** + * FWS Linux — animation de la page 404. + * + * Une seule fois, puis on s'arrête sur l'image finale : Tux s'approche, + * attrape le câble RJ45, le débranche (la LED passe au rouge, une pastille + * « link down » apparaît), puis lâche le câble qui tombe au sol et s'immobilise. + * + * Le connecteur suit sa cible via un ressort sous-amorti et, à partir du + * lâcher, les deux extrémités du câble deviennent des points libres soumis à + * la gravité (avec rebond et frottement). Le tracé du câble est recalculé à + * chaque image, ce qui donne le fouetté et la chute naturels. + * + * Sans JavaScript, la scène reste dans son état « branché » défini dans le SVG. + */ +(function () { + 'use strict'; + + var svg = document.querySelector('.nf-scene'); + if (!svg) { + return; + } + + var el = { + switch: svg.querySelector('#nf-switch'), + tux: svg.querySelector('#nf-tux'), + arm: svg.querySelector('#nf-arm'), + connector: svg.querySelector('#nf-connector'), + cables: svg.querySelectorAll('.nf-cable'), + ledGreen: svg.querySelectorAll('.nf-led-green'), + ledRed: svg.querySelectorAll('.nf-led-red'), + badge: svg.querySelector('#nf-badge'), + spark: svg.querySelector('#nf-spark'), + footL: svg.querySelector('#nf-foot-l'), + footR: svg.querySelector('#nf-foot-r'), + eyes: svg.querySelector('#nf-eyes') + }; + + /* Géométrie — doit rester synchronisée avec le dessin dans p/404.php. */ + var G = { + feet: [180, 356], + armPivot: [198, 224], + hand: [276, 265], + plugPivot: [555, 236], + connAttach: [534, 236] + }; + + /* Timeline (ms) : tout se joue une fois, puis l'image finale reste. */ + var APPROACH_A = 1000, APPROACH_B = 1750; + var PULL_A = 1800, RELEASE = 2900; + var HAND_RELEASE = 3500, RECOVER = 4600; + var TOTAL = 6400; + + var PULL_X = -112; + var FLOOR = 386; + var GRAVITY = 1600; + + /* ── Helpers ─────────────────────────────────────────────────────────── */ + + function clamp01(x) { return x < 0 ? 0 : (x > 1 ? 1 : x); } + function smoothstep(e0, e1, x) { + var t = clamp01((x - e0) / (e1 - e0)); + return t * t * (3 - 2 * t); + } + function easeInOut(t) { + return t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2; + } + + function mul(A, B) { + return [ + A[0] * B[0] + A[2] * B[1], + A[1] * B[0] + A[3] * B[1], + A[0] * B[2] + A[2] * B[3], + A[1] * B[2] + A[3] * B[3], + A[0] * B[4] + A[2] * B[5] + A[4], + A[1] * B[4] + A[3] * B[5] + A[5] + ]; + } + function tr(x, y) { return [1, 0, 0, 1, x, y]; } + function rot(deg, cx, cy) { + var r = deg * Math.PI / 180, c = Math.cos(r), s = Math.sin(r); + return [c, s, -s, c, cx - c * cx + s * cy, cy - s * cx - c * cy]; + } + function apply(m, x, y) { return [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]]; } + function tx(x, y, deg, px, py) { + return 'translate(' + x + ' ' + y + ')' + + (deg ? ' rotate(' + deg + ' ' + px + ' ' + py + ')' : ''); + } + function setOpacity(list, value) { + for (var i = 0; i < list.length; i++) { + list[i].setAttribute('opacity', value.toFixed(3)); + } + } + function setCable(d) { + for (var i = 0; i < el.cables.length; i++) { + el.cables[i].setAttribute('d', d); + } + } + + /* ── État persistant ─────────────────────────────────────────────────── */ + + var springX = 0, springV = 0; // connecteur tant qu'il est tenu + var prevPull = 0, gait = 0; + var released = false; // le câble est-il lâché (chute libre) ? + var endA = { x: 0, y: 0, vx: 0, vy: 0, rest: false }; // extrémité connecteur + var endB = { x: 0, y: 0, vx: 0, vy: 0, rest: false }; // extrémité libre (main) + var connDeg = 0, connDegV = 0; + + function springStep(pos, vel, target, k, d, dt) { + var acc = -k * (pos - target) - d * vel; + vel += acc * dt; + pos += vel * dt; + return [pos, vel]; + } + + /* Chute d'une extrémité : gravité, rebond amorti, frottement au sol. */ + function fall(pt, dt) { + if (pt.rest) { + return; + } + pt.vy += GRAVITY * dt; + pt.vx *= 0.995; + pt.x += pt.vx * dt; + pt.y += pt.vy * dt; + if (pt.y >= FLOOR) { + pt.y = FLOOR; + if (pt.vy > 40) { + pt.vy = -pt.vy * 0.38; // rebond + pt.vx *= 0.6; + } else { + pt.vy = 0; + } + pt.vx *= 0.86; // frottement + if (Math.abs(pt.vx) < 7 && Math.abs(pt.vy) < 1) { + pt.vx = 0; + pt.rest = true; + } + } + } + + /* ── Un pas d'animation ──────────────────────────────────────────────── */ + + function advance(t, dt) { + /* Courbe de traction : Tux tire, puis se détend et se relève partiellement */ + var pull; + if (t <= PULL_A) { + pull = 0; + } else if (t < RELEASE) { + pull = easeInOut((t - PULL_A) / (RELEASE - PULL_A)); + } else if (t < HAND_RELEASE) { + pull = 1; + } else if (t < RECOVER) { + pull = 1 - 0.5 * easeInOut((t - HAND_RELEASE) / (RECOVER - HAND_RELEASE)); + } else { + pull = 0.5; + } + + var approach = smoothstep(APPROACH_A, APPROACH_B, t); + var sinceRel = (t - RELEASE) / 1000; + var yank = (t >= RELEASE && t < RELEASE + 900) + ? -13 * Math.sin(sinceRel * 13) * Math.exp(-sinceRel * 5) : 0; + var struggle = -3 * Math.sin(t / 70) * (pull * (1 - pull) * 4); + + var tuxX = 9 * approach + PULL_X * pull + yank + struggle; + var tuxRot = 5 * approach - 13 * pull - yank * 0.12; + var bob = Math.sin(t / 520) * 1.2 - 2 * pull; + + /* Démarche : la phase avance avec la distance parcourue */ + var dp = pull - prevPull; + gait += Math.abs(dp) * 16; + var walk = smoothstep(0.006, 0.05, Math.abs(dp) / Math.max(dt, 0.001) * 0.1); + var swing = Math.sin(gait) * 9 * walk; + var liftL = Math.max(0, Math.sin(gait)) * 6 * walk; + var liftR = Math.max(0, Math.sin(gait + Math.PI)) * 6 * walk; + prevPull = pull; + + el.tux.setAttribute('transform', tx(tuxX, bob, tuxRot, G.feet[0], G.feet[1])); + el.footL.setAttribute('transform', 'translate(' + (swing * 0.7).toFixed(2) + ' ' + (-liftL).toFixed(2) + ')'); + el.footR.setAttribute('transform', 'translate(' + (-swing * 0.7).toFixed(2) + ' ' + (-liftR).toFixed(2) + ')'); + + var armRot = 16 * approach - 24 * pull; + el.arm.setAttribute('transform', + tx(tuxX, bob, tuxRot, G.feet[0], G.feet[1]) + + ' rotate(' + armRot + ' ' + G.armPivot[0] + ' ' + G.armPivot[1] + ')'); + + /* Regard : Tux suit le connecteur, puis regarde le câble au sol */ + var gx = 0, gy = 0; + if (t >= HAND_RELEASE) { gx = -2; gy = 5; } + else if (t >= RELEASE) { gx = 3; gy = -1.5; } + if (el.eyes) { + el.eyes.setAttribute('transform', 'translate(' + gx + ' ' + gy + ')'); + } + + /* Connecteur tenu : ressort vers la main tant qu'il est branché/tenu */ + var target = t >= RELEASE ? tuxX : 0; + var sp = springStep(springX, springV, target, 150, 14, dt); + springX = sp[0]; + springV = sp[1]; + + var tuxM = mul(tr(tuxX, bob), rot(tuxRot, G.feet[0], G.feet[1])); + var armM = mul(tuxM, rot(armRot, G.armPivot[0], G.armPivot[1])); + var hand = apply(armM, G.hand[0], G.hand[1]); + + var heldRot = (t >= RELEASE && t < HAND_RELEASE) + ? 15 * Math.sin(sinceRel * 7) * Math.exp(-sinceRel * 1.2) : 0; + var heldA = [G.connAttach[0] + springX, G.connAttach[1]]; + + /* Point A = extrémité câble du connecteur ; point B = extrémité libre */ + var A, B, deg; + if (t < HAND_RELEASE) { + A = heldA; + B = hand; + deg = heldRot; + released = false; + } else { + if (!released) { + /* Lâcher : les deux extrémités deviennent des points libres, avec la + vitesse héritée du ressort (le connecteur part vers la gauche). */ + released = true; + endA.x = heldA[0]; endA.y = heldA[1]; + endA.vx = springV * 0.5 - 140; endA.vy = 0; + endB.x = hand[0]; endB.y = hand[1]; + endB.vx = -14; endB.vy = 0; + connDeg = heldRot; + connDegV = 60; + } + fall(endA, dt); + fall(endB, dt); + /* Le connecteur bascule sur le flanc puis se stabilise */ + connDegV += (-(connDeg - (-82)) * 130 - connDegV * 12) * dt; + connDeg += connDegV * dt; + A = [endA.x, endA.y]; + B = [endB.x, endB.y]; + deg = connDeg; + } + + /* Connecteur : translation calculée pour amener son point d'attache en A */ + var R = rot(deg, G.plugPivot[0], G.plugPivot[1]); + var ar = apply(R, G.connAttach[0], G.connAttach[1]); + el.connector.setAttribute('transform', + 'translate(' + (A[0] - ar[0]).toFixed(2) + ' ' + (A[1] - ar[1]).toFixed(2) + ')' + + ' rotate(' + deg.toFixed(2) + ' ' + G.plugPivot[0] + ' ' + G.plugPivot[1] + ')'); + + /* Câble : affaissement réduit quand il se tend, jamais sous le sol */ + var dist = Math.sqrt((A[0] - B[0]) * (A[0] - B[0]) + (A[1] - B[1]) * (A[1] - B[1])); + var taut = clamp01((dist - 150) / 220); + var velWorld = released ? endA.vx : springV; + var wob = Math.max(-18, Math.min(18, velWorld * 0.05)); + var sway = 5 * Math.sin(t / 620) + 2 * Math.sin(t / 370 + 1.3); + var sag = 92 * (1 - taut * 0.55) + (released ? 0 : sway); + var lim = FLOOR - 3; + + var c1x = A[0] - 46 - 16 * taut; + var c1y = Math.min(lim, A[1] + sag); + var c2x = B[0] + 64; + var c2y = Math.min(lim, Math.min(lim, B[1] + sag * 0.8) + wob); + setCable('M ' + A[0].toFixed(2) + ' ' + A[1].toFixed(2) + + ' C ' + c1x.toFixed(2) + ' ' + c1y.toFixed(2) + + ', ' + c2x.toFixed(2) + ' ' + c2y.toFixed(2) + + ', ' + B[0].toFixed(2) + ' ' + B[1].toFixed(2)); + + /* LED : vert au départ, rouge clignotant une fois débranché */ + var greenA = clamp01(1 - smoothstep(RELEASE - 60, RELEASE + 40, t)); + var redA = (1 - greenA) * (0.55 + 0.45 * Math.abs(Math.sin(t / 90))); + setOpacity(el.ledGreen, greenA); + setOpacity(el.ledRed, redA); + + /* Pastille « link down » */ + var badgeA = smoothstep(RELEASE, RELEASE + 220, t); + el.badge.setAttribute('opacity', badgeA.toFixed(3)); + el.badge.setAttribute('transform', + 'translate(648 150) scale(' + (0.55 + 0.45 * badgeA).toFixed(3) + ') translate(-648 -150)'); + + /* Étincelle de débranchement */ + var sparkA = (t >= RELEASE && sinceRel < 0.55) ? Math.exp(-sinceRel * 7) : 0; + el.spark.setAttribute('opacity', sparkA.toFixed(3)); + el.spark.setAttribute('transform', + 'translate(557 228) scale(' + (0.7 + sinceRel * 1.6).toFixed(3) + ') translate(-557 -228)'); + + /* Secousse du switch */ + var jx = 0, jr = 0; + if (t >= RELEASE) { + jx = 4 * Math.sin(sinceRel * 32) * Math.exp(-sinceRel * 7); + jr = 0.55 * Math.sin(sinceRel * 32) * Math.exp(-sinceRel * 7); + } + el.switch.setAttribute('transform', tx(jx, 0, jr, 515, 206)); + } + + /* ── Lancement ───────────────────────────────────────────────────────── */ + + var reduceMotion = window.matchMedia + && window.matchMedia('(prefers-reduced-motion: reduce)').matches; + + if (reduceMotion || typeof window.requestAnimationFrame !== 'function') { + /* Accessibilité / vieux navigateurs : on saute directement à l'image finale. */ + var step = 1000 / 60; + for (var sim = 0; sim < TOTAL; sim += step) { + advance(sim, step / 1000); + } + advance(TOTAL, step / 1000); + return; + } + + var start = null; + var last = 0; + + function frame(now) { + if (start === null) { + start = now; + last = now; + } + var t = now - start; + var dt = Math.min(0.05, (now - last) / 1000) || 0.016; + last = now; + if (t >= TOTAL) { + advance(TOTAL, dt); // image finale, puis on s'arrête + return; + } + advance(t, dt); + window.requestAnimationFrame(frame); + } + + window.requestAnimationFrame(frame); +})(); diff --git a/p/assets/styles/404.css b/p/assets/styles/404.css new file mode 100644 index 0000000..6d1a3f8 --- /dev/null +++ b/p/assets/styles/404.css @@ -0,0 +1,110 @@ +@import "./var.css"; + +/* ── 404 — Tux débranche le câble réseau ───────────────────────────────────── + Mise en page uniquement : le mouvement (Tux, connecteur, câble) est piloté + par p/assets/js/not-found.js. Le SVG est livré dans son état « branché », + donc la page reste propre même sans JavaScript. */ + +.notfound { + position: relative; + overflow: hidden; + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); + align-items: center; + gap: clamp(1.5rem, 4vw, 3rem); + padding: clamp(1.75rem, 4vw, 3.25rem); + border-radius: 1.25rem; + background: var(--surface); + border: 1px solid var(--border); + box-shadow: var(--shadow-lg); +} + +.notfound::before { + content: ""; + position: absolute; + inset: -35% -10% auto; + height: 70%; + background: radial-gradient(60% 100% at 78% 0%, rgba(56, 189, 248, 0.16), transparent 70%); + pointer-events: none; +} + +.notfound-copy { + position: relative; + z-index: 2; +} + +.notfound-code { + margin: 0 0 0.35rem; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: clamp(3.5rem, 11vw, 6.5rem); + line-height: 0.9; + letter-spacing: -0.04em; + color: transparent; + background: linear-gradient(180deg, var(--accent-soft), var(--accent-strong)); + -webkit-background-clip: text; + background-clip: text; +} + +.notfound-title { + margin: 0 0 0.75rem; + font-family: "Georgia", "Palatino Linotype", serif; + font-size: clamp(1.6rem, 3.6vw, 2.6rem); + line-height: 1.1; + color: var(--text); +} + +.notfound-lead { + margin: 0 0 1.5rem; + max-width: 46ch; + color: var(--text-secondary); + line-height: 1.7; + text-wrap: pretty; +} + +.notfound-actions { + display: flex; + flex-wrap: wrap; + gap: 0.75rem; +} + +.notfound-visual { + position: relative; + z-index: 2; +} + +.nf-scene { + display: block; + width: 100%; + height: auto; + overflow: visible; +} + +/* ── Responsive ───────────────────────────────────────────────────────────── */ + +@media (max-width: 900px) { + .notfound { + grid-template-columns: 1fr; + text-align: center; + } + + .notfound-visual { + order: 2; + max-width: 34rem; + margin: 0 auto; + } + + .notfound-lead { + margin-left: auto; + margin-right: auto; + } + + .notfound-actions { + justify-content: center; + } +} + +@media (max-width: 700px) { + .notfound-actions .button { + width: 100%; + } +}