diff options
Diffstat (limited to 'public/bluebey-studio')
| -rw-r--r-- | public/bluebey-studio/src/caption.js | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/public/bluebey-studio/src/caption.js b/public/bluebey-studio/src/caption.js index 08b962f..821ccb5 100644 --- a/public/bluebey-studio/src/caption.js +++ b/public/bluebey-studio/src/caption.js @@ -827,6 +827,7 @@ function thinkEdges(box, scale) { const amp = Math.min((perimeter / count) * 0.55, Math.min(w, h) * 0.26); const edges = []; + let outer = amp; for (let i = 0; i < points.length; i++) { const a = points[i]; const b = points[(i + 1) % points.length]; @@ -844,9 +845,13 @@ function thinkEdges(box, scale) { nx = -nx; ny = -ny; } - edges.push(scallopEdge(a, b, { x: nx, y: ny }, amp)); + // A small, *deterministic* wobble so the scallops are not all identical - the + // even size read as too regular. Same index, same bubble, every render. + const scallopAmp = amp * (0.72 + 0.56 * scallopJitter(i)); + if (scallopAmp > outer) outer = scallopAmp; + edges.push(scallopEdge(a, b, { x: nx, y: ny }, scallopAmp)); } - return { edges, amp }; + return { edges, amp: outer }; } /** A closed cloud, followed by the tail: two or three shrinking puffs. */ @@ -905,6 +910,17 @@ function scallopEdge(from, to, normal, amp) { ); } +/** + * A small deterministic wobble in 0..1 for the i-th scallop of a cloud. + * + * It is derived from the index alone, so a bubble draws its scallops exactly + * the same in the live preview, a screenshot, and the SVG export. + */ +function scallopJitter(i) { + const x = Math.sin((i + 1) * 12.9898) * 43758.5453; + return x - Math.floor(x); +} + /** A circle as `M`/`C`/`Z` commands, so it can join the bubble's one path. */ function circleCommands(cx, cy, r) { const k = r * KAPPA; |
