Spaces:
Running
Running
v10: smooth swell fit
Browse filesFiles changed (5)
- BACKLOG.md+13-1
- README.md+1-1
- src/body.ts+135-1
- src/main.ts+2
- src/versions.ts+27-1
99 unmodified lines10010110210310310410510639 unmodified lines14614714814915015115215315415515615715815916016116216399 unmodified linesOpenRouter shadow_3 / shadow_6). They follow the hands every frame, pinned or not. Uses thelogo alpha mask (`mask-type: alpha`), which Figma may not honour on SVG import.
## v9 (current): one press arc## v9: one press arc
The edge bow is one press arc for the whole logo instead of one bow per path: the pressededge points (same rule as v8's edge bow) are gathered from every path, split into groups39 unmodified lines17 → 26.7 px at one spot) or the fit switches which edge rays it leaves out (Pydantic, ~5 px);springs ease these over ~0.2 s while dragging.
## v10 (current): smooth swell fit
v9 with Huggy's moon swells fitted smoothly, so a swell never snaps between shapes whiledragging. Each ray's openness fades in (0 → 1) with its room to the pocket's far wall and withhow far the rim has entered the pocket there (both measured below the 3 px scan step). Runs ofopen rays are swells; inside one, a half-open ray blends "two separate swells" with "onemerged swell" by its openness, and instead of picking one best trim, every trim's arc isblended (soft-max on height × width, weighted by the openness of the half-open edge rays itincludes). Settled 1 px drag sweep, biggest swell step: Mistral 9.6 → 3.0 px, Pydantic4.9 → 2.7, Fal 3.4 → 2.7, OpenRouter 2.3 → 2.3 (the remaining ones are a swell first appearingat contact). Figma frames unchanged. Cost: up to ~5 ms per frame on Pydantic (v9 ~2.5).
## Contact shadow painting on the logo
Darken the partner logo where it presses into Huggy, like the `shadow` layers on the logos in40 unmodified lines414243444445464740 unmodified lines Huggy's swell and both logo bows, so everything squishes harder the further the logo is pushed in, up to the set maximums. The sidebar's "Squish tuning" panel (`src/tuner.ts`) edits every setting live and records / exports "sweet spots" as JSON.- `src/versions.ts` lists every stage of the squish (v1 Figma bend … v9 one press arc, the current one) with a- `src/versions.ts` lists every stage of the squish (v1 Figma bend … v10 smooth swell fit, the current one) with a short description; the sidebar's Version dropdown switches between them (engine, defaults and relevant sliders) for quick comparison. v6 (push field, reverted) lives in `src/warpField.ts`.- `src/hands.ts` keeps the right hand near home (small snap to the nearest edge) and lets16 unmodified lines17181920212223242512 unmodified lines38394041424344454696 unmodified lines143144145140146147148149150151152153154155156157158159160214 unmodified lines3753763773783793803813823833843853864 unmodified lines39139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150279 unmodified lines58258358458558658758858916 unmodified linesconst SPRING = 260; // pull toward targetconst TENSION = 2600; // neighbour smoothing (keeps the outline round)const DAMPING = 20;const SOFT_ENTRY = 8; // v10: px the rim must be into the pocket at a ray for it to be fully openconst SOFT_ROOM = 8; // v10: px of room over the outline gap for a ray to be fully openconst SOFT_FIT_TEMP = 0.12; // v10: soft-max width for blending trims (× the best score)const MOON_ENTRY_GAIN = 2; // moon swell: at most this × how far the rim is into the pocket (px)const MOON_MAX_SAG = 0.6; // moon swell: arc height ≤ this × half its width (a gentle crescent)// Moon swell: keep Huggy's outline (its stroke, plus a little room) inside the pocket walls.12 unmodified lines * smooths it further. 'moon' (v8): one circular arc across the pocket that leaves Huggy's * circle at a clear angle; springs settle exactly on it (tension only smooths the motion). */ swellShape?: 'dome' | 'moon'; /** v10: fit moon swells smoothly (blend trims / merges by how open each ray is) so a swell * never snaps between shapes while dragging. */ swellSmooth?: boolean;}
// Swell height = minBulge + (maxBulge − minBulge) × squish level × swellAmount, so Huggy swells96 unmodified lines // rim enters the pocket and peaking inside it. let w = kR; while (w <= kMax && cls[w] === CLS_POCKET) w++; const wall = w * STEP; let wall = w * STEP; if (this.params.swellSmooth && w > kR && w <= kMax) { // v10: refine the far wall between grid steps too, so the room grows smoothly. let a = (w - 1) * STEP; // pocket let z = w * STEP; // wall for (let it = 0; it < 5; it++) { const mid = (a + z) / 2; if (sampler.cls(BODY.cx + c * mid, BODY.cy + s * mid) === CLS_POCKET) a = mid; else z = mid; } wall = z; } // How far the rim has gone into the pocket: the pocket's extent inside the rim // (measured to sub-step precision from the inner edge's position on the grid). let n = kR;214 unmodified lines } this.bulge = b * hug;
if (moonShape && p.swellSmooth) { const r = this.smoothMoon(b, moonRadius, fitHeight); for (let i = 0; i < N; i++) this.target[i] = hug > 0 ? R + (r[i] - R) * hug : R; return; }
for (let i = 0; i < N; i++) { if (swells(i) && hug > 0) { // Fade the whole dome (lift included) with the hug amount.4 unmodified lines } }
/** * v10 moon swell, fitted smoothly. Each ray's openness o ∈ [0, 1] fades in with its room * (eligible, pocket wall more than the outline gap away; full at SOFT_ROOM px more). Runs of * open rays are swells. Within one: * - a half-open ray inside it blends between "two separate swells" (weight 1 − o) and "one * merged swell" (weight o), so neighbours merge gradually instead of snapping into one arc; * - instead of the single best trim (edge rays left out), every trim is blended, weighted by * how full its arc is (height × width, soft-max) and by the openness of the half-open edge * rays it includes, so the arc's ends slide instead of jumping. * Returns the target radius per ray. */ private smoothMoon( b: number, moonRadius: (i: number, h: number, first: number, len: number) => number, fitHeight: (first: number, len: number, b: number) => number, ): Float32Array { const R = BODY.r; const out = new Float32Array(N).fill(R); const open = new Float32Array(N); for (let i = 0; i < N; i++) { const ray = this.rays[i]; // Fades in with its room and with how far the rim has entered the pocket here (a ray that // just became part of a pocket starts closed even when the pocket's far wall is far). open[i] = ray.eligible ? smooth01((ray.wall - R - (MOON_WALL_GAP + 1)) / SOFT_ROOM) * smooth01(ray.inner / SOFT_ENTRY) : 0; } // Soft-trimmed fit of rays first..first+len-1 (absolute indices, may exceed N). const fitPart = (first: number, len: number): Float32Array => { const res = new Float32Array(len).fill(R); if (len < 1) return res; const maxTrim = Math.floor(len / 3); const combos: { tl: number; tr: number; h: number; w: number }[] = []; for (let tl = 0; tl <= maxTrim; tl++) { for (let tr = 0; tr <= maxTrim; tr++) { const n = len - tl - tr; if (n < 1 || ((tl || tr) && n < 3)) continue; const h = fitHeight(first + tl, n, b); // Half-open edge rays only count as much as they are open. let w = 1; for (let j = tl; j < len - tr; j++) w *= Math.max(1e-3, open[(first + j) % N]); combos.push({ tl, tr, h, w: w * h * n }); } } let best = 0; for (const c of combos) best = Math.max(best, c.w); if (best <= 0) return res; const tau = SOFT_FIT_TEMP * best; let wsum = 0; const acc = new Float64Array(len); for (const c of combos) { const wt = Math.exp((c.w - best) / tau); if (wt < 1e-4) continue; wsum += wt; const n = len - c.tl - c.tr; for (let j = 0; j < len; j++) { const i = (first + j) % N; const inArc = j >= c.tl && j < len - c.tr; const r = inArc && c.h > 0 ? Math.min(moonRadius(i, Math.min(b, c.h), first + c.tl, n), this.rays[i].wall) : R; acc[j] += wt * r; } } for (let j = 0; j < len; j++) res[j] = acc[j] / wsum; return res; }; // Split at the least-open interior ray: blend separate vs merged by its openness. const fitRun = (first: number, len: number, depth = 0): Float32Array => { let split = -1; let so = 1; for (let j = 1; j < len - 1; j++) { const o = open[(first + j) % N]; if (o < 0.999 && o < so) { so = o; split = j; } } const merged = fitPart(first, len); if (split < 0 || depth > 4) return merged; const left = fitRun(first, split, depth + 1); const right = fitRun(first + split + 1, len - split - 1, depth + 1); const res = new Float32Array(len); for (let j = 0; j < len; j++) { const sep = j < split ? left[j] : j > split ? right[j - split - 1] : R; res[j] = sep * (1 - so) + merged[j] * so; } return res; }; // Runs of (at least slightly) open rays, starting from a closed ray. let origin = -1; for (let i = 0; i < N; i++) if (open[i] <= 0) { origin = i; break; } if (origin < 0) origin = 0; let start = -1; for (let n = 0; n <= N; n++) { const i = (origin + n) % N; const on = n < N && open[i] > 0; if (on && start < 0) start = origin + n; if (!on && start >= 0) { const len = origin + n - start; const r = fitRun(start, len); for (let j = 0; j < len; j++) out[(start + j) % N] = r[j]; start = -1; } } return out; }
step(dt: number) { const sub = 4; const h = dt / sub;79 unmodified lines } return d + 'Z';}
function smooth01(v: number) { const t = Math.max(0, Math.min(1, v)); return t * t * (3 - 2 * t);}1005 unmodified lines100610071008100910101011101219 unmodified lines10321033103410351036103710381005 unmodified lines localStorage.setItem(VERSION_KEY, v.id); body.params.swellMode = v.swellMode; body.params.swellShape = v.swellShape ?? 'dome'; body.params.swellSmooth = !!v.swellSmooth; for (const k of Object.keys(tuneDefaults)) delete tuneDefaults[k]; Object.assign(tuneDefaults, v.defaults); versionSelect.value = v.id;19 unmodified lines});body.params.swellMode = version.swellMode;body.params.swellShape = version.swellShape ?? 'dome';body.params.swellSmooth = !!version.swellSmooth;// Start from the selected version's defaults (the panel then restores your own tweaks).for (const p of tuneSpecs) if (typeof version.defaults[p.key] === 'number') p.set(version.defaults[p.key]);versionSelect.value = version.id;15 unmodified lines16171819202122149 unmodified lines17217317417417517617717815 unmodified lines19419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322415 unmodified lines cheekFollowsSquish?: boolean; // v8: the cheek squish follows the squish level (starts with the logo's) swellMode: 'level' | 'area'; // Huggy's swell: follows squish level, or solved from overlap area swellShape?: 'dome' | 'moon'; // Huggy's swell outline (default dome) swellSmooth?: boolean; // v10: moon swells fitted smoothly (no snaps between shapes) defaults: Record<string, number>; // tuning-panel values for this version uses: string[]; // tuning-panel settings that matter for this version}149 unmodified lines }, { id: 'v9', label: 'v9 · One press arc (current)', label: 'v9 · One press arc', desc: 'v8, but the edge bow is one press arc across every path facing Huggy, so a logo whose pressed side is made of separate pieces (e.g. Mistral’s stacked bars) gets one wide bow instead of one bow per piece. Single smooth edges look as in v8.', engine: 'bows', mode: { profile: 'moon', pocket: 'lowerLeft', combine: 'max', limit: 'ease', corners: true, outerOnly: true, smoothHandles: true, shadows: true, pressArc: true },15 unmodified lines 'logo.twoSided', ], }, { id: 'v10', label: 'v10 · Smooth swell fit (current)', desc: 'v9, but Huggy’s swell arcs are fitted smoothly: neighbouring swells merge gradually and the arc’s ends slide instead of jumping, so a swell never snaps between shapes while dragging.', engine: 'bows', mode: { profile: 'moon', pocket: 'lowerLeft', combine: 'max', limit: 'ease', corners: true, outerOnly: true, smoothHandles: true, shadows: true, pressArc: true }, depthDriven: true, freeze: true, freezeEdgeOnly: true, cheekFollowsSquish: true, swellMode: 'level', swellShape: 'moon', swellSmooth: true, defaults: { ...BASE, 'logo.pocketStrength': 10, 'logo.zeroDeg': 40, 'huggy.swellAmount': 0.55 }, uses: [ ...SWELL_LEVEL, ...EDGE, 'logo.pocketStrength', 'logo.depthPerLength', 'logo.fullDepth', 'logo.freezeDepth', 'logo.minThickness', 'logo.twoSided', ], },];
export const CURRENT_VERSION = VERSIONS[VERSIONS.length - 1];BACKLOG.md+13-1
README.md+1-1
src/body.ts+135-1
src/main.ts+2
src/versions.ts+27-1