agentcut 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -2
- package/dist/bridge.d.ts +45 -0
- package/dist/bridge.js +691 -0
- package/dist/bridge.js.map +1 -0
- package/dist/config.d.ts +13 -0
- package/dist/config.js +50 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/log.d.ts +1 -0
- package/dist/log.js +14 -0
- package/dist/log.js.map +1 -0
- package/dist/studio/agents/claude.d.ts +7 -0
- package/dist/studio/agents/claude.js +155 -0
- package/dist/studio/agents/claude.js.map +1 -0
- package/dist/studio/agents/codex.d.ts +4 -0
- package/dist/studio/agents/codex.js +169 -0
- package/dist/studio/agents/codex.js.map +1 -0
- package/dist/studio/agents/index.d.ts +8 -0
- package/dist/studio/agents/index.js +50 -0
- package/dist/studio/agents/index.js.map +1 -0
- package/dist/studio/agents/types.d.ts +131 -0
- package/dist/studio/agents/types.js +11 -0
- package/dist/studio/agents/types.js.map +1 -0
- package/dist/studio/bundler.d.ts +29 -0
- package/dist/studio/bundler.js +136 -0
- package/dist/studio/bundler.js.map +1 -0
- package/dist/studio/chat.d.ts +147 -0
- package/dist/studio/chat.js +681 -0
- package/dist/studio/chat.js.map +1 -0
- package/dist/studio/cli.d.ts +2 -0
- package/dist/studio/cli.js +194 -0
- package/dist/studio/cli.js.map +1 -0
- package/dist/studio/components.d.ts +4 -0
- package/dist/studio/components.js +36 -0
- package/dist/studio/components.js.map +1 -0
- package/dist/studio/host.d.ts +105 -0
- package/dist/studio/host.js +634 -0
- package/dist/studio/host.js.map +1 -0
- package/dist/studio/http.d.ts +21 -0
- package/dist/studio/http.js +240 -0
- package/dist/studio/http.js.map +1 -0
- package/dist/studio/music.d.ts +35 -0
- package/dist/studio/music.js +130 -0
- package/dist/studio/music.js.map +1 -0
- package/dist/studio/proc.d.ts +11 -0
- package/dist/studio/proc.js +69 -0
- package/dist/studio/proc.js.map +1 -0
- package/dist/studio/projects.d.ts +84 -0
- package/dist/studio/projects.js +369 -0
- package/dist/studio/projects.js.map +1 -0
- package/dist/studio/render.d.ts +24 -0
- package/dist/studio/render.js +197 -0
- package/dist/studio/render.js.map +1 -0
- package/dist/studio/reveal.d.ts +7 -0
- package/dist/studio/reveal.js +49 -0
- package/dist/studio/reveal.js.map +1 -0
- package/dist/studio/schema.d.ts +4152 -0
- package/dist/studio/schema.js +358 -0
- package/dist/studio/schema.js.map +1 -0
- package/dist/studio/tools.d.ts +2 -0
- package/dist/studio/tools.js +165 -0
- package/dist/studio/tools.js.map +1 -0
- package/dist/studio/voice.d.ts +150 -0
- package/dist/studio/voice.js +434 -0
- package/dist/studio/voice.js.map +1 -0
- package/dist/studio/workspace.d.ts +31 -0
- package/dist/studio/workspace.js +187 -0
- package/dist/studio/workspace.js.map +1 -0
- package/package.json +50 -4
- package/template/AGENTS.md +13 -0
- package/template/components/CATALOG.md +1306 -0
- package/template/components/README.md +61 -0
- package/template/components/STYLES.md +246 -0
- package/template/components/arcade-title/ArcadeTitle.tsx +860 -0
- package/template/components/arcade-title/meta.json +28 -0
- package/template/components/aurora/Aurora.tsx +63 -0
- package/template/components/aurora/meta.json +28 -0
- package/template/components/bar-wipe-title/BarWipeTitle.tsx +94 -0
- package/template/components/bar-wipe-title/meta.json +29 -0
- package/template/components/before-after/BeforeAfter.tsx +89 -0
- package/template/components/before-after/meta.json +233 -0
- package/template/components/bento-grid/BentoGrid.tsx +202 -0
- package/template/components/bento-grid/meta.json +25 -0
- package/template/components/blur-in-title/BlurInTitle.tsx +121 -0
- package/template/components/blur-in-title/meta.json +32 -0
- package/template/components/catalog.json +8730 -0
- package/template/components/catalog.ts +103 -0
- package/template/components/chat-thread/ChatThread.tsx +128 -0
- package/template/components/chat-thread/meta.json +24 -0
- package/template/components/checklist/Checklist.tsx +129 -0
- package/template/components/checklist/meta.json +25 -0
- package/template/components/confetti/Confetti.tsx +109 -0
- package/template/components/confetti/meta.json +28 -0
- package/template/components/countdown/Countdown.tsx +166 -0
- package/template/components/countdown/meta.json +28 -0
- package/template/components/cut-and-paste/CutAndPaste.tsx +654 -0
- package/template/components/cut-and-paste/meta.json +29 -0
- package/template/components/decode-text/DecodeText.tsx +97 -0
- package/template/components/decode-text/meta.json +29 -0
- package/template/components/editorial-quote/EditorialQuote.tsx +122 -0
- package/template/components/editorial-quote/meta.json +28 -0
- package/template/components/glitch-title/GlitchTitle.tsx +171 -0
- package/template/components/glitch-title/meta.json +32 -0
- package/template/components/halftone-wave/HalftoneWave.tsx +106 -0
- package/template/components/halftone-wave/meta.json +28 -0
- package/template/components/highlighter/Highlighter.tsx +142 -0
- package/template/components/highlighter/meta.json +28 -0
- package/template/components/hook-card/HookCard.tsx +552 -0
- package/template/components/hook-card/meta.json +304 -0
- package/template/components/index.ts +149 -0
- package/template/components/iris-wipe/IrisWipe.tsx +76 -0
- package/template/components/iris-wipe/meta.json +24 -0
- package/template/components/kinetic-poster/KineticPoster.tsx +437 -0
- package/template/components/kinetic-poster/meta.json +31 -0
- package/template/components/kinetic-punch/KineticPunch.tsx +80 -0
- package/template/components/kinetic-punch/meta.json +30 -0
- package/template/components/lava-lamp/LavaLamp.tsx +92 -0
- package/template/components/lava-lamp/meta.json +28 -0
- package/template/components/letter-cascade/LetterCascade.tsx +102 -0
- package/template/components/letter-cascade/meta.json +29 -0
- package/template/components/lib.ts +179 -0
- package/template/components/light-leak/LightLeakTransition.tsx +43 -0
- package/template/components/light-leak/meta.json +74 -0
- package/template/components/line-diagram/LineDiagram.tsx +205 -0
- package/template/components/line-diagram/meta.json +217 -0
- package/template/components/list-card/ListCard.tsx +104 -0
- package/template/components/list-card/meta.json +232 -0
- package/template/components/logo-sting/LogoSting.tsx +129 -0
- package/template/components/logo-sting/meta.json +29 -0
- package/template/components/looks.tsx +1447 -0
- package/template/components/lower-third/LowerThird.tsx +100 -0
- package/template/components/lower-third/meta.json +24 -0
- package/template/components/marquee/Marquee.tsx +100 -0
- package/template/components/marquee/meta.json +30 -0
- package/template/components/notification/Notification.tsx +115 -0
- package/template/components/notification/meta.json +27 -0
- package/template/components/outline-fill/OutlineFill.tsx +106 -0
- package/template/components/outline-fill/meta.json +28 -0
- package/template/components/panel-sweep/PanelSweep.tsx +86 -0
- package/template/components/panel-sweep/meta.json +25 -0
- package/template/components/prompt-box/PromptBox.tsx +131 -0
- package/template/components/prompt-box/meta.json +24 -0
- package/template/components/props.ts +73 -0
- package/template/components/quote-card/QuoteCard.tsx +71 -0
- package/template/components/quote-card/meta.json +216 -0
- package/template/components/shape-shift/ShapeShift.tsx +420 -0
- package/template/components/shape-shift/meta.json +31 -0
- package/template/components/slide-zoom-message/SlideZoomMessage.tsx +179 -0
- package/template/components/slide-zoom-message/meta.json +199 -0
- package/template/components/social-post/SocialPost.tsx +185 -0
- package/template/components/social-post/meta.json +30 -0
- package/template/components/split-flap/SplitFlap.tsx +191 -0
- package/template/components/split-flap/meta.json +29 -0
- package/template/components/spotlight-grid/SpotlightGrid.tsx +84 -0
- package/template/components/spotlight-grid/meta.json +25 -0
- package/template/components/stat-counter/StatCounter.tsx +117 -0
- package/template/components/stat-counter/meta.json +27 -0
- package/template/components/sticker-badge/StickerBadge.tsx +46 -0
- package/template/components/sticker-badge/meta.json +220 -0
- package/template/components/sticker-slam/StickerSlam.tsx +941 -0
- package/template/components/sticker-slam/meta.json +34 -0
- package/template/components/style-layer.tsx +233 -0
- package/template/components/styles.json +762 -0
- package/template/components/styles.ts +113 -0
- package/template/components/target-lock/TargetLock.tsx +662 -0
- package/template/components/target-lock/meta.json +32 -0
- package/template/components/text-reveal/TextReveal.tsx +99 -0
- package/template/components/text-reveal/meta.json +28 -0
- package/template/components/tile-wipe/TileWipe.tsx +75 -0
- package/template/components/tile-wipe/meta.json +24 -0
- package/template/components/type-zoom/TypeZoom.tsx +103 -0
- package/template/components/type-zoom/meta.json +27 -0
- package/template/components/types.ts +66 -0
- package/template/components/typewriter/Typewriter.tsx +112 -0
- package/template/components/typewriter/meta.json +29 -0
- package/template/components/word-pop/WordPop.tsx +59 -0
- package/template/components/word-pop/meta.json +237 -0
- package/template/components/word-stack/WordStack.tsx +122 -0
- package/template/components/word-stack/meta.json +27 -0
- package/template/components/word-swap/WordSwap.tsx +127 -0
- package/template/components/word-swap/meta.json +30 -0
- package/template/presets/charcoal-sketch/PROMPT.md +48 -0
- package/template/presets/charcoal-sketch/assets/paper/grain-0.png +0 -0
- package/template/presets/charcoal-sketch/assets/paper/grain-1.png +0 -0
- package/template/presets/charcoal-sketch/assets/paper/grain-2.png +0 -0
- package/template/presets/charcoal-sketch/assets/paper/sketch-paper.jpg +0 -0
- package/template/presets/charcoal-sketch/assets/paper/smudge.png +0 -0
- package/template/presets/charcoal-sketch/poster.jpg +0 -0
- package/template/presets/charcoal-sketch/preset.json +17 -0
- package/template/presets/charcoal-sketch/preview.mp4 +0 -0
- package/template/presets/charcoal-sketch/scenes/Grain.tsx +23 -0
- package/template/presets/charcoal-sketch/scenes/Paper.tsx +17 -0
- package/template/presets/charcoal-sketch/scenes/examples/Agents.tsx +100 -0
- package/template/presets/charcoal-sketch/scenes/examples/Approvals.tsx +110 -0
- package/template/presets/charcoal-sketch/scenes/examples/Blog.tsx +105 -0
- package/template/presets/charcoal-sketch/scenes/examples/EndCard.tsx +41 -0
- package/template/presets/charcoal-sketch/scenes/examples/Hook.tsx +130 -0
- package/template/presets/charcoal-sketch/scenes/examples/Ideas.tsx +92 -0
- package/template/presets/charcoal-sketch/scenes/examples/Posting.tsx +128 -0
- package/template/presets/charcoal-sketch/scenes/lib/painfix.tsx +119 -0
- package/template/presets/charcoal-sketch/scenes/lib/sketch.tsx +291 -0
- package/template/presets/charcoal-sketch/scripts/build_layers.example.py +193 -0
- package/template/presets/charcoal-sketch/scripts/duck_music.py +34 -0
- package/template/presets/charcoal-sketch/scripts/make_textures.py +93 -0
- package/template/presets/punk-cut-paper/PROMPT.md +37 -0
- package/template/presets/punk-cut-paper/assets/paper/desk-cream.jpg +0 -0
- package/template/presets/punk-cut-paper/assets/paper/grain-overlay.png +0 -0
- package/template/presets/punk-cut-paper/assets/paper/halftone-black.png +0 -0
- package/template/presets/punk-cut-paper/assets/paper/halftone-red.png +0 -0
- package/template/presets/punk-cut-paper/assets/paper/halftone-yellow.png +0 -0
- package/template/presets/punk-cut-paper/assets/paper/kraft.jpg +0 -0
- package/template/presets/punk-cut-paper/assets/paper/newsprint.jpg +0 -0
- package/template/presets/punk-cut-paper/assets/paper/paper-cream.jpg +0 -0
- package/template/presets/punk-cut-paper/assets/paper/paper-white.jpg +0 -0
- package/template/presets/punk-cut-paper/assets/paper/tape.png +0 -0
- package/template/presets/punk-cut-paper/build_layers.example.py +150 -0
- package/template/presets/punk-cut-paper/poster.jpg +0 -0
- package/template/presets/punk-cut-paper/preset.json +15 -0
- package/template/presets/punk-cut-paper/preview.mp4 +0 -0
- package/template/presets/punk-cut-paper/scenes/Backdrop.tsx +76 -0
- package/template/presets/punk-cut-paper/scenes/Motif.tsx +376 -0
- package/template/presets/punk-cut-paper/scenes/Photo.tsx +73 -0
- package/template/presets/punk-cut-paper/scenes/Ransom.tsx +119 -0
- package/template/presets/punk-cut-paper/scenes/Xerox.tsx +31 -0
- package/template/presets/punk-cut-paper/scenes/lib/punk.tsx +208 -0
- package/template/runtime/composition.tsx +918 -0
- package/template/runtime/helpers.tsx +228 -0
- package/template/runtime/index.tsx +22 -0
- package/template/runtime/types.ts +248 -0
- package/template/skill/SKILL.md +149 -0
- package/template/skill/references/browser-export.md +61 -0
- package/template/skill/references/components.md +38 -0
- package/template/skill/references/craft.md +53 -0
- package/template/skill/references/cursor.md +91 -0
- package/template/skill/references/footage.md +73 -0
- package/template/skill/references/format.md +140 -0
- package/template/skill/references/presets.md +56 -0
- package/template/skill/references/sound.md +128 -0
- package/template/starter/.studio/chat.json +1 -0
- package/template/starter/assets/.keep +0 -0
- package/template/starter/layers.json +46 -0
- package/template/starter/notes.md +4 -0
- package/template/starter/project.json +13 -0
- package/template/starter/renders/.keep +0 -0
- package/template/starter/scenes/Title.tsx +38 -0
|
@@ -0,0 +1,654 @@
|
|
|
1
|
+
import { useId, type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import { AbsoluteFill, Img, random, useCurrentFrame } from "remotion";
|
|
3
|
+
import { FONTS, exitOut, onColor, splitHighlights, unit } from "../lib";
|
|
4
|
+
import type { MotionBaseProps } from "../types";
|
|
5
|
+
|
|
6
|
+
type Props = MotionBaseProps & {
|
|
7
|
+
headline: string[];
|
|
8
|
+
kicker: string;
|
|
9
|
+
bubble: string;
|
|
10
|
+
paper: string;
|
|
11
|
+
ink: string;
|
|
12
|
+
accent: string;
|
|
13
|
+
accent2: string;
|
|
14
|
+
rate: number;
|
|
15
|
+
jitter: number;
|
|
16
|
+
images: string[];
|
|
17
|
+
seed: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type Pt = [number, number];
|
|
21
|
+
|
|
22
|
+
/** Rounded so the server-rendered still and the client agree to the last digit. */
|
|
23
|
+
const r2 = (v: number) => Math.round(v * 100) / 100;
|
|
24
|
+
|
|
25
|
+
/** Fonts the ransom-note words draw from, with a rough width per character (em). */
|
|
26
|
+
const WORD_FONTS = [
|
|
27
|
+
{ font: "condensed", upper: true, weight: 400, w: 0.5 },
|
|
28
|
+
{ font: "serif", upper: false, weight: 400, w: 0.5 },
|
|
29
|
+
{ font: "fraunces", upper: false, weight: 800, w: 0.6 },
|
|
30
|
+
{ font: "mono", upper: true, weight: 600, w: 0.62 },
|
|
31
|
+
{ font: "display", upper: false, weight: 800, w: 0.58 },
|
|
32
|
+
{ font: "wide", upper: true, weight: 800, w: 0.82 },
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A cut-paper collage, stop-motion style: on warm newsprint, torn color blocks, a constructivist
|
|
37
|
+
* wedge and stripes, a halftone sun and cut-out graphics get slapped on by hand at a low frame rate,
|
|
38
|
+
* the headline arrives as ransom-note scraps, then a pointing hand, a speech bubble and scribbles.
|
|
39
|
+
* At the end the pieces are pulled off again in reverse order.
|
|
40
|
+
*/
|
|
41
|
+
export function CutAndPaste(props: Props) {
|
|
42
|
+
const frame = useCurrentFrame();
|
|
43
|
+
const { width: w, height: h, fps, durationInFrames: d } = props;
|
|
44
|
+
const u = unit(w, h);
|
|
45
|
+
const m = Math.min(w, h);
|
|
46
|
+
const vertical = h > w;
|
|
47
|
+
const id = `col${useId().replace(/[^a-zA-Z0-9]/g, "")}`;
|
|
48
|
+
const seed = props.seed;
|
|
49
|
+
|
|
50
|
+
// Stop motion: time only moves in held steps (`rate` drawings a second), and every held
|
|
51
|
+
// drawing nudges each piece by a pixel or two, like hands placing paper under a camera.
|
|
52
|
+
const holdLen = fps / Math.max(4, props.rate);
|
|
53
|
+
const hold = Math.floor(frame / holdLen);
|
|
54
|
+
const q = hold * holdLen;
|
|
55
|
+
const jit = props.jitter * u;
|
|
56
|
+
const out = exitOut(frame, d, 5);
|
|
57
|
+
|
|
58
|
+
// Removal: the last ~15% of the clip pulls pieces off, last placed first.
|
|
59
|
+
const pieces: string[] = [];
|
|
60
|
+
const order = (key: string) => {
|
|
61
|
+
pieces.push(key);
|
|
62
|
+
return pieces.length - 1;
|
|
63
|
+
};
|
|
64
|
+
type Placed = { x: number; y: number; s: number; r: number } | null;
|
|
65
|
+
const placements: Record<string, { at: number; k: number; rot: number }> = {};
|
|
66
|
+
const schedule = (key: string, at: number, rot = 5) => {
|
|
67
|
+
placements[key] = { at, k: order(key), rot };
|
|
68
|
+
};
|
|
69
|
+
const place = (key: string): Placed => {
|
|
70
|
+
const p = placements[key];
|
|
71
|
+
const n = pieces.length;
|
|
72
|
+
const rmStart = d * 0.84;
|
|
73
|
+
const off = rmStart + ((n - 1 - p.k) / n) * (d - 5 - rmStart);
|
|
74
|
+
if (q < p.at || q >= off) return null;
|
|
75
|
+
const since = Math.floor((q - p.at) / holdLen + 1e-6);
|
|
76
|
+
const dir = random(`${seed}-${key}-dir`) > 0.5 ? 1 : -1;
|
|
77
|
+
const j = (k: string) => (random(`${seed}-${key}-${hold}-${k}`) - 0.5) * 2;
|
|
78
|
+
return {
|
|
79
|
+
x: r2(j("x") * jit),
|
|
80
|
+
y: r2(j("y") * jit),
|
|
81
|
+
s: [1.16, 1.04, 1][Math.min(2, since)],
|
|
82
|
+
r: r2([p.rot, p.rot * 0.3, 0][Math.min(2, since)] * dir + j("r") * 0.35 * props.jitter),
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// ---- Layout (fractions of the frame, per orientation) ----
|
|
87
|
+
const L = vertical
|
|
88
|
+
? {
|
|
89
|
+
cy: h * 0.5,
|
|
90
|
+
sun: [w * 0.72, h * 0.2, m * 0.26] as const,
|
|
91
|
+
star: [w * 0.2, h * 0.15, m * 0.15] as const,
|
|
92
|
+
photo3: [w * 0.24, h * 0.75, m * 0.3] as const,
|
|
93
|
+
bubble: [w * 0.72, h * 0.7, m * 0.2] as const,
|
|
94
|
+
stripesY: h * 0.88,
|
|
95
|
+
}
|
|
96
|
+
: {
|
|
97
|
+
cy: h * 0.53,
|
|
98
|
+
sun: [w * 0.8, h * 0.27, m * 0.2] as const,
|
|
99
|
+
star: [w * 0.14, h * 0.22, m * 0.13] as const,
|
|
100
|
+
photo3: [w * 0.12, h * 0.66, m * 0.26] as const,
|
|
101
|
+
bubble: [w * 0.85, h * 0.72, m * 0.15] as const,
|
|
102
|
+
stripesY: h * 0.9,
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// ---- Headline: ransom-note scraps ----
|
|
106
|
+
const lines = props.headline.filter((l) => l.trim()).slice(0, 4);
|
|
107
|
+
const parsed = lines.map((line) => splitHighlights(line));
|
|
108
|
+
const longest = Math.max(1, ...lines.map((l) => l.replace(/\*/g, "").length));
|
|
109
|
+
const fs = Math.min(m * (vertical ? 0.13 : 0.12), (w * (vertical ? 0.86 : 0.7)) / (longest * 0.66 + 1));
|
|
110
|
+
const headH = lines.length * fs * 1.45;
|
|
111
|
+
const wordCount = parsed.reduce((n, l) => n + l.length, 0);
|
|
112
|
+
|
|
113
|
+
// ---- Schedule (in frames; compared against held time) ----
|
|
114
|
+
const step = holdLen;
|
|
115
|
+
schedule("news1", 0, 0);
|
|
116
|
+
schedule("block", 0, 2);
|
|
117
|
+
schedule("wedge", step, 3);
|
|
118
|
+
schedule("stripes", step * 2, 2);
|
|
119
|
+
schedule("sun", step * 3, 6);
|
|
120
|
+
schedule("star", step * 4, 10);
|
|
121
|
+
schedule("photo3", step * 5, 6);
|
|
122
|
+
schedule("news2", step * 2, 0);
|
|
123
|
+
const kickAt = Math.max(step * 5, d * 0.12);
|
|
124
|
+
schedule("kicker", kickAt, 6);
|
|
125
|
+
const wordsFrom = kickAt + step;
|
|
126
|
+
const wordsTo = Math.max(wordsFrom + step * wordCount, d * 0.48);
|
|
127
|
+
const wordGap = Math.max(step, (wordsTo - wordsFrom) / Math.max(1, wordCount));
|
|
128
|
+
let wi = 0;
|
|
129
|
+
parsed.forEach((line, li) =>
|
|
130
|
+
line.forEach((word, i) => {
|
|
131
|
+
const at = wordsFrom + wordGap * wi++;
|
|
132
|
+
schedule(`w${li}-${i}`, at, 7);
|
|
133
|
+
// Emphasized words are cut letter by letter: each letter is slapped on half a beat apart.
|
|
134
|
+
if (word.highlighted) [...word.text].forEach((_, ci) => schedule(`w${li}-${i}-${ci}`, at + Math.floor(ci / 2) * step, 9));
|
|
135
|
+
}),
|
|
136
|
+
);
|
|
137
|
+
const afterWords = wordsFrom + wordGap * wordCount;
|
|
138
|
+
schedule("hand", afterWords, 8);
|
|
139
|
+
schedule("bubble", afterWords + step * 2, 8);
|
|
140
|
+
schedule("scribble", afterWords + step, 0);
|
|
141
|
+
schedule("circle", afterWords + step * 3, 0);
|
|
142
|
+
schedule("doodles", afterWords + step * 4, 0);
|
|
143
|
+
|
|
144
|
+
const images = props.images.map((s) => s.trim()).filter(Boolean).slice(0, 3);
|
|
145
|
+
const scrapBgs = ["#fbf8f1", props.ink, props.accent, props.accent2, "#d9ccb0", "#ffffff"];
|
|
146
|
+
|
|
147
|
+
// ---- Torn shapes ----
|
|
148
|
+
const tornPoly = (pts: Pt[], amp: number, stepPx: number, key: string) => jag(pts, amp, stepPx, `${seed}-${key}`);
|
|
149
|
+
const t = (p: Placed, cx: number, cy: number) =>
|
|
150
|
+
p ? `translate(${r2(cx + p.x)} ${r2(cy + p.y)}) rotate(${p.r}) scale(${p.s}) translate(${r2(-cx)} ${r2(-cy)})` : undefined;
|
|
151
|
+
|
|
152
|
+
// Back layer: newsprint, blocks, wedge, stripes, sun, starburst.
|
|
153
|
+
const news1 = place("news1");
|
|
154
|
+
const news2 = place("news2");
|
|
155
|
+
const block = place("block");
|
|
156
|
+
const wedge = place("wedge");
|
|
157
|
+
const stripes = place("stripes");
|
|
158
|
+
const sun = place("sun");
|
|
159
|
+
const star = place("star");
|
|
160
|
+
const photo3 = place("photo3");
|
|
161
|
+
|
|
162
|
+
const blockW = Math.min(w * 0.9, Math.max(w * 0.5, longest * fs * 0.62 + fs * 2));
|
|
163
|
+
const blockH = headH + fs * 1.6;
|
|
164
|
+
const blockPts = tornPoly(
|
|
165
|
+
[
|
|
166
|
+
[w / 2 - blockW / 2, L.cy - blockH / 2],
|
|
167
|
+
[w / 2 + blockW / 2, L.cy - blockH / 2],
|
|
168
|
+
[w / 2 + blockW / 2, L.cy + blockH / 2],
|
|
169
|
+
[w / 2 - blockW / 2, L.cy + blockH / 2],
|
|
170
|
+
],
|
|
171
|
+
6 * u,
|
|
172
|
+
14 * u,
|
|
173
|
+
"block",
|
|
174
|
+
);
|
|
175
|
+
const wedgePts = tornPoly(
|
|
176
|
+
vertical
|
|
177
|
+
? [[w * 0.45, -20], [w + 20, -20], [w + 20, h * 0.42]]
|
|
178
|
+
: [[w * 0.56, -20], [w + 20, -20], [w + 20, h * 0.8]],
|
|
179
|
+
7 * u,
|
|
180
|
+
18 * u,
|
|
181
|
+
"wedge",
|
|
182
|
+
);
|
|
183
|
+
const stripeLen = w * 1.3;
|
|
184
|
+
const stripeH = m * 0.05;
|
|
185
|
+
const newsPts = (cx: number, cy: number, bw: number, bh: number, key: string) =>
|
|
186
|
+
tornPoly(
|
|
187
|
+
[
|
|
188
|
+
[cx - bw / 2, cy - bh / 2],
|
|
189
|
+
[cx + bw / 2, cy - bh / 2],
|
|
190
|
+
[cx + bw / 2, cy + bh / 2],
|
|
191
|
+
[cx - bw / 2, cy + bh / 2],
|
|
192
|
+
],
|
|
193
|
+
5 * u,
|
|
194
|
+
12 * u,
|
|
195
|
+
key,
|
|
196
|
+
);
|
|
197
|
+
const n1 = vertical ? ([w * 0.3, h * 0.33, w * 0.52, h * 0.22] as const) : ([w * 0.24, h * 0.36, w * 0.3, h * 0.42] as const);
|
|
198
|
+
const n2 = vertical ? ([w * 0.7, h * 0.62, w * 0.5, h * 0.2] as const) : ([w * 0.7, h * 0.66, w * 0.3, h * 0.36] as const);
|
|
199
|
+
|
|
200
|
+
const starPts: Pt[] = Array.from({ length: 28 }, (_, i) => {
|
|
201
|
+
const a = (i / 28) * Math.PI * 2;
|
|
202
|
+
const rr = (i % 2 === 0 ? 1 : 0.62) * L.star[2];
|
|
203
|
+
return [L.star[0] + Math.cos(a) * rr, L.star[1] + Math.sin(a) * rr];
|
|
204
|
+
});
|
|
205
|
+
const starTurn = (hold % 24) * 3.75;
|
|
206
|
+
|
|
207
|
+
const scissor = Math.max(2, 3.5 * u);
|
|
208
|
+
const dot = Math.max(4, 9 * u);
|
|
209
|
+
|
|
210
|
+
const back = (
|
|
211
|
+
<svg width={w} height={h} style={{ position: "absolute", inset: 0 }}>
|
|
212
|
+
<defs>
|
|
213
|
+
<filter id={`${id}-fibre`} x="0" y="0" width="100%" height="100%">
|
|
214
|
+
<feTurbulence type="fractalNoise" baseFrequency={r2(0.006 / u)} numOctaves={3} seed={seed % 97} />
|
|
215
|
+
<feColorMatrix values="0 0 0 0 0.45 0 0 0 0 0.33 0 0 0 0 0.18 0 0 0 0.9 -0.32" />
|
|
216
|
+
</filter>
|
|
217
|
+
<pattern id={`${id}-lines`} width={r2(40 * u)} height={r2(7 * u)} patternUnits="userSpaceOnUse">
|
|
218
|
+
<rect width={r2(36 * u)} height={r2(2.2 * u)} y={r2(2 * u)} fill={props.ink} opacity={0.42} />
|
|
219
|
+
</pattern>
|
|
220
|
+
<pattern id={`${id}-dots`} width={r2(dot)} height={r2(dot)} patternUnits="userSpaceOnUse" patternTransform="rotate(30)">
|
|
221
|
+
<circle cx={r2(dot / 2)} cy={r2(dot / 2)} r={r2(dot * 0.36)} fill={props.ink} />
|
|
222
|
+
</pattern>
|
|
223
|
+
<pattern id={`${id}-dots-s`} width={r2(dot * 0.7)} height={r2(dot * 0.7)} patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
|
|
224
|
+
<circle cx={r2(dot * 0.35)} cy={r2(dot * 0.35)} r={r2(dot * 0.16)} fill={props.ink} />
|
|
225
|
+
</pattern>
|
|
226
|
+
<linearGradient id={`${id}-fade`} x1="0" y1="0" x2="1" y2="1">
|
|
227
|
+
<stop offset="0%" stopColor="#ffffff" stopOpacity={0} />
|
|
228
|
+
<stop offset="100%" stopColor="#ffffff" stopOpacity={1} />
|
|
229
|
+
</linearGradient>
|
|
230
|
+
<mask id={`${id}-sunmask`}>
|
|
231
|
+
<circle cx={r2(L.sun[0])} cy={r2(L.sun[1])} r={r2(L.sun[2])} fill={`url(#${id}-fade)`} />
|
|
232
|
+
</mask>
|
|
233
|
+
<radialGradient id={`${id}-age`} cx="50%" cy="50%" r="72%">
|
|
234
|
+
<stop offset="60%" stopColor="#5b3a12" stopOpacity={0} />
|
|
235
|
+
<stop offset="100%" stopColor="#5b3a12" stopOpacity={0.28} />
|
|
236
|
+
</radialGradient>
|
|
237
|
+
</defs>
|
|
238
|
+
|
|
239
|
+
{/* Paper: newsprint color, fibres and aged edges. */}
|
|
240
|
+
<rect width={w} height={h} fill={props.paper} />
|
|
241
|
+
<rect width={w} height={h} filter={`url(#${id}-fibre)`} opacity={0.5} />
|
|
242
|
+
<rect width={w} height={h} fill={`url(#${id}-age)`} />
|
|
243
|
+
|
|
244
|
+
{/* Torn newspaper scraps: columns of "text" with a heading bar. */}
|
|
245
|
+
{[
|
|
246
|
+
[news1, n1, "n1"],
|
|
247
|
+
[news2, n2, "n2"],
|
|
248
|
+
].map(([p, n, key]) => {
|
|
249
|
+
const pl = p as Placed;
|
|
250
|
+
const [cx, cy, bw, bh] = n as readonly [number, number, number, number];
|
|
251
|
+
if (!pl) return null;
|
|
252
|
+
const pts = newsPts(cx, cy, bw, bh, key as string);
|
|
253
|
+
return (
|
|
254
|
+
<g key={key as string} transform={t(pl, cx, cy)}>
|
|
255
|
+
<polygon points={svgPts(pts)} fill="#e4dac4" />
|
|
256
|
+
<polygon points={svgPts(pts)} fill={`url(#${id}-lines)`} opacity={0.5} />
|
|
257
|
+
<rect x={r2(cx - bw * 0.42)} y={r2(cy - bh * 0.4)} width={r2(bw * 0.6)} height={r2(bh * 0.09)} fill={props.ink} opacity={0.75} />
|
|
258
|
+
</g>
|
|
259
|
+
);
|
|
260
|
+
})}
|
|
261
|
+
|
|
262
|
+
{/* The constructivist wedge. */}
|
|
263
|
+
{wedge ? (
|
|
264
|
+
<g transform={t(wedge, w * 0.85, h * 0.2)}>
|
|
265
|
+
<polygon points={svgPts(wedgePts)} fill={props.accent} />
|
|
266
|
+
<polygon points={svgPts(wedgePts)} fill={`url(#${id}-dots-s)`} opacity={0.22} />
|
|
267
|
+
</g>
|
|
268
|
+
) : null}
|
|
269
|
+
|
|
270
|
+
{/* Stripes band across the bottom, torn at the ends. */}
|
|
271
|
+
{stripes ? (
|
|
272
|
+
<g transform={`${t(stripes, w / 2, L.stripesY) ?? ""} rotate(-7 ${r2(w / 2)} ${r2(L.stripesY)})`}>
|
|
273
|
+
{[props.ink, props.accent2, props.ink, props.paper].map((c, i) => (
|
|
274
|
+
<polygon
|
|
275
|
+
key={i}
|
|
276
|
+
points={svgPts(
|
|
277
|
+
tornPoly(
|
|
278
|
+
[
|
|
279
|
+
[w / 2 - stripeLen / 2, L.stripesY + (i - 2) * stripeH],
|
|
280
|
+
[w / 2 + stripeLen / 2, L.stripesY + (i - 2) * stripeH],
|
|
281
|
+
[w / 2 + stripeLen / 2, L.stripesY + (i - 1) * stripeH],
|
|
282
|
+
[w / 2 - stripeLen / 2, L.stripesY + (i - 1) * stripeH],
|
|
283
|
+
],
|
|
284
|
+
2.5 * u,
|
|
285
|
+
16 * u,
|
|
286
|
+
`st${i}`,
|
|
287
|
+
),
|
|
288
|
+
)}
|
|
289
|
+
fill={c}
|
|
290
|
+
/>
|
|
291
|
+
))}
|
|
292
|
+
</g>
|
|
293
|
+
) : null}
|
|
294
|
+
|
|
295
|
+
{/* The color block behind the headline. */}
|
|
296
|
+
{block ? (
|
|
297
|
+
<g transform={t(block, w / 2, L.cy)}>
|
|
298
|
+
<g transform={`rotate(-3 ${r2(w / 2)} ${r2(L.cy)})`}>
|
|
299
|
+
<polygon points={svgPts(blockPts)} fill={props.accent2} />
|
|
300
|
+
<polygon points={svgPts(blockPts)} fill={`url(#${id}-dots-s)`} opacity={0.16} />
|
|
301
|
+
</g>
|
|
302
|
+
</g>
|
|
303
|
+
) : null}
|
|
304
|
+
|
|
305
|
+
{/* The halftone sun, cut out with a white scissor edge. */}
|
|
306
|
+
{sun && !images[0] ? (
|
|
307
|
+
<g transform={t(sun, L.sun[0], L.sun[1])}>
|
|
308
|
+
<circle cx={r2(L.sun[0])} cy={r2(L.sun[1])} r={r2(L.sun[2])} fill={props.accent2} stroke="#ffffff" strokeWidth={r2(scissor * 2)} />
|
|
309
|
+
<rect
|
|
310
|
+
x={r2(L.sun[0] - L.sun[2])}
|
|
311
|
+
y={r2(L.sun[1] - L.sun[2])}
|
|
312
|
+
width={r2(L.sun[2] * 2)}
|
|
313
|
+
height={r2(L.sun[2] * 2)}
|
|
314
|
+
fill={`url(#${id}-dots)`}
|
|
315
|
+
mask={`url(#${id}-sunmask)`}
|
|
316
|
+
/>
|
|
317
|
+
</g>
|
|
318
|
+
) : null}
|
|
319
|
+
|
|
320
|
+
{/* The starburst, turning in hand-placed steps. */}
|
|
321
|
+
{star && !images[1] ? (
|
|
322
|
+
<g transform={`${t(star, L.star[0], L.star[1])} rotate(${r2(starTurn)} ${r2(L.star[0])} ${r2(L.star[1])})`}>
|
|
323
|
+
<polygon points={svgPts(starPts)} fill={props.accent} stroke="#ffffff" strokeWidth={r2(scissor * 2)} strokeLinejoin="round" />
|
|
324
|
+
<circle cx={r2(L.star[0])} cy={r2(L.star[1])} r={r2(L.star[2] * 0.38)} fill={props.paper} />
|
|
325
|
+
<circle cx={r2(L.star[0])} cy={r2(L.star[1])} r={r2(L.star[2] * 0.38)} fill={`url(#${id}-dots-s)`} opacity={0.4} />
|
|
326
|
+
</g>
|
|
327
|
+
) : null}
|
|
328
|
+
</svg>
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
// Photo scraps (optional images) take the sun, starburst and a third slot.
|
|
332
|
+
const photoSlots = [
|
|
333
|
+
{ key: "sun", at: L.sun, p: sun, rot: 5 },
|
|
334
|
+
{ key: "star", at: L.star, p: star, rot: -7 },
|
|
335
|
+
{ key: "photo3", at: L.photo3, p: photo3, rot: 4 },
|
|
336
|
+
];
|
|
337
|
+
const photos = images.map((src, i) => {
|
|
338
|
+
const slot = photoSlots[i];
|
|
339
|
+
if (!slot.p) return null;
|
|
340
|
+
const pw = slot.at[2] * (i === 1 ? 2.1 : 1.7);
|
|
341
|
+
const ph = pw * 1.2;
|
|
342
|
+
const clip = cssPoly(
|
|
343
|
+
tornPoly([[3, 3], [pw - 3, 3], [pw - 3, ph - 3], [3, ph - 3]], 4 * u, 12 * u, `ph${i}`),
|
|
344
|
+
pw,
|
|
345
|
+
ph,
|
|
346
|
+
);
|
|
347
|
+
return (
|
|
348
|
+
<div
|
|
349
|
+
key={i}
|
|
350
|
+
style={{
|
|
351
|
+
position: "absolute",
|
|
352
|
+
left: r2(slot.at[0] - pw / 2 + slot.p.x),
|
|
353
|
+
top: r2(slot.at[1] - ph / 2 + slot.p.y),
|
|
354
|
+
width: r2(pw),
|
|
355
|
+
height: r2(ph),
|
|
356
|
+
transform: `rotate(${r2(slot.rot + slot.p.r)}deg) scale(${slot.p.s})`,
|
|
357
|
+
}}
|
|
358
|
+
>
|
|
359
|
+
<div style={{ position: "absolute", inset: 0, transform: `translate(${r2(5 * u)}px, ${r2(7 * u)}px)`, background: "rgba(0, 0, 0, 0.28)", clipPath: clip }} />
|
|
360
|
+
<div style={{ position: "absolute", inset: 0, background: "#ffffff", clipPath: clip }} />
|
|
361
|
+
<div style={{ position: "absolute", inset: r2(scissor * 2.2), overflow: "hidden", clipPath: clip }}>
|
|
362
|
+
<Img src={src} crossOrigin="anonymous" style={{ width: "100%", height: "100%", objectFit: "cover" }} />
|
|
363
|
+
<svg width="100%" height="100%" style={{ position: "absolute", inset: 0 }}>
|
|
364
|
+
<defs>
|
|
365
|
+
<pattern id={`${id}-pd${i}`} width={r2(dot * 0.6)} height={r2(dot * 0.6)} patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
|
|
366
|
+
<circle cx={r2(dot * 0.3)} cy={r2(dot * 0.3)} r={r2(dot * 0.14)} fill={props.ink} />
|
|
367
|
+
</pattern>
|
|
368
|
+
</defs>
|
|
369
|
+
<rect width="100%" height="100%" fill={`url(#${id}-pd${i})`} opacity={0.3} />
|
|
370
|
+
</svg>
|
|
371
|
+
</div>
|
|
372
|
+
</div>
|
|
373
|
+
);
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
// ---- Headline layer (HTML) ----
|
|
377
|
+
const scrap = (text: string, key: string, size: number, emphasized: boolean): ReactNode => {
|
|
378
|
+
const p = place(key);
|
|
379
|
+
const rs = (k: string) => random(`${seed}-${key}-${k}`);
|
|
380
|
+
const style = WORD_FONTS[Math.floor(rs("f") * WORD_FONTS.length)];
|
|
381
|
+
const bg = emphasized ? (rs("e") > 0.5 ? props.accent : props.ink) : scrapBgs[Math.floor(rs("b") * scrapBgs.length)];
|
|
382
|
+
const fg = bg === props.ink ? (emphasized ? props.accent2 : props.paper) : bg === props.accent ? onColor(props.accent) : props.ink;
|
|
383
|
+
const label = style.upper ? text.toUpperCase() : text;
|
|
384
|
+
const estW = Math.max(1, label.length * style.w * size + size * 0.7);
|
|
385
|
+
const estH = size * 1.35;
|
|
386
|
+
const amp = size * 0.06;
|
|
387
|
+
const outer = cssPoly(tornPoly([[amp, amp], [estW - amp, amp], [estW - amp, estH - amp], [amp, estH - amp]], amp, size * 0.14, `${key}o`), estW, estH);
|
|
388
|
+
const inner = cssPoly(tornPoly([[amp, amp], [estW - amp, amp], [estW - amp, estH - amp], [amp, estH - amp]], amp * 0.8, size * 0.12, `${key}i`), estW, estH);
|
|
389
|
+
const baseRot = (rs("r") - 0.5) * 12;
|
|
390
|
+
const lift = (rs("y") - 0.5) * size * 0.16;
|
|
391
|
+
const scrapStyle: CSSProperties = {
|
|
392
|
+
position: "relative",
|
|
393
|
+
display: "inline-block",
|
|
394
|
+
opacity: p ? 1 : 0,
|
|
395
|
+
transform: p
|
|
396
|
+
? `translate(${p.x}px, ${r2(p.y + lift)}px) rotate(${r2(baseRot + p.r)}deg) scale(${p.s})`
|
|
397
|
+
: `translateY(${r2(lift)}px) rotate(${r2(baseRot)}deg)`,
|
|
398
|
+
margin: `0 ${r2(size * 0.04)}px`,
|
|
399
|
+
};
|
|
400
|
+
return (
|
|
401
|
+
<div key={key} style={scrapStyle}>
|
|
402
|
+
<div style={{ position: "absolute", inset: 0, transform: `translate(${r2(4 * u)}px, ${r2(6 * u)}px)`, background: "rgba(0, 0, 0, 0.3)", clipPath: outer }} />
|
|
403
|
+
<div style={{ position: "relative", background: "#ffffff", clipPath: outer, padding: r2(scissor) }}>
|
|
404
|
+
<div
|
|
405
|
+
style={{
|
|
406
|
+
background: bg,
|
|
407
|
+
clipPath: inner,
|
|
408
|
+
color: fg,
|
|
409
|
+
fontFamily: FONTS[style.font],
|
|
410
|
+
fontWeight: style.weight,
|
|
411
|
+
fontStyle: style.font === "serif" && rs("i") > 0.5 ? "italic" : undefined,
|
|
412
|
+
fontSize: r2(size),
|
|
413
|
+
lineHeight: 1.12,
|
|
414
|
+
padding: `${r2(size * 0.08)}px ${r2(size * 0.24)}px`,
|
|
415
|
+
whiteSpace: "nowrap",
|
|
416
|
+
letterSpacing: style.font === "mono" ? "0.02em" : "-0.01em",
|
|
417
|
+
}}
|
|
418
|
+
>
|
|
419
|
+
{label}
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
</div>
|
|
423
|
+
);
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
const kick = place("kicker");
|
|
427
|
+
const headline = (
|
|
428
|
+
<AbsoluteFill style={{ alignItems: "center", justifyContent: "center" }}>
|
|
429
|
+
<div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: r2(fs * 0.12), transform: `translateY(${r2(L.cy - h / 2)}px)` }}>
|
|
430
|
+
{props.kicker ? (
|
|
431
|
+
<div
|
|
432
|
+
style={{
|
|
433
|
+
position: "relative",
|
|
434
|
+
alignSelf: vertical ? "center" : "flex-start",
|
|
435
|
+
marginBottom: r2(fs * 0.15),
|
|
436
|
+
opacity: kick ? 1 : 0,
|
|
437
|
+
transform: `translate(${kick?.x ?? 0}px, ${kick?.y ?? 0}px) rotate(${r2(-3 + (kick?.r ?? 0))}deg) scale(${kick?.s ?? 1})`,
|
|
438
|
+
}}
|
|
439
|
+
>
|
|
440
|
+
<div
|
|
441
|
+
style={{
|
|
442
|
+
background: "#fbf8f1",
|
|
443
|
+
color: props.ink,
|
|
444
|
+
fontFamily: FONTS.mono,
|
|
445
|
+
fontWeight: 600,
|
|
446
|
+
fontSize: r2(Math.max(14, fs * 0.26)),
|
|
447
|
+
letterSpacing: "0.16em",
|
|
448
|
+
textTransform: "uppercase",
|
|
449
|
+
padding: `${r2(fs * 0.08)}px ${r2(fs * 0.2)}px`,
|
|
450
|
+
boxShadow: `${r2(3 * u)}px ${r2(4 * u)}px 0 rgba(0, 0, 0, 0.22)`,
|
|
451
|
+
}}
|
|
452
|
+
>
|
|
453
|
+
{props.kicker}
|
|
454
|
+
</div>
|
|
455
|
+
<Tape left={-fs * 0.22} top={-fs * 0.12} w={fs * 0.6} h={fs * 0.2} rot={-28} />
|
|
456
|
+
<Tape right={-fs * 0.22} top={-fs * 0.1} w={fs * 0.6} h={fs * 0.2} rot={24} />
|
|
457
|
+
</div>
|
|
458
|
+
) : null}
|
|
459
|
+
{parsed.map((line, li) => (
|
|
460
|
+
<div key={li} style={{ display: "flex", flexWrap: "wrap", justifyContent: "center", alignItems: "center", rowGap: r2(fs * 0.1) }}>
|
|
461
|
+
{line.map((word, i) => {
|
|
462
|
+
const key = `w${li}-${i}`;
|
|
463
|
+
if (!word.highlighted) return scrap(word.text, key, fs, false);
|
|
464
|
+
return (
|
|
465
|
+
<div key={key} style={{ display: "inline-flex", margin: `0 ${r2(fs * 0.08)}px` }}>
|
|
466
|
+
{[...word.text].map((ch, ci) => scrap(ch, `${key}-${ci}`, fs * 1.15, true))}
|
|
467
|
+
</div>
|
|
468
|
+
);
|
|
469
|
+
})}
|
|
470
|
+
</div>
|
|
471
|
+
))}
|
|
472
|
+
</div>
|
|
473
|
+
</AbsoluteFill>
|
|
474
|
+
);
|
|
475
|
+
// ---- Front layer: the pointing hand, the speech bubble, scribbles, doodles ----
|
|
476
|
+
const hand = place("hand");
|
|
477
|
+
const bubble = place("bubble");
|
|
478
|
+
const scribble = place("scribble");
|
|
479
|
+
const circle = place("circle");
|
|
480
|
+
const doodles = place("doodles");
|
|
481
|
+
|
|
482
|
+
// The hand: a sleeve from the bottom-left corner and a pointing hand, puppet-jointed at the wrist.
|
|
483
|
+
const shoulder: Pt = vertical ? [w * -0.04, h * 0.98] : [w * -0.02, h * 1.04];
|
|
484
|
+
const armLen = m * (vertical ? 0.42 : 0.42);
|
|
485
|
+
const armAngle = (vertical ? -48 : -38) + Math.sin(hold * 0.8) * 3;
|
|
486
|
+
const wristAngle = Math.sin(hold * 1.3 + 1) * 9;
|
|
487
|
+
const sleeveW = m * 0.11;
|
|
488
|
+
const handS = m * 0.1;
|
|
489
|
+
|
|
490
|
+
const bubbleOpen = hold % 4 < 2 ? 1 : 1.07;
|
|
491
|
+
const [bx, by, br] = L.bubble;
|
|
492
|
+
const headBottom = L.cy + headH / 2 + fs * 0.25;
|
|
493
|
+
const zig = (() => {
|
|
494
|
+
const x0 = w / 2 - Math.min(w * 0.36, longest * fs * 0.34);
|
|
495
|
+
const x1 = w - x0;
|
|
496
|
+
const n = 9;
|
|
497
|
+
return Array.from({ length: n + 1 }, (_, i) => {
|
|
498
|
+
const x = x0 + ((x1 - x0) * i) / n;
|
|
499
|
+
const y = headBottom + (i % 2 ? fs * 0.12 : -fs * 0.04) + (random(`${seed}-zz${i}`) - 0.5) * fs * 0.06;
|
|
500
|
+
return `${i ? "L" : "M"}${r2(x)} ${r2(y)}`;
|
|
501
|
+
}).join(" ");
|
|
502
|
+
})();
|
|
503
|
+
const loop = (() => {
|
|
504
|
+
const [cx, cy, rr] = images[0] ? [L.sun[0], L.sun[1], L.sun[2] * 1.15] : L.sun;
|
|
505
|
+
const pts: string[] = [];
|
|
506
|
+
for (let i = 0; i <= 40; i++) {
|
|
507
|
+
const a = -1.9 + (i / 40) * Math.PI * 2.25;
|
|
508
|
+
const k = rr * (1.16 + 0.07 * Math.sin(i * 0.9 + seed) + i * 0.002);
|
|
509
|
+
pts.push(`${i ? "L" : "M"}${r2(cx + Math.cos(a) * k * 1.08)} ${r2(cy + Math.sin(a) * k * 0.94)}`);
|
|
510
|
+
}
|
|
511
|
+
return pts.join(" ");
|
|
512
|
+
})();
|
|
513
|
+
const drawOn = (key: string, frames: number) => {
|
|
514
|
+
const p = placements[key];
|
|
515
|
+
const since = Math.max(0, q - p.at);
|
|
516
|
+
return r2(Math.min(1, (since + holdLen) / frames));
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
const front = (
|
|
520
|
+
<svg width={w} height={h} style={{ position: "absolute", inset: 0 }}>
|
|
521
|
+
{hand ? (
|
|
522
|
+
<g transform={`translate(${hand.x} ${hand.y}) rotate(${r2(armAngle)} ${r2(shoulder[0])} ${r2(shoulder[1])})`}>
|
|
523
|
+
{/* Sleeve: striped cut-out. */}
|
|
524
|
+
<rect x={r2(shoulder[0])} y={r2(shoulder[1] - sleeveW / 2)} width={r2(armLen)} height={r2(sleeveW)} fill={props.ink} stroke="#ffffff" strokeWidth={r2(scissor * 2)} />
|
|
525
|
+
{[0.2, 0.45, 0.7].map((f) => (
|
|
526
|
+
<rect key={f} x={r2(shoulder[0] + armLen * f)} y={r2(shoulder[1] - sleeveW / 2)} width={r2(armLen * 0.08)} height={r2(sleeveW)} fill={props.accent} />
|
|
527
|
+
))}
|
|
528
|
+
<rect x={r2(shoulder[0] + armLen - sleeveW * 0.25)} y={r2(shoulder[1] - sleeveW * 0.58)} width={r2(sleeveW * 0.35)} height={r2(sleeveW * 1.16)} fill="#ffffff" />
|
|
529
|
+
{/* Hand, jointed at the wrist. */}
|
|
530
|
+
<g transform={`rotate(${r2(wristAngle)} ${r2(shoulder[0] + armLen)} ${r2(shoulder[1])})`}>
|
|
531
|
+
<g stroke="#ffffff" strokeWidth={r2(scissor * 2)} fill="#f1c9a5" strokeLinejoin="round">
|
|
532
|
+
<rect x={r2(shoulder[0] + armLen + handS * 0.05)} y={r2(shoulder[1] - handS * 0.5)} width={r2(handS * 0.95)} height={r2(handS)} rx={r2(handS * 0.28)} />
|
|
533
|
+
<rect x={r2(shoulder[0] + armLen + handS * 0.6)} y={r2(shoulder[1] - handS * 0.5)} width={r2(handS * 1.15)} height={r2(handS * 0.3)} rx={r2(handS * 0.15)} />
|
|
534
|
+
</g>
|
|
535
|
+
<g stroke={props.ink} strokeWidth={r2(2 * u)} fill="none" opacity={0.6}>
|
|
536
|
+
<path d={`M${r2(shoulder[0] + armLen + handS * 0.35)} ${r2(shoulder[1] - handS * 0.05)} h${r2(handS * 0.55)}`} />
|
|
537
|
+
<path d={`M${r2(shoulder[0] + armLen + handS * 0.35)} ${r2(shoulder[1] + handS * 0.22)} h${r2(handS * 0.5)}`} />
|
|
538
|
+
</g>
|
|
539
|
+
</g>
|
|
540
|
+
</g>
|
|
541
|
+
) : null}
|
|
542
|
+
|
|
543
|
+
{bubble && props.bubble ? (
|
|
544
|
+
<g transform={`${t(bubble, bx, by)} translate(${r2(bx)} ${r2(by)}) scale(${bubbleOpen}) translate(${r2(-bx)} ${r2(-by)})`}>
|
|
545
|
+
<g stroke={props.ink} strokeWidth={r2(3.5 * u)} strokeLinejoin="round">
|
|
546
|
+
<polygon
|
|
547
|
+
points={svgPts([
|
|
548
|
+
[bx - br * 0.55, by + br * 0.45],
|
|
549
|
+
[bx - br * 1.05, by + br * 1.05],
|
|
550
|
+
[bx - br * 0.15, by + br * 0.55],
|
|
551
|
+
])}
|
|
552
|
+
fill="#ffffff"
|
|
553
|
+
/>
|
|
554
|
+
<ellipse cx={r2(bx)} cy={r2(by)} rx={r2(br * 1.25)} ry={r2(br * 0.78)} fill="#ffffff" />
|
|
555
|
+
</g>
|
|
556
|
+
<text
|
|
557
|
+
x={r2(bx)}
|
|
558
|
+
y={r2(by + br * 0.18)}
|
|
559
|
+
textAnchor="middle"
|
|
560
|
+
fontFamily="Impact, 'Arial Black', sans-serif"
|
|
561
|
+
fontSize={r2(Math.min(br * 0.62, (br * 2.1) / Math.max(1, props.bubble.length * 0.55)))}
|
|
562
|
+
fill={props.accent}
|
|
563
|
+
>
|
|
564
|
+
{props.bubble.toUpperCase()}
|
|
565
|
+
</text>
|
|
566
|
+
</g>
|
|
567
|
+
) : null}
|
|
568
|
+
|
|
569
|
+
{scribble ? (
|
|
570
|
+
<path d={zig} fill="none" stroke={props.accent} strokeWidth={r2(6 * u)} strokeLinecap="round" strokeLinejoin="round" pathLength={1} strokeDasharray="1" strokeDashoffset={r2(1 - drawOn("scribble", holdLen * 3))} transform={`translate(${scribble.x} ${scribble.y})`} />
|
|
571
|
+
) : null}
|
|
572
|
+
{circle ? (
|
|
573
|
+
<path d={loop} fill="none" stroke={props.ink} strokeWidth={r2(4.5 * u)} strokeLinecap="round" pathLength={1} strokeDasharray="1" strokeDashoffset={r2(1 - drawOn("circle", holdLen * 3))} transform={`translate(${circle.x} ${circle.y})`} />
|
|
574
|
+
) : null}
|
|
575
|
+
{doodles
|
|
576
|
+
? [0, 1, 2].map((i) => {
|
|
577
|
+
const cx = (vertical ? [0.12, 0.88, 0.5] : [0.33, 0.66, 0.93])[i] * w;
|
|
578
|
+
const cy = (vertical ? [0.32, 0.4, 0.06] : [0.12, 0.1, 0.48])[i] * h;
|
|
579
|
+
const s = m * (0.022 + 0.01 * i);
|
|
580
|
+
const tw = (random(`${seed}-dd${i}-${hold}`) - 0.5) * 18;
|
|
581
|
+
return (
|
|
582
|
+
<g key={i} transform={`rotate(${r2(tw)} ${r2(cx)} ${r2(cy)})`} stroke={i === 1 ? props.accent : props.ink} strokeWidth={r2(3.5 * u)} strokeLinecap="round">
|
|
583
|
+
<path d={`M${r2(cx - s)} ${r2(cy)} H${r2(cx + s)} M${r2(cx)} ${r2(cy - s)} V${r2(cy + s)} M${r2(cx - s * 0.6)} ${r2(cy - s * 0.6)} L${r2(cx + s * 0.6)} ${r2(cy + s * 0.6)} M${r2(cx + s * 0.6)} ${r2(cy - s * 0.6)} L${r2(cx - s * 0.6)} ${r2(cy + s * 0.6)}`} />
|
|
584
|
+
</g>
|
|
585
|
+
);
|
|
586
|
+
})
|
|
587
|
+
: null}
|
|
588
|
+
</svg>
|
|
589
|
+
);
|
|
590
|
+
|
|
591
|
+
// Film grain that changes with every held drawing.
|
|
592
|
+
const grain = (
|
|
593
|
+
<svg width={w} height={h} style={{ position: "absolute", inset: 0 }}>
|
|
594
|
+
<filter id={`${id}-grain`} x="0" y="0" width="100%" height="100%">
|
|
595
|
+
<feTurbulence type="fractalNoise" baseFrequency={0.85} numOctaves={2} seed={(hold % 6) + seed} />
|
|
596
|
+
<feColorMatrix values="0 0 0 0 0.12 0 0 0 0 0.09 0 0 0 0 0.06 0 0 0 1.1 -0.42" />
|
|
597
|
+
</filter>
|
|
598
|
+
<rect width={w} height={h} filter={`url(#${id}-grain)`} opacity={0.55} />
|
|
599
|
+
</svg>
|
|
600
|
+
);
|
|
601
|
+
|
|
602
|
+
return (
|
|
603
|
+
<AbsoluteFill style={{ background: props.paper, opacity: out, overflow: "hidden" }}>
|
|
604
|
+
{back}
|
|
605
|
+
{photos}
|
|
606
|
+
{headline}
|
|
607
|
+
{front}
|
|
608
|
+
{grain}
|
|
609
|
+
</AbsoluteFill>
|
|
610
|
+
);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/** A strip of translucent masking tape. */
|
|
614
|
+
function Tape(props: { left?: number; right?: number; top: number; w: number; h: number; rot: number }) {
|
|
615
|
+
return (
|
|
616
|
+
<div
|
|
617
|
+
style={{
|
|
618
|
+
position: "absolute",
|
|
619
|
+
left: props.left !== undefined ? r2(props.left) : undefined,
|
|
620
|
+
right: props.right !== undefined ? r2(props.right) : undefined,
|
|
621
|
+
top: r2(props.top),
|
|
622
|
+
width: r2(props.w),
|
|
623
|
+
height: r2(props.h),
|
|
624
|
+
background: "rgba(236, 222, 170, 0.78)",
|
|
625
|
+
transform: `rotate(${props.rot}deg)`,
|
|
626
|
+
}}
|
|
627
|
+
/>
|
|
628
|
+
);
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/** A polygon with torn edges: each side broken into short jagged steps (seeded). */
|
|
632
|
+
function jag(pts: Pt[], amp: number, step: number, key: string): Pt[] {
|
|
633
|
+
const out: Pt[] = [];
|
|
634
|
+
for (let i = 0; i < pts.length; i++) {
|
|
635
|
+
const [x1, y1] = pts[i];
|
|
636
|
+
const [x2, y2] = pts[(i + 1) % pts.length];
|
|
637
|
+
const len = Math.hypot(x2 - x1, y2 - y1) || 1;
|
|
638
|
+
const n = Math.max(1, Math.round(len / Math.max(1, step)));
|
|
639
|
+
const nx = -(y2 - y1) / len;
|
|
640
|
+
const ny = (x2 - x1) / len;
|
|
641
|
+
for (let k = 0; k < n; k++) {
|
|
642
|
+
const f = k / n;
|
|
643
|
+
const o = k === 0 ? 0 : (random(`${key}-${i}-${k}`) - 0.5) * 2 * amp;
|
|
644
|
+
out.push([x1 + (x2 - x1) * f + nx * o, y1 + (y2 - y1) * f + ny * o]);
|
|
645
|
+
}
|
|
646
|
+
}
|
|
647
|
+
return out;
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
const svgPts = (p: Pt[]) => p.map(([x, y]) => `${r2(x)},${r2(y)}`).join(" ");
|
|
651
|
+
|
|
652
|
+
/** The same polygon as a CSS clip-path, in % of the element's (estimated) box. */
|
|
653
|
+
const cssPoly = (p: Pt[], w: number, h: number) =>
|
|
654
|
+
`polygon(${p.map(([x, y]) => `${r2(Math.min(100, Math.max(0, (x / w) * 100)))}% ${r2(Math.min(100, Math.max(0, (y / h) * 100)))}%`).join(", ")})`;
|