agentcut 0.0.0-stage → 0.1.1
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 +920 -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,208 @@
|
|
|
1
|
+
// Art-punk cut-paper kit: palette, seeded randomness, stop-motion timing, torn paper, tape, beats.
|
|
2
|
+
// Everything is clip-path polygons + <Img> textures so the browser export draws it.
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Img } from "remotion";
|
|
5
|
+
import { asset } from "agentcut";
|
|
6
|
+
import { BEATS } from "./beats";
|
|
7
|
+
|
|
8
|
+
export const P = {
|
|
9
|
+
paper: "#EFE8D8",
|
|
10
|
+
cream: "#F4ECDC",
|
|
11
|
+
white: "#FBF8F1",
|
|
12
|
+
ink: "#141312",
|
|
13
|
+
red: "#E2332A",
|
|
14
|
+
pink: "#FF4F9A",
|
|
15
|
+
yellow: "#FFD21F",
|
|
16
|
+
orange: "#F07A22",
|
|
17
|
+
teal: "#13A89A",
|
|
18
|
+
green: "#3E9B3A",
|
|
19
|
+
blue: "#2A5FD8",
|
|
20
|
+
kraft: "#C49A6C",
|
|
21
|
+
};
|
|
22
|
+
export const ACCENTS = [P.red, P.pink, P.yellow, P.orange, P.teal, P.blue];
|
|
23
|
+
|
|
24
|
+
// ransom-note faces: [family, size multiplier, uppercase?]
|
|
25
|
+
export const FACES: [string, number, boolean][] = [
|
|
26
|
+
["Anton", 1.0, true],
|
|
27
|
+
["Archivo Black", 0.78, true],
|
|
28
|
+
["Special Elite", 0.86, false],
|
|
29
|
+
["Abril Fatface", 0.88, false],
|
|
30
|
+
["Permanent Marker", 0.82, true],
|
|
31
|
+
["Rubik Mono One", 0.66, true],
|
|
32
|
+
["Courier Prime", 0.86, false],
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
// chip looks: [bg, fg, texture]
|
|
36
|
+
export const CHIPS: [string, string, Tex | null][] = [
|
|
37
|
+
[P.ink, P.white, null],
|
|
38
|
+
[P.white, P.ink, "white"],
|
|
39
|
+
[P.cream, P.ink, "newsprint"],
|
|
40
|
+
[P.yellow, P.ink, null],
|
|
41
|
+
[P.red, P.white, null],
|
|
42
|
+
[P.pink, P.ink, null],
|
|
43
|
+
[P.cream, P.red, "cream"],
|
|
44
|
+
[P.teal, P.white, null],
|
|
45
|
+
[P.kraft, P.ink, "kraft"],
|
|
46
|
+
[P.orange, P.ink, null],
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
// ---------- seeded randomness ----------
|
|
50
|
+
export function rand(seed: number) {
|
|
51
|
+
let a = (Math.floor(seed) * 2654435761) >>> 0;
|
|
52
|
+
return () => {
|
|
53
|
+
a = (a + 0x6d2b79f5) >>> 0;
|
|
54
|
+
let t = a;
|
|
55
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
56
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
57
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export const hash = (a: number, b = 0) => rand(a * 7919 + b * 104729 + 13)();
|
|
61
|
+
export const strSeed = (s: string) => {
|
|
62
|
+
let h = 7;
|
|
63
|
+
for (let i = 0; i < s.length; i++) h = (h * 31 + s.charCodeAt(i)) >>> 0;
|
|
64
|
+
return h % 100000;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// ---------- stop-motion time ----------
|
|
68
|
+
const clamp01 = (x: number) => Math.max(0, Math.min(1, x));
|
|
69
|
+
export const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
|
|
70
|
+
export const easeOut = (t: number) => 1 - Math.pow(1 - t, 3);
|
|
71
|
+
export const easeIn = (t: number) => t * t * t;
|
|
72
|
+
export const backOut = (t: number) => {
|
|
73
|
+
const c = 1.9;
|
|
74
|
+
return 1 + (c + 1) * Math.pow(t - 1, 3) + c * Math.pow(t - 1, 2);
|
|
75
|
+
};
|
|
76
|
+
/** Frame quantised to 12 fps. */
|
|
77
|
+
export const q12 = (f: number) => Math.floor(f / 2.5) * 2.5;
|
|
78
|
+
/** Progress 0..1 from t0 over dur frames, sampled at 12 fps. */
|
|
79
|
+
export function st(f: number, t0: number, dur: number, ease: (t: number) => number = easeOut) {
|
|
80
|
+
return ease(clamp01((q12(f) - t0) / dur));
|
|
81
|
+
}
|
|
82
|
+
/** Hand-placed wobble that changes on 12 fps steps. */
|
|
83
|
+
export function jit(seed: number, f: number, amp = 2) {
|
|
84
|
+
const k = Math.floor(f / 2.5);
|
|
85
|
+
return {
|
|
86
|
+
x: (hash(seed, k) * 2 - 1) * amp,
|
|
87
|
+
y: (hash(seed + 31, k) * 2 - 1) * amp,
|
|
88
|
+
r: (hash(seed + 67, k) * 2 - 1) * amp * 0.25,
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
/** Slap landing with a stepped overshoot. */
|
|
92
|
+
export function slap(f: number, t0: number, s0 = 1.6) {
|
|
93
|
+
if (f < t0) return { s: s0, o: 0 };
|
|
94
|
+
const steps = [s0, 0.9, 1.06, 0.98, 1];
|
|
95
|
+
const i = Math.min(steps.length - 1, Math.floor((f - t0) / 2));
|
|
96
|
+
return { s: steps[i], o: 1 };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ---------- beats (absolute frames) ----------
|
|
100
|
+
export function beatIndex(abs: number) {
|
|
101
|
+
let lo = 0, hi = BEATS.length - 1, ans = -1;
|
|
102
|
+
while (lo <= hi) {
|
|
103
|
+
const m = (lo + hi) >> 1;
|
|
104
|
+
if (BEATS[m] <= abs) { ans = m; lo = m + 1; } else hi = m - 1;
|
|
105
|
+
}
|
|
106
|
+
return ans;
|
|
107
|
+
}
|
|
108
|
+
/** 1 on a strong beat, decaying to 0 over `decay` frames. */
|
|
109
|
+
export function beatPulse(abs: number, decay = 8) {
|
|
110
|
+
const i = beatIndex(abs);
|
|
111
|
+
if (i < 0) return 0;
|
|
112
|
+
const d = abs - BEATS[i];
|
|
113
|
+
return d > decay ? 0 : 1 - d / decay;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// ---------- torn / cut outlines ----------
|
|
117
|
+
export function outline(w: number, h: number, seed: number, kind: "tear" | "cut" = "cut", inset = 0, sides = "trbl") {
|
|
118
|
+
const r = rand(seed);
|
|
119
|
+
const pts: string[] = [];
|
|
120
|
+
const step = kind === "tear" ? 10 : 60;
|
|
121
|
+
const amp = kind === "tear" ? Math.min(6, Math.max(2.5, Math.min(w, h) * 0.03)) : 2.4;
|
|
122
|
+
const edge = (x0: number, y0: number, x1: number, y1: number, nx: number, ny: number, rough: boolean) => {
|
|
123
|
+
const L = Math.hypot(x1 - x0, y1 - y0);
|
|
124
|
+
const n = Math.max(2, Math.min(90, Math.round(L / (kind === "tear" ? step : step + r() * 70))));
|
|
125
|
+
let lf = 0;
|
|
126
|
+
for (let i = 0; i < n; i++) {
|
|
127
|
+
const t = i / n;
|
|
128
|
+
lf = lf * 0.7 + (r() * 2 - 1) * 0.3;
|
|
129
|
+
const d = rough ? inset + amp * (kind === "tear" ? r() * 1.4 + lf * 1.6 : r() * 2 - 0.4) : inset;
|
|
130
|
+
const x = x0 + (x1 - x0) * t + nx * d;
|
|
131
|
+
const y = y0 + (y1 - y0) * t + ny * d;
|
|
132
|
+
pts.push(`${((x / w) * 100).toFixed(2)}% ${((y / h) * 100).toFixed(2)}%`);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
edge(0, 0, w, 0, 0, 1, sides.includes("t"));
|
|
136
|
+
edge(w, 0, w, h, -1, 0, sides.includes("r"));
|
|
137
|
+
edge(w, h, 0, h, 0, -1, sides.includes("b"));
|
|
138
|
+
edge(0, h, 0, 0, 1, 0, sides.includes("l"));
|
|
139
|
+
return `polygon(${pts.join(",")})`;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export type Tex = "cream" | "white" | "newsprint" | "kraft";
|
|
143
|
+
const TEX: Record<Tex, string> = {
|
|
144
|
+
cream: "assets/paper/paper-cream.jpg",
|
|
145
|
+
white: "assets/paper/paper-white.jpg",
|
|
146
|
+
newsprint: "assets/paper/newsprint.jpg",
|
|
147
|
+
kraft: "assets/paper/kraft.jpg",
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
/** A piece of paper: contact shadow, optional white rim, textured face. */
|
|
151
|
+
export function Paper({ w, h, seed = 1, tex = null, color = P.cream, grain = 0.45, kind = "cut", sides = "trbl", rim = 0, rimColor = P.white, shadow = 1, style, children }: {
|
|
152
|
+
w: number; h: number; seed?: number; tex?: Tex | null; color?: string; grain?: number; kind?: "tear" | "cut"; sides?: string;
|
|
153
|
+
rim?: number; rimColor?: string; shadow?: number; style?: React.CSSProperties; children?: React.ReactNode;
|
|
154
|
+
}) {
|
|
155
|
+
const outer = outline(w, h, seed, kind, 0, sides);
|
|
156
|
+
const inner = rim > 0 ? outline(w, h, seed + 101, kind, rim, sides) : outer;
|
|
157
|
+
const tw = Math.max(w, h, 1024);
|
|
158
|
+
const ox = -((seed * 137) % Math.max(1, tw - w));
|
|
159
|
+
const oy = -((seed * 211) % Math.max(1, tw - h));
|
|
160
|
+
return (
|
|
161
|
+
<div style={{ position: "absolute", width: w, height: h, ...style }}>
|
|
162
|
+
{shadow > 0 ? (
|
|
163
|
+
<div style={{ position: "absolute", left: 6 * shadow, top: 10 * shadow, width: w, height: h, background: "rgba(20,12,4,0.42)", clipPath: outer }} />
|
|
164
|
+
) : null}
|
|
165
|
+
{rim > 0 ? <div style={{ position: "absolute", left: 0, top: 0, width: w, height: h, background: rimColor, clipPath: outer }} /> : null}
|
|
166
|
+
<div style={{ position: "absolute", left: 0, top: 0, width: w, height: h, clipPath: inner, overflow: "hidden", background: color }}>
|
|
167
|
+
{tex ? <Img src={asset(TEX[tex])} style={{ position: "absolute", left: ox, top: oy, width: tw, height: tw }} /> : null}
|
|
168
|
+
{!tex && grain > 0 ? <Img src={asset("assets/paper/grain-overlay.png")} style={{ position: "absolute", left: ox, top: oy, width: tw, height: tw, opacity: grain }} /> : null}
|
|
169
|
+
{children}
|
|
170
|
+
</div>
|
|
171
|
+
</div>
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function Tape({ x, y, w = 150, rot = 0, o = 1, seed = 1 }: { x: number; y: number; w?: number; rot?: number; o?: number; seed?: number }) {
|
|
176
|
+
const h = w * 0.25;
|
|
177
|
+
return (
|
|
178
|
+
<Img src={asset("assets/paper/tape.png")}
|
|
179
|
+
style={{ position: "absolute", left: x - w / 2, top: y - h / 2, width: w, height: h, transform: `rotate(${rot}deg) scaleX(${seed % 2 ? -1 : 1})`, opacity: 0.92 * o }} />
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function Halftone({ x, y, size, color = "black", o = 1, rot = 0 }: { x: number; y: number; size: number; color?: "red" | "black" | "yellow"; o?: number; rot?: number }) {
|
|
184
|
+
return <Img src={asset(`assets/paper/halftone-${color}.png`)} style={{ position: "absolute", left: x - size / 2, top: y - size / 2, width: size, height: size, opacity: o, transform: `rotate(${rot}deg)` }} />;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** Layout areas (px) for the two halves of a beat: the words and the picture. */
|
|
188
|
+
export type Side = "left" | "right" | "center";
|
|
189
|
+
export function areas(width: number, height: number, side: Side) {
|
|
190
|
+
const vertical = height > width;
|
|
191
|
+
if (vertical) {
|
|
192
|
+
return {
|
|
193
|
+
text: { x: 60, y: height * 0.5, w: width - 120, h: height * 0.32 },
|
|
194
|
+
pic: { cx: width / 2, cy: height * 0.29, size: Math.min(width * 0.86, height * 0.4) },
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
if (side === "center") {
|
|
198
|
+
return {
|
|
199
|
+
text: { x: width * 0.1, y: height * 0.52, w: width * 0.8, h: height * 0.4 },
|
|
200
|
+
pic: { cx: width / 2, cy: height * 0.3, size: height * 0.5 },
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
const textLeft = side === "left";
|
|
204
|
+
return {
|
|
205
|
+
text: { x: textLeft ? width * 0.05 : width * 0.47, y: height * 0.14, w: width * 0.48, h: height * 0.72 },
|
|
206
|
+
pic: { cx: textLeft ? width * 0.76 : width * 0.25, cy: height * 0.5, size: height * 0.74 },
|
|
207
|
+
};
|
|
208
|
+
}
|