Branchwell

Become a Pro / website · becomeapro.ai / scripts / covers / site-scene.mjs

Raw 6.3 KB on 6c7ce85c3441baadd17890ab9cc9bf8ed5112901
1// The site's own share image (public/og/site.jpg), in the style of the home page: a dark void, the Impossible A
2// drawn whole in blue and white particles (as in the film outros), the "AI Resource" wordmark with its PRO badge, and the
3// hero headline in light Funnel Display. Text stays clear of the top and bottom 60px, which the 1200 x 630 crop trims.
4import { H, W } from "./base.mjs";
5
6// The mark's three faces in its 64 x 64 viewBox, each with the particle colours it's drawn in (blues and whites only)
7const FACES = [
8 { d: "M3 49.94 L7.14 57.11 L56.86 57.11 L36.14 21.24 L32 28.41 L44.43 49.94Z", z: 0, colors: ["#46AAE9", "#5DB6EE", "#46AAE9"], edge: "#7CC4F2" },
9 { d: "M56.86 57.11 L61 49.94 L36.14 6.89 L15.43 42.76 L23.71 42.76 L36.14 21.24Z", z: 0, colors: ["#1F6599", "#2A7FB8", "#1F6599"], edge: "#3A86E8" },
10 { d: "M36.14 6.89 L27.86 6.89 L3 49.94 L44.43 49.94 L40.29 42.76 L15.43 42.76Z", z: 0, colors: ["#FFFFFF", "#E4F2FC", "#FFFFFF"], edge: "#FFFFFF" },
11];
12
13const solidMark = (size) =>
14 `<svg viewBox="0 0 64 64" width="${size}" height="${size}">${FACES.map((f, i) => `<path d="${f.d}" fill="${["#46AAE9", "#2A7FB8", "#fff"][i]}"/>`).join("")}</svg>`;
15
16// Runs inside the page: samples each face of the mark, flat and in register, so it reads as one solid logo
17const PARTICLES = /* js */ `
18(() => {
19 const c = document.getElementById("amark"), g = c.getContext("2d");
20 c.width = ${W}; c.height = ${H};
21 let h = 2166136261; for (const ch of "airesourcepro-site") h = Math.imul(h ^ ch.charCodeAt(0), 16777619);
22 const r = () => { h ^= h << 13; h ^= h >>> 17; h ^= h << 5; return ((h >>> 0) % 100000) / 100000; };
23 const gauss = () => (r() + r() + r() - 1.5) / 1.5;
24
25 // Loose dust across the whole frame, densest around the mark
26 for (let i = 0; i < 1400; i++) {
27 const near = r() < .55, x = near ? 1250 + gauss() * 480 : r() * ${W}, y = near ? 480 + gauss() * 380 : r() * ${H};
28 g.globalAlpha = .08 + Math.pow(r(), 2) * .5; g.fillStyle = r() < .7 ? "#bfe3fa" : "#46aae9";
29 const s = .8 + Math.pow(r(), 3) * 2; g.fillRect(x, y, s, s);
30 }
31
32 const CX = 1262, CY = 476, S = 10.2, YAW = 0, PITCH = 0, F = 150;
33 const probe = document.createElement("canvas").getContext("2d");
34 const project = (x, y, z) => {
35 x -= 32; y -= 32;
36 const x1 = x * Math.cos(YAW) + z * Math.sin(YAW), z1 = -x * Math.sin(YAW) + z * Math.cos(YAW);
37 const y1 = y * Math.cos(PITCH) - z1 * Math.sin(PITCH), z2 = y * Math.sin(PITCH) + z1 * Math.cos(PITCH);
38 const k = F / (F - z2);
39 return [CX + x1 * k * S, CY + y1 * k * S, k];
40 };
41 const pts = [];
42 FACES.forEach((f) => {
43 const path = new Path2D(f.d);
44 // fill: random points inside the face, with a little depth so the mark reads as a solid, not a decal
45 for (let n = 0; n < 9000; ) {
46 const x = 3 + r() * 58, y = 6.5 + r() * 51;
47 if (!probe.isPointInPath(path, x, y)) continue;
48 n++; pts.push([x, y, f.z + gauss() * .3, f.colors[(r() * 3) | 0], .45 + r() * .5, .75 + Math.pow(r(), 3) * 1.6]);
49 }
50 // edges: denser, brighter points so the shape stays crisp at thumbnail size
51 const v = f.d.match(/[\\d.]+ [\\d.]+/g).map((p) => p.split(" ").map(Number));
52 v.forEach((a, i) => {
53 const b = v[(i + 1) % v.length], len = Math.hypot(b[0] - a[0], b[1] - a[1]);
54 for (let t = 0; t < len * 26; t++) {
55 const u = r();
56 pts.push([a[0] + (b[0] - a[0]) * u + gauss() * .1, a[1] + (b[1] - a[1]) * u + gauss() * .1, f.z + gauss() * .4, f.edge, .45 + r() * .35, .9 + r() * .7]);
57 }
58 });
59 });
60
61 // Draw back to front, additively, so overlaps glow
62 const out = pts.map(([x, y, z, col, a, s]) => {
63 const [px, py, k] = project(x, y, z);
64 return [px, py, k, col, a, s * k];
65 }).sort((p, q) => p[2] - q[2]);
66
67 g.globalCompositeOperation = "lighter";
68 const glow = g.createRadialGradient(CX, CY + 20, 20, CX, CY + 20, 430);
69 glow.addColorStop(0, "rgba(70,170,233,.26)"); glow.addColorStop(1, "rgba(70,170,233,0)");
70 g.globalAlpha = 1; g.fillStyle = glow; g.fillRect(0, 0, ${W}, ${H});
71 for (const [x, y, k, col, a, s] of out) {
72 g.globalAlpha = a; g.fillStyle = col; g.beginPath(); g.arc(x, y, s, 0, 6.2832); g.fill();
73 }
74 // a few larger outlined triangles, the site's particle motif
75 g.lineWidth = 1.4;
76 for (let i = 0; i < 46; i++) {
77 const x = 1250 + gauss() * 520, y = 470 + gauss() * 400, s = 3 + Math.pow(r(), 3) * 9, rot = r() * 6.28;
78 g.globalAlpha = .25 + r() * .45; g.strokeStyle = ["#46AAE9", "#7CC4F2", "#BFE3FA"][(r() * 3) | 0];
79 g.beginPath();
80 for (let q = 0; q < 3; q++) { const t = rot + q * 2.0944; q ? g.lineTo(x + Math.cos(t) * s, y + Math.sin(t) * s) : g.moveTo(x + Math.cos(t) * s, y + Math.sin(t) * s); }
81 g.closePath(); g.stroke();
82 }
83})();`;
84
85export function siteScene() {
86 return {
87 plain: true,
88 glows: [
89 { x: 1250, y: 476, w: 1000, h: 760, c: "rgba(58,134,232,.20)" },
90 { x: 260, y: 820, w: 900, h: 420, c: "rgba(70,170,233,.10)" },
91 ],
92 body: `
93 <style>html, body { background: #0b0f16; }</style>
94 <canvas id="amark" style="position:absolute;inset:0"></canvas>
95 <script>const FACES = ${JSON.stringify(FACES)};${PARTICLES}</script>
96 <div class="abs" style="left:112px;top:150px;width:900px;text-shadow:0 0 40px rgba(6,10,18,.9)">
97 <div style="display:flex;align-items:center;gap:18px;font:600 50px Poppins, Geist, sans-serif;letter-spacing:-0.02em;color:#fff">
98 ${solidMark(62)}<span>AI Resource</span><span style="margin-left:4px;border-radius:12px;background:#46aae9;padding:4px 15px;font-size:28px;letter-spacing:.02em;text-shadow:none;box-shadow:0 0 30px rgba(70,170,233,.45)">PRO</span>
99 </div>
100 <div class="display" style="margin-top:58px;font-size:132px;font-weight:400;line-height:.92;letter-spacing:-0.05em;color:#fff">Learn AI by<br>building with it.</div>
101 <div style="margin-top:40px;font-size:31px;font-weight:300;line-height:1.45;color:rgba(214,232,247,.82);max-width:700px">Claude Code and Codex best practices, computer-use agents, and open-weight models on your own GPU.</div>
102 </div>
103 <div class="abs mono" style="left:114px;bottom:96px;display:flex;align-items:center;gap:14px;font-size:22px;letter-spacing:.14em;text-transform:uppercase;color:#7cc4f2">
104 <span style="width:34px;height:1px;background:#46aae9"></span>Free tutorials and videos
105 </div>
106 <div class="abs mono" style="right:110px;bottom:96px;font-size:24px;letter-spacing:.02em;color:rgba(214,232,247,.75)">airesourcepro.com</div>`,
107 };
108}