macbetter 0.0.0-stage → 0.1.0-beta.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 +201 -0
- package/README.md +92 -2
- package/dist/components/accessory-tile.d.ts +50 -0
- package/dist/components/accessory-tile.js +46 -0
- package/dist/components/activity-indicator.d.ts +15 -0
- package/dist/components/activity-indicator.js +15 -0
- package/dist/components/alert.d.ts +29 -0
- package/dist/components/alert.js +30 -0
- package/dist/components/artwork.d.ts +44 -0
- package/dist/components/artwork.js +935 -0
- package/dist/components/automation-row.d.ts +24 -0
- package/dist/components/automation-row.js +12 -0
- package/dist/components/avatar.d.ts +33 -0
- package/dist/components/avatar.js +45 -0
- package/dist/components/badge.d.ts +24 -0
- package/dist/components/badge.js +19 -0
- package/dist/components/button.d.ts +20 -0
- package/dist/components/button.js +10 -0
- package/dist/components/calendar.d.ts +30 -0
- package/dist/components/calendar.js +47 -0
- package/dist/components/camera-view.d.ts +40 -0
- package/dist/components/camera-view.js +44 -0
- package/dist/components/card.d.ts +14 -0
- package/dist/components/card.js +21 -0
- package/dist/components/carousel.d.ts +18 -0
- package/dist/components/carousel.js +33 -0
- package/dist/components/checkbox.d.ts +13 -0
- package/dist/components/checkbox.js +16 -0
- package/dist/components/code-field.d.ts +16 -0
- package/dist/components/code-field.js +29 -0
- package/dist/components/color-well.d.ts +23 -0
- package/dist/components/color-well.js +27 -0
- package/dist/components/combo-box.d.ts +42 -0
- package/dist/components/combo-box.js +102 -0
- package/dist/components/command-palette.d.ts +33 -0
- package/dist/components/command-palette.js +55 -0
- package/dist/components/context-menu.d.ts +9 -0
- package/dist/components/context-menu.js +15 -0
- package/dist/components/date-picker.d.ts +53 -0
- package/dist/components/date-picker.js +86 -0
- package/dist/components/device-frame.d.ts +18 -0
- package/dist/components/device-frame.js +16 -0
- package/dist/components/dialog.d.ts +27 -0
- package/dist/components/dialog.js +35 -0
- package/dist/components/disclosure.d.ts +32 -0
- package/dist/components/disclosure.js +35 -0
- package/dist/components/dock.d.ts +28 -0
- package/dist/components/dock.js +80 -0
- package/dist/components/door-control.d.ts +20 -0
- package/dist/components/door-control.js +43 -0
- package/dist/components/energy-readout.d.ts +32 -0
- package/dist/components/energy-readout.js +27 -0
- package/dist/components/field.d.ts +28 -0
- package/dist/components/field.js +32 -0
- package/dist/components/gauge.d.ts +25 -0
- package/dist/components/gauge.js +42 -0
- package/dist/components/glass.d.ts +34 -0
- package/dist/components/glass.js +31 -0
- package/dist/components/home-backdrop.d.ts +23 -0
- package/dist/components/home-backdrop.js +12 -0
- package/dist/components/home-section.d.ts +19 -0
- package/dist/components/home-section.js +21 -0
- package/dist/components/home-status.d.ts +24 -0
- package/dist/components/home-status.js +14 -0
- package/dist/components/hover-card.d.ts +14 -0
- package/dist/components/hover-card.js +16 -0
- package/dist/components/level-control.d.ts +19 -0
- package/dist/components/level-control.js +13 -0
- package/dist/components/light-color-picker.d.ts +33 -0
- package/dist/components/light-color-picker.js +56 -0
- package/dist/components/list.d.ts +42 -0
- package/dist/components/list.js +42 -0
- package/dist/components/listbox.d.ts +16 -0
- package/dist/components/listbox.js +28 -0
- package/dist/components/lock-control.d.ts +20 -0
- package/dist/components/lock-control.js +35 -0
- package/dist/components/menu-bar.d.ts +14 -0
- package/dist/components/menu-bar.js +16 -0
- package/dist/components/menu.d.ts +40 -0
- package/dist/components/menu.js +54 -0
- package/dist/components/navigation-bar.d.ts +24 -0
- package/dist/components/navigation-bar.js +54 -0
- package/dist/components/outline.d.ts +21 -0
- package/dist/components/outline.js +40 -0
- package/dist/components/page-control.d.ts +10 -0
- package/dist/components/page-control.js +8 -0
- package/dist/components/popover.d.ts +16 -0
- package/dist/components/popover.js +24 -0
- package/dist/components/progress.d.ts +27 -0
- package/dist/components/progress.js +27 -0
- package/dist/components/radio.d.ts +16 -0
- package/dist/components/radio.js +13 -0
- package/dist/components/rating.d.ts +10 -0
- package/dist/components/rating.js +12 -0
- package/dist/components/scene-tile.d.ts +22 -0
- package/dist/components/scene-tile.js +13 -0
- package/dist/components/scroll-view.d.ts +21 -0
- package/dist/components/scroll-view.js +13 -0
- package/dist/components/search-field.d.ts +16 -0
- package/dist/components/search-field.js +12 -0
- package/dist/components/secure-field.d.ts +23 -0
- package/dist/components/secure-field.js +21 -0
- package/dist/components/segmented-control.d.ts +12 -0
- package/dist/components/segmented-control.js +10 -0
- package/dist/components/select.d.ts +45 -0
- package/dist/components/select.js +79 -0
- package/dist/components/sensor-readout.d.ts +29 -0
- package/dist/components/sensor-readout.js +12 -0
- package/dist/components/separator.d.ts +14 -0
- package/dist/components/separator.js +11 -0
- package/dist/components/setup-code.d.ts +29 -0
- package/dist/components/setup-code.js +47 -0
- package/dist/components/sheet.d.ts +31 -0
- package/dist/components/sheet.js +51 -0
- package/dist/components/sidebar.d.ts +30 -0
- package/dist/components/sidebar.js +26 -0
- package/dist/components/slider.d.ts +27 -0
- package/dist/components/slider.js +43 -0
- package/dist/components/split-view.d.ts +11 -0
- package/dist/components/split-view.js +13 -0
- package/dist/components/squircle.d.ts +41 -0
- package/dist/components/squircle.js +63 -0
- package/dist/components/stepper.d.ts +30 -0
- package/dist/components/stepper.js +28 -0
- package/dist/components/switch.d.ts +10 -0
- package/dist/components/switch.js +10 -0
- package/dist/components/tab-bar.d.ts +20 -0
- package/dist/components/tab-bar.js +17 -0
- package/dist/components/table.d.ts +49 -0
- package/dist/components/table.js +179 -0
- package/dist/components/tabs.d.ts +16 -0
- package/dist/components/tabs.js +19 -0
- package/dist/components/text-area.d.ts +14 -0
- package/dist/components/text-area.js +9 -0
- package/dist/components/text-field.d.ts +26 -0
- package/dist/components/text-field.js +23 -0
- package/dist/components/thermostat-control.d.ts +30 -0
- package/dist/components/thermostat-control.js +139 -0
- package/dist/components/toast.d.ts +30 -0
- package/dist/components/toast.js +114 -0
- package/dist/components/toggle.d.ts +21 -0
- package/dist/components/toggle.js +19 -0
- package/dist/components/token-field.d.ts +31 -0
- package/dist/components/token-field.js +78 -0
- package/dist/components/toolbar.d.ts +27 -0
- package/dist/components/toolbar.js +39 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +18 -0
- package/dist/components/window.d.ts +56 -0
- package/dist/components/window.js +61 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +79 -0
- package/dist/lib/cx.d.ts +9 -0
- package/dist/lib/cx.js +14 -0
- package/dist/lib/derive.d.ts +53 -0
- package/dist/lib/derive.js +255 -0
- package/dist/lib/field-glyphs.d.ts +13 -0
- package/dist/lib/field-glyphs.js +28 -0
- package/dist/lib/menu-glyphs.d.ts +6 -0
- package/dist/lib/menu-glyphs.js +15 -0
- package/dist/lib/platform.d.ts +18 -0
- package/dist/lib/platform.js +17 -0
- package/dist/lib/squircle.d.ts +23 -0
- package/dist/lib/squircle.js +69 -0
- package/dist/lib/theme.d.ts +42 -0
- package/dist/lib/theme.js +62 -0
- package/dist/styles/base.css +115 -0
- package/dist/styles/components/accessory-tile.css +461 -0
- package/dist/styles/components/activity-indicator.css +63 -0
- package/dist/styles/components/alert.css +433 -0
- package/dist/styles/components/artwork.css +380 -0
- package/dist/styles/components/automation-row.css +52 -0
- package/dist/styles/components/avatar.css +230 -0
- package/dist/styles/components/badge.css +204 -0
- package/dist/styles/components/button.css +298 -0
- package/dist/styles/components/calendar.css +287 -0
- package/dist/styles/components/camera-view.css +239 -0
- package/dist/styles/components/card.css +100 -0
- package/dist/styles/components/carousel.css +210 -0
- package/dist/styles/components/checkbox.css +212 -0
- package/dist/styles/components/code-field.css +163 -0
- package/dist/styles/components/color-well.css +452 -0
- package/dist/styles/components/combo-box.css +222 -0
- package/dist/styles/components/command-palette.css +379 -0
- package/dist/styles/components/context-menu.css +43 -0
- package/dist/styles/components/date-picker.css +356 -0
- package/dist/styles/components/device-frame.css +194 -0
- package/dist/styles/components/dialog.css +366 -0
- package/dist/styles/components/disclosure.css +197 -0
- package/dist/styles/components/dock.css +404 -0
- package/dist/styles/components/door-control.css +187 -0
- package/dist/styles/components/energy-readout.css +161 -0
- package/dist/styles/components/field.css +175 -0
- package/dist/styles/components/gauge.css +239 -0
- package/dist/styles/components/glass.css +113 -0
- package/dist/styles/components/home-backdrop.css +81 -0
- package/dist/styles/components/home-section.css +100 -0
- package/dist/styles/components/home-status.css +215 -0
- package/dist/styles/components/hover-card.css +145 -0
- package/dist/styles/components/index.css +75 -0
- package/dist/styles/components/level-control.css +247 -0
- package/dist/styles/components/light-color-picker.css +94 -0
- package/dist/styles/components/list.css +411 -0
- package/dist/styles/components/listbox.css +168 -0
- package/dist/styles/components/lock-control.css +164 -0
- package/dist/styles/components/menu-bar.css +94 -0
- package/dist/styles/components/menu.css +454 -0
- package/dist/styles/components/navigation-bar.css +248 -0
- package/dist/styles/components/outline.css +248 -0
- package/dist/styles/components/page-control.css +127 -0
- package/dist/styles/components/popover.css +186 -0
- package/dist/styles/components/progress.css +228 -0
- package/dist/styles/components/radio.css +281 -0
- package/dist/styles/components/rating.css +122 -0
- package/dist/styles/components/scene-tile.css +295 -0
- package/dist/styles/components/scroll-view.css +195 -0
- package/dist/styles/components/search-field.css +128 -0
- package/dist/styles/components/secure-field.css +189 -0
- package/dist/styles/components/segmented-control.css +183 -0
- package/dist/styles/components/select.css +290 -0
- package/dist/styles/components/sensor-readout.css +231 -0
- package/dist/styles/components/separator.css +62 -0
- package/dist/styles/components/setup-code.css +138 -0
- package/dist/styles/components/sheet.css +345 -0
- package/dist/styles/components/sidebar.css +261 -0
- package/dist/styles/components/slider.css +208 -0
- package/dist/styles/components/split-view.css +75 -0
- package/dist/styles/components/squircle.css +44 -0
- package/dist/styles/components/stepper.css +278 -0
- package/dist/styles/components/switch.css +115 -0
- package/dist/styles/components/tab-bar.css +223 -0
- package/dist/styles/components/table.css +313 -0
- package/dist/styles/components/tabs.css +262 -0
- package/dist/styles/components/text-area.css +94 -0
- package/dist/styles/components/text-field.css +294 -0
- package/dist/styles/components/thermostat-control.css +214 -0
- package/dist/styles/components/toast.css +418 -0
- package/dist/styles/components/toggle.css +312 -0
- package/dist/styles/components/token-field.css +193 -0
- package/dist/styles/components/toolbar.css +370 -0
- package/dist/styles/components/tooltip.css +69 -0
- package/dist/styles/components/window.css +428 -0
- package/dist/styles/index.css +17 -0
- package/dist/styles/materials.css +263 -0
- package/dist/styles/platforms.css +214 -0
- package/dist/styles/themes/ember.css +24 -0
- package/dist/styles/themes/graphite.css +16 -0
- package/dist/styles/themes/nebula.css +16 -0
- package/dist/styles/themes/system.css +28 -0
- package/dist/styles/tokens.css +299 -0
- package/package.json +82 -3
|
@@ -0,0 +1,935 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { join } from "../lib/cx.js";
|
|
4
|
+
const artworkVariants = [
|
|
5
|
+
"aurora",
|
|
6
|
+
"bloom",
|
|
7
|
+
"orbit",
|
|
8
|
+
"strata",
|
|
9
|
+
"prism",
|
|
10
|
+
"halftone",
|
|
11
|
+
"rays",
|
|
12
|
+
"glyph",
|
|
13
|
+
"ribbon",
|
|
14
|
+
"topo",
|
|
15
|
+
"grain",
|
|
16
|
+
"mosaic",
|
|
17
|
+
"wash",
|
|
18
|
+
"horizon",
|
|
19
|
+
"window",
|
|
20
|
+
"lens",
|
|
21
|
+
];
|
|
22
|
+
/** The variants made to sit behind an interface: soft, low in contrast, flat by default. */
|
|
23
|
+
const artworkBackgrounds = ["wash", "horizon", "window", "lens"];
|
|
24
|
+
const artworkTimes = ["dawn", "day", "dusk", "night"];
|
|
25
|
+
const artworkPalettes = [
|
|
26
|
+
"accent",
|
|
27
|
+
"sunset",
|
|
28
|
+
"ocean",
|
|
29
|
+
"forest",
|
|
30
|
+
"berry",
|
|
31
|
+
"citrus",
|
|
32
|
+
"dusk",
|
|
33
|
+
"ember",
|
|
34
|
+
"glacier",
|
|
35
|
+
"candy",
|
|
36
|
+
"mono",
|
|
37
|
+
"dawn",
|
|
38
|
+
"sky",
|
|
39
|
+
"night",
|
|
40
|
+
"amber",
|
|
41
|
+
"water",
|
|
42
|
+
"slate",
|
|
43
|
+
];
|
|
44
|
+
/* ── Deterministic math ───────────────────────────────────────── */
|
|
45
|
+
// Only + − × ÷, % and sqrt are exactly specified in IEEE 754, so the art avoids
|
|
46
|
+
// Math.sin/cos/exp/pow: every engine draws the same path, and hydration matches.
|
|
47
|
+
const PI = 3.141592653589793;
|
|
48
|
+
const TAU = PI * 2;
|
|
49
|
+
function sin(value) {
|
|
50
|
+
let x = value % TAU;
|
|
51
|
+
if (x > PI)
|
|
52
|
+
x -= TAU;
|
|
53
|
+
else if (x < -PI)
|
|
54
|
+
x += TAU;
|
|
55
|
+
if (x > PI / 2)
|
|
56
|
+
x = PI - x;
|
|
57
|
+
else if (x < -PI / 2)
|
|
58
|
+
x = -PI - x;
|
|
59
|
+
const x2 = x * x;
|
|
60
|
+
return x * (1 - (x2 / 6) * (1 - (x2 / 20) * (1 - (x2 / 42) * (1 - (x2 / 72) * (1 - (x2 / 110) * (1 - x2 / 156))))));
|
|
61
|
+
}
|
|
62
|
+
function cos(value) {
|
|
63
|
+
return sin(value + PI / 2);
|
|
64
|
+
}
|
|
65
|
+
const rad = (degrees) => (degrees * PI) / 180;
|
|
66
|
+
const clamp = (value, min = 0, max = 1) => Math.min(max, Math.max(min, value));
|
|
67
|
+
const lerp = (a, b, t) => a + (b - a) * t;
|
|
68
|
+
const smoothstep = (t) => {
|
|
69
|
+
const x = clamp(t);
|
|
70
|
+
return x * x * (3 - 2 * x);
|
|
71
|
+
};
|
|
72
|
+
/** Rounds to a tenth of a unit, which is a tenth of a percent of the picture. */
|
|
73
|
+
function n(value) {
|
|
74
|
+
return Math.round(value * 10) / 10;
|
|
75
|
+
}
|
|
76
|
+
function hash(input) {
|
|
77
|
+
let h = 0x811c9dc5;
|
|
78
|
+
for (let i = 0; i < input.length; i++) {
|
|
79
|
+
h ^= input.charCodeAt(i);
|
|
80
|
+
h = Math.imul(h, 0x01000193);
|
|
81
|
+
}
|
|
82
|
+
h ^= h >>> 16;
|
|
83
|
+
h = Math.imul(h, 0x85ebca6b);
|
|
84
|
+
h ^= h >>> 13;
|
|
85
|
+
h = Math.imul(h, 0xc2b2ae35);
|
|
86
|
+
h ^= h >>> 16;
|
|
87
|
+
return h >>> 0;
|
|
88
|
+
}
|
|
89
|
+
function createRng(seed) {
|
|
90
|
+
let a = seed | 0;
|
|
91
|
+
const next = () => {
|
|
92
|
+
a = (a + 0x6d2b79f5) | 0;
|
|
93
|
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
|
94
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
95
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
96
|
+
};
|
|
97
|
+
const rng = {
|
|
98
|
+
next,
|
|
99
|
+
range: (min, max) => min + (max - min) * next(),
|
|
100
|
+
int: (min, max) => min + Math.floor(next() * (max - min + 1)),
|
|
101
|
+
chance: (p) => next() < p,
|
|
102
|
+
pick: (list) => list[Math.floor(next() * list.length)],
|
|
103
|
+
shuffle: (list) => {
|
|
104
|
+
const out = [...list];
|
|
105
|
+
for (let i = out.length - 1; i > 0; i--) {
|
|
106
|
+
const j = Math.floor(next() * (i + 1));
|
|
107
|
+
[out[i], out[j]] = [out[j], out[i]];
|
|
108
|
+
}
|
|
109
|
+
return out;
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
return rng;
|
|
113
|
+
}
|
|
114
|
+
function polygon(points) {
|
|
115
|
+
return `M${points.map(([x, y]) => `${n(x)} ${n(y)}`).join("L")}Z`;
|
|
116
|
+
}
|
|
117
|
+
/** A Catmull-Rom curve through the points, as cubic Béziers. */
|
|
118
|
+
function smooth(points, closed) {
|
|
119
|
+
const count = points.length;
|
|
120
|
+
const at = (i) => closed ? points[(i + count) % count] : points[clamp(i, 0, count - 1)];
|
|
121
|
+
let d = `M${n(at(0)[0])} ${n(at(0)[1])}`;
|
|
122
|
+
const segments = closed ? count : count - 1;
|
|
123
|
+
for (let i = 0; i < segments; i++) {
|
|
124
|
+
const [p0, p1, p2, p3] = [at(i - 1), at(i), at(i + 1), at(i + 2)];
|
|
125
|
+
const c1 = [p1[0] + (p2[0] - p0[0]) / 6, p1[1] + (p2[1] - p0[1]) / 6];
|
|
126
|
+
const c2 = [p2[0] - (p3[0] - p1[0]) / 6, p2[1] - (p3[1] - p1[1]) / 6];
|
|
127
|
+
d += `C${n(c1[0])} ${n(c1[1])} ${n(c2[0])} ${n(c2[1])} ${n(p2[0])} ${n(p2[1])}`;
|
|
128
|
+
}
|
|
129
|
+
return closed ? `${d}Z` : d;
|
|
130
|
+
}
|
|
131
|
+
/* ── Color ────────────────────────────────────────────────────── */
|
|
132
|
+
const ground = "var(--mb-artwork-ground)";
|
|
133
|
+
const light = "var(--mb-artwork-light)";
|
|
134
|
+
const paper = "var(--mb-artwork-paper)";
|
|
135
|
+
const ink = "var(--mb-artwork-ink)";
|
|
136
|
+
function mix(a, b, percentOfA) {
|
|
137
|
+
const p = Math.round(clamp(percentOfA, 0, 100));
|
|
138
|
+
if (p >= 100)
|
|
139
|
+
return a;
|
|
140
|
+
if (p <= 0)
|
|
141
|
+
return b;
|
|
142
|
+
return `color-mix(in oklch, ${a} ${p}%, ${b})`;
|
|
143
|
+
}
|
|
144
|
+
/** A color along a ramp of stops, `t` from 0 to 1. */
|
|
145
|
+
function ramp(stops, t) {
|
|
146
|
+
const u = clamp(t) * (stops.length - 1);
|
|
147
|
+
const i = Math.min(Math.floor(u), stops.length - 2);
|
|
148
|
+
return mix(stops[i + 1], stops[i], (u - i) * 100);
|
|
149
|
+
}
|
|
150
|
+
function stops(list) {
|
|
151
|
+
return list.map(([offset, color, opacity = 1], i) => (_jsx("stop", { offset: n(offset * 100) / 100, style: { stopColor: color, stopOpacity: opacity } }, i)));
|
|
152
|
+
}
|
|
153
|
+
/** A soft falloff, close to a Gaussian, so blobs have no visible edge. */
|
|
154
|
+
function soft(color, opacity) {
|
|
155
|
+
return [
|
|
156
|
+
[0, color, opacity],
|
|
157
|
+
[0.25, color, opacity * 0.82],
|
|
158
|
+
[0.5, color, opacity * 0.48],
|
|
159
|
+
[0.72, color, opacity * 0.18],
|
|
160
|
+
[0.88, color, opacity * 0.05],
|
|
161
|
+
[1, color, 0],
|
|
162
|
+
];
|
|
163
|
+
}
|
|
164
|
+
function Linear({ x, name, to, list, user }) {
|
|
165
|
+
const [x1, y1, x2, y2] = to;
|
|
166
|
+
return (_jsx("linearGradient", { id: x.id(name), x1: n(x1 * (user ? 1 : 100)) + (user ? "" : "%"), y1: n(y1 * (user ? 1 : 100)) + (user ? "" : "%"), x2: n(x2 * (user ? 1 : 100)) + (user ? "" : "%"), y2: n(y2 * (user ? 1 : 100)) + (user ? "" : "%"), gradientUnits: user ? "userSpaceOnUse" : undefined, children: stops(list) }));
|
|
167
|
+
}
|
|
168
|
+
function Radial({ x, name, list, at, }) {
|
|
169
|
+
return (_jsx("radialGradient", { id: x.id(name), gradientUnits: at ? "userSpaceOnUse" : undefined, cx: at ? n(at.cx) : undefined, cy: at ? n(at.cy) : undefined, r: at ? n(at.r) : undefined, fx: at?.fx !== undefined ? n(at.fx) : undefined, fy: at?.fy !== undefined ? n(at.fy) : undefined, children: stops(list) }));
|
|
170
|
+
}
|
|
171
|
+
function Glow({ x, name, cx, cy, r, color, opacity }) {
|
|
172
|
+
return (_jsxs(_Fragment, { children: [_jsx(Radial, { x: x, name: name, list: soft(color, opacity) }), _jsx("circle", { cx: n(cx), cy: n(cy), r: n(r), fill: x.url(name) })] }));
|
|
173
|
+
}
|
|
174
|
+
function Ground({ x, color }) {
|
|
175
|
+
return _jsx("rect", { width: n(x.w), height: n(x.h), style: { fill: color } });
|
|
176
|
+
}
|
|
177
|
+
/* ── Variants ─────────────────────────────────────────────────── */
|
|
178
|
+
/** Soft blobs of color melting into each other, like a mesh gradient. */
|
|
179
|
+
function aurora(x) {
|
|
180
|
+
const { r, w, h, s } = x;
|
|
181
|
+
const count = r.int(4, 6);
|
|
182
|
+
const start = r.range(0, TAU);
|
|
183
|
+
const blobs = Array.from({ length: count }, (_, i) => {
|
|
184
|
+
const angle = start + (i * TAU) / count + r.range(-0.45, 0.45);
|
|
185
|
+
const distance = r.range(0.16, 0.42);
|
|
186
|
+
const rx = r.range(0.48, 0.74) * s;
|
|
187
|
+
return {
|
|
188
|
+
cx: x.cx + cos(angle) * distance * w,
|
|
189
|
+
cy: x.cy + sin(angle) * distance * h,
|
|
190
|
+
rx,
|
|
191
|
+
ry: rx * r.range(0.55, 0.9),
|
|
192
|
+
rotate: r.range(0, 180),
|
|
193
|
+
color: x.c(i),
|
|
194
|
+
};
|
|
195
|
+
});
|
|
196
|
+
const glow = { cx: x.cx + r.range(-0.28, 0.28) * w, cy: r.range(0.18, 0.45) * h, r: r.range(0.4, 0.55) * s };
|
|
197
|
+
const half = Math.ceil(count / 2);
|
|
198
|
+
const blob = (b, i) => (_jsx("ellipse", { cx: n(b.cx), cy: n(b.cy), rx: n(b.rx), ry: n(b.ry), transform: `rotate(${n(b.rotate)} ${n(b.cx)} ${n(b.cy)})`, fill: x.url(`b${i}`) }, i));
|
|
199
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "base", to: [0, 0, 1, 1], list: [[0, mix(x.c(0), ground, 55)], [1, mix(x.c(1), ground, 30)]] }), blobs.map((b, i) => (_jsx(Radial, { x: x, name: `b${i}`, list: soft(b.color, 0.95) }, i)))] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("base") }), _jsx("g", { className: "mb-artwork-drift", "data-drift": "1", children: blobs.slice(0, half).map(blob) }), _jsx("g", { className: "mb-artwork-drift", "data-drift": "2", children: blobs.slice(half).map((b, i) => blob(b, i + half)) }), _jsx("g", { className: "mb-artwork-drift", "data-drift": "3", children: _jsx(Glow, { x: x, name: "glow", cx: glow.cx, cy: glow.cy, r: glow.r, color: light, opacity: 0.42 }) })] }));
|
|
200
|
+
}
|
|
201
|
+
const bloomAnchors = [
|
|
202
|
+
{ at: [-0.06, 1.06], from: -98, to: 8 },
|
|
203
|
+
{ at: [1.06, 1.06], from: -172, to: -82 },
|
|
204
|
+
{ at: [0.5, 1.18], from: -168, to: -12 },
|
|
205
|
+
{ at: [-0.14, 0.55], from: -72, to: 72 },
|
|
206
|
+
{ at: [1.14, 0.45], from: 108, to: 252 },
|
|
207
|
+
];
|
|
208
|
+
/** Petals fanned out from an edge, shaded like folded silk. */
|
|
209
|
+
function bloom(x) {
|
|
210
|
+
const { r, w, h, s } = x;
|
|
211
|
+
const anchor = r.pick(bloomAnchors);
|
|
212
|
+
const [ax, ay] = [anchor.at[0] * w, anchor.at[1] * h];
|
|
213
|
+
const far = Math.sqrt(w * w + h * h);
|
|
214
|
+
const fan = (count, reach, thickness, tone, prefix) => Array.from({ length: count }, (_, i) => {
|
|
215
|
+
const t = count > 1 ? i / (count - 1) : 0.5;
|
|
216
|
+
const angle = lerp(anchor.from, anchor.to, (i + 0.5) / count) + r.range(-4, 4);
|
|
217
|
+
const length = r.range(reach[0], reach[1]) * far;
|
|
218
|
+
const width = length * r.range(thickness[0], thickness[1]);
|
|
219
|
+
const color = tone(t);
|
|
220
|
+
return { key: `${prefix}${i}`, angle, length, width, color };
|
|
221
|
+
});
|
|
222
|
+
const a = x.c(0);
|
|
223
|
+
const b = x.c(1);
|
|
224
|
+
const outer = fan(r.int(6, 8), [0.82, 1.04], [0.17, 0.23], (t) => mix(mix(b, a, t * 100), light, 100 - t * 22), "p");
|
|
225
|
+
const inner = fan(r.int(3, 5), [0.42, 0.6], [0.2, 0.28], (t) => mix(mix(x.c(2), x.c(3), 100 - t * 100), light, 88 - t * 16), "q");
|
|
226
|
+
const petals = [...outer, ...inner];
|
|
227
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "base", to: [0, 0, 1, 1], list: [[0, mix(b, ground, 30)], [1, ground]] }), petals.map((p) => (_jsx(Linear, { x: x, name: p.key, to: [0, 0, 0, 1], list: [
|
|
228
|
+
[0, mix(p.color, light, 55)],
|
|
229
|
+
[0.3, p.color],
|
|
230
|
+
[0.72, mix(p.color, ground, 82)],
|
|
231
|
+
[1, mix(p.color, ground, 45)],
|
|
232
|
+
] }, p.key)))] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("base") }), _jsx(Glow, { x: x, name: "glow", cx: w - ax * 0.6, cy: h - ay * 0.7, r: s * 0.9, color: x.c(2), opacity: 0.45 }), [outer, inner].map((group, g) => (_jsx("g", { className: "mb-artwork-drift", "data-drift": g === 0 ? "1" : "2", children: group.map((p) => (_jsx("ellipse", { cx: n(ax + p.length / 2), cy: n(ay), rx: n(p.length / 2), ry: n(p.width / 2), transform: `rotate(${n(p.angle)} ${n(ax)} ${n(ay)})`, fill: x.url(p.key) }, p.key))) }, g))), _jsx(Glow, { x: x, name: "core", cx: ax, cy: ay, r: s * 0.5, color: light, opacity: 0.35 })] }));
|
|
233
|
+
}
|
|
234
|
+
/** Concentric rings with bright arcs and a few moons, around a glowing core. */
|
|
235
|
+
function orbit(x) {
|
|
236
|
+
const { r, w, h, s } = x;
|
|
237
|
+
const centered = r.chance(0.55);
|
|
238
|
+
const cx = centered ? x.cx : r.range(0.22, 0.78) * w;
|
|
239
|
+
const cy = centered ? x.cy : r.pick([0.72, 0.8, 0.28]) * h;
|
|
240
|
+
const farthest = Math.sqrt(Math.max(cx, w - cx) ** 2 + Math.max(cy, h - cy) ** 2);
|
|
241
|
+
const core = r.range(0.07, 0.1) * s;
|
|
242
|
+
const rings = [];
|
|
243
|
+
let radius = core * r.range(1.8, 2.3);
|
|
244
|
+
let i = 0;
|
|
245
|
+
while (radius < farthest && rings.length < 14) {
|
|
246
|
+
const arc = r.chance(0.72)
|
|
247
|
+
? {
|
|
248
|
+
width: r.range(0.012, 0.04) * s,
|
|
249
|
+
length: r.range(14, 58),
|
|
250
|
+
start: r.range(0, 360),
|
|
251
|
+
color: x.c(i),
|
|
252
|
+
key: `a${i}`,
|
|
253
|
+
}
|
|
254
|
+
: undefined;
|
|
255
|
+
rings.push({ radius, arc });
|
|
256
|
+
radius += r.range(0.055, 0.105) * s;
|
|
257
|
+
i++;
|
|
258
|
+
}
|
|
259
|
+
const moons = r.shuffle(rings.slice(1, -1)).slice(0, r.int(2, 3)).map((ring, m) => {
|
|
260
|
+
const angle = r.range(0, TAU);
|
|
261
|
+
return {
|
|
262
|
+
key: `m${m}`,
|
|
263
|
+
x: cx + cos(angle) * ring.radius,
|
|
264
|
+
y: cy + sin(angle) * ring.radius,
|
|
265
|
+
radius: r.range(0.012, 0.024) * s,
|
|
266
|
+
};
|
|
267
|
+
});
|
|
268
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Radial, { x: x, name: "base", at: { cx, cy, r: farthest }, list: [[0, mix(x.c(0), ground, 40)], [0.55, mix(x.c(1), ground, 18)], [1, ground]] }), _jsx(Radial, { x: x, name: "core", at: { cx, cy, r: core, fx: cx - core * 0.35, fy: cy - core * 0.4 }, list: [[0, light], [0.45, x.c(0)], [1, mix(x.c(0), ground, 60)]] }), rings.map((ring) => ring.arc ? (_jsx(Linear, { x: x, name: ring.arc.key, to: [0, 0, 1, 1], list: [[0, mix(ring.arc.color, light, 55)], [1, ring.arc.color]] }, ring.arc.key)) : null)] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("base") }), _jsx(Glow, { x: x, name: "halo", cx: cx, cy: cy, r: core * 4.5, color: x.c(0), opacity: 0.55 }), _jsx("g", { fill: "none", style: { stroke: light }, strokeOpacity: 0.16, strokeWidth: n(0.0035 * s), children: rings.map((ring, k) => (_jsx("circle", { cx: n(cx), cy: n(cy), r: n(ring.radius) }, k))) }), _jsx("g", { className: "mb-artwork-drift", "data-drift": "5", fill: "none", strokeLinecap: "round", style: { transformOrigin: `${n(cx)}px ${n(cy)}px` }, children: rings.map((ring, k) => ring.arc ? (_jsx("circle", { cx: n(cx), cy: n(cy), r: n(ring.radius), pathLength: 100, strokeDasharray: `${n(ring.arc.length)} ${n(100 - ring.arc.length)}`, strokeWidth: n(ring.arc.width), stroke: x.url(ring.arc.key), transform: `rotate(${n(ring.arc.start)} ${n(cx)} ${n(cy)})` }, k)) : null) }), moons.map((moon) => (_jsxs(React.Fragment, { children: [_jsx(Glow, { x: x, name: `${moon.key}g`, cx: moon.x, cy: moon.y, r: moon.radius * 5, color: light, opacity: 0.5 }), _jsx("circle", { cx: n(moon.x), cy: n(moon.y), r: n(moon.radius), style: { fill: light } })] }, moon.key))), _jsx("circle", { cx: n(cx), cy: n(cy), r: n(core), fill: x.url("core") })] }));
|
|
269
|
+
}
|
|
270
|
+
/** Layered dunes or hills, hazier toward the horizon. */
|
|
271
|
+
function strata(x) {
|
|
272
|
+
const { r, w, h, s } = x;
|
|
273
|
+
const count = r.int(5, 7);
|
|
274
|
+
const tilt = r.range(-0.14, 0.14);
|
|
275
|
+
const sun = r.chance(0.8) ? { cx: r.range(0.22, 0.78) * w, cy: r.range(0.14, 0.3) * h, r: r.range(0.07, 0.12) * s } : null;
|
|
276
|
+
const tones = [mix(x.c(1), light, 50), x.c(1), x.c(2), mix(x.c(2), ground, 50)];
|
|
277
|
+
const bands = Array.from({ length: count }, (_, i) => {
|
|
278
|
+
const t = i / (count - 1);
|
|
279
|
+
const base = h * (0.4 + 0.5 * t) + r.range(-0.02, 0.02) * h;
|
|
280
|
+
const amplitude = r.range(0.035, 0.07) * h * (1 + t * 0.6);
|
|
281
|
+
const frequency = (r.range(0.5, 1.25) * TAU) / w;
|
|
282
|
+
const phase = r.range(0, TAU);
|
|
283
|
+
const phase2 = r.range(0, TAU);
|
|
284
|
+
const slope = tilt * r.range(0.6, 1.3) * (i % 2 ? 1 : -0.7);
|
|
285
|
+
const points = Array.from({ length: 12 }, (_, k) => {
|
|
286
|
+
const px = -0.06 * w + (k / 11) * 1.12 * w;
|
|
287
|
+
const y = base +
|
|
288
|
+
amplitude * sin(frequency * px + phase) +
|
|
289
|
+
amplitude * 0.3 * sin(frequency * 2.1 * px + phase2) +
|
|
290
|
+
slope * (px - w / 2);
|
|
291
|
+
return [px, y];
|
|
292
|
+
});
|
|
293
|
+
const color = ramp(tones, t);
|
|
294
|
+
const crest = smooth(points, false);
|
|
295
|
+
const last = points[points.length - 1];
|
|
296
|
+
const first = points[0];
|
|
297
|
+
return { key: `s${i}`, crest, fill: `${crest}L${n(last[0])} ${n(h + 2)}L${n(first[0])} ${n(h + 2)}Z`, color };
|
|
298
|
+
});
|
|
299
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "sky", to: [0, 0, 0, 1], list: [[0, mix(x.c(3), light, 70)], [0.5, mix(x.c(0), light, 45)]] }), bands.map((band) => (_jsx(Linear, { x: x, name: band.key, to: [0, 0, 0, 1], list: [
|
|
300
|
+
[0, mix(band.color, light, 82)],
|
|
301
|
+
[0.3, band.color],
|
|
302
|
+
[1, mix(band.color, ground, 60)],
|
|
303
|
+
] }, band.key)))] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("sky") }), sun ? (_jsxs("g", { className: "mb-artwork-drift", "data-drift": "3", children: [_jsx(Glow, { x: x, name: "sunglow", cx: sun.cx, cy: sun.cy, r: sun.r * 3.6, color: light, opacity: 0.6 }), _jsx("circle", { cx: n(sun.cx), cy: n(sun.cy), r: n(sun.r), style: { fill: mix(light, x.c(0), 80) } })] })) : null, bands.map((band) => (_jsxs(React.Fragment, { children: [_jsx("path", { d: band.fill, fill: x.url(band.key) }), _jsx("path", { d: band.crest, fill: "none", style: { stroke: light }, strokeOpacity: 0.24, strokeWidth: n(0.004 * s) })] }, band.key)))] }));
|
|
304
|
+
}
|
|
305
|
+
/** Translucent planes of light crossing each other, like glass in a beam. */
|
|
306
|
+
function prism(x) {
|
|
307
|
+
const { r, w, h, s } = x;
|
|
308
|
+
const base = r.range(0, 180);
|
|
309
|
+
const count = r.int(4, 6);
|
|
310
|
+
const planes = Array.from({ length: count }, (_, i) => {
|
|
311
|
+
const angle = base + r.range(-26, 26);
|
|
312
|
+
const width = r.range(0.2, 0.42) * s;
|
|
313
|
+
const offset = r.range(-0.42, 0.42) * s;
|
|
314
|
+
return { key: `p${i}`, angle, width, offset, from: x.c(i), to: x.c(i + 1 + r.int(0, 2)), opacity: r.range(0.6, 0.92) };
|
|
315
|
+
});
|
|
316
|
+
const length = Math.sqrt(w * w + h * h) * 1.6;
|
|
317
|
+
const shard = r.chance(0.75)
|
|
318
|
+
? [
|
|
319
|
+
[r.range(-0.1, 0.4) * w, r.range(-0.1, 0.3) * h],
|
|
320
|
+
[r.range(0.6, 1.1) * w, r.range(0.2, 0.6) * h],
|
|
321
|
+
[r.range(0.1, 0.7) * w, r.range(0.8, 1.1) * h],
|
|
322
|
+
]
|
|
323
|
+
: null;
|
|
324
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "base", to: [0, 0, 1, 1], list: [[0, mix(x.c(0), ground, 28)], [1, ground]] }), planes.map((p) => (_jsx(Linear, { x: x, name: p.key, to: [0, 0, 0, 1], list: [[0, mix(p.from, light, 85), p.opacity], [0.5, p.from, p.opacity * 0.6], [1, p.to, 0.05]] }, p.key))), _jsx(Linear, { x: x, name: "shard", to: [0, 0, 1, 1], list: [[0, x.c(2), 0.85], [1, x.c(3), 0.08]] })] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("base") }), _jsx(Glow, { x: x, name: "glare", cx: x.cx + r.range(-0.3, 0.3) * w, cy: x.cy + r.range(-0.3, 0.3) * h, r: 0.7 * s, color: x.c(1), opacity: 0.45 }), _jsxs("g", { className: "mb-artwork-blend mb-artwork-drift", "data-drift": "1", children: [shard ? _jsx("path", { d: polygon(shard), fill: x.url("shard") }) : null, planes.map((p) => {
|
|
325
|
+
const top = x.cy + p.offset - p.width / 2;
|
|
326
|
+
const left = x.cx - length / 2;
|
|
327
|
+
const rotate = `rotate(${n(p.angle)} ${n(x.cx)} ${n(x.cy)})`;
|
|
328
|
+
return (_jsxs("g", { transform: rotate, children: [_jsx("rect", { x: n(left), y: n(top), width: n(length), height: n(p.width), fill: x.url(p.key) }), _jsx("line", { x1: n(left), y1: n(top), x2: n(left + length), y2: n(top), style: { stroke: light }, strokeOpacity: 0.55, strokeWidth: n(0.004 * s) })] }, p.key));
|
|
329
|
+
})] })] }));
|
|
330
|
+
}
|
|
331
|
+
/** A field of dots that swell and shrink across the picture, like a print screen. */
|
|
332
|
+
function halftone(x) {
|
|
333
|
+
const { r, w, h, s } = x;
|
|
334
|
+
const onPaper = r.chance(0.4);
|
|
335
|
+
const step = s / r.pick([14, 16, 18]);
|
|
336
|
+
const spots = Array.from({ length: r.int(1, 3) }, () => ({
|
|
337
|
+
x: r.range(0.1, 0.9) * w,
|
|
338
|
+
y: r.range(0.1, 0.9) * h,
|
|
339
|
+
reach: r.range(0.6, 0.95) * s,
|
|
340
|
+
weight: r.range(0.75, 1.05),
|
|
341
|
+
}));
|
|
342
|
+
const angle = r.range(0, TAU);
|
|
343
|
+
const [dx, dy] = [cos(angle), sin(angle)];
|
|
344
|
+
const lean = r.range(0.3, 0.55);
|
|
345
|
+
let d = "";
|
|
346
|
+
const rowHeight = step * 0.866;
|
|
347
|
+
const rows = Math.ceil(h / rowHeight) + 1;
|
|
348
|
+
const cols = Math.ceil(w / step) + 1;
|
|
349
|
+
for (let row = 0; row <= rows; row++) {
|
|
350
|
+
for (let col = 0; col <= cols; col++) {
|
|
351
|
+
const px = col * step + (row % 2 ? step / 2 : 0) - step / 4;
|
|
352
|
+
const py = row * rowHeight;
|
|
353
|
+
let field = 0;
|
|
354
|
+
for (const spot of spots) {
|
|
355
|
+
const dist = Math.sqrt((px - spot.x) ** 2 + (py - spot.y) ** 2);
|
|
356
|
+
field = Math.max(field, smoothstep(1 - dist / spot.reach) * spot.weight);
|
|
357
|
+
}
|
|
358
|
+
const directional = (((px - x.cx) * dx + (py - x.cy) * dy) / s + 0.5) * lean;
|
|
359
|
+
const value = clamp(field + directional);
|
|
360
|
+
const radius = step * 0.47 * value;
|
|
361
|
+
if (radius < step * 0.07)
|
|
362
|
+
continue;
|
|
363
|
+
d += `M${n(px - radius)} ${n(py)}a${n(radius)} ${n(radius)} 0 1 0 ${n(radius * 2)} 0a${n(radius)} ${n(radius)} 0 1 0 ${n(-radius * 2)} 0`;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const span = 0.62 * s;
|
|
367
|
+
return (_jsxs(_Fragment, { children: [_jsx("defs", { children: _jsx(Linear, { x: x, name: "dots", user: true, to: [x.cx - dx * span, x.cy - dy * span, x.cx + dx * span, x.cy + dy * span], list: onPaper ? [[0, x.c(0)], [0.5, x.c(1)], [1, mix(x.c(2), ink, 70)]] : [[0, x.c(0)], [0.5, mix(x.c(1), light, 80)], [1, x.c(2)]] }) }), _jsx(Ground, { x: x, color: onPaper ? paper : ground }), onPaper ? null : _jsx(Glow, { x: x, name: "glow", cx: spots[0]?.x ?? x.cx, cy: spots[0]?.y ?? x.cy, r: 0.9 * s, color: x.c(0), opacity: 0.38 }), _jsx("path", { className: "mb-artwork-drift", "data-drift": "4", d: d, fill: x.url("dots") })] }));
|
|
368
|
+
}
|
|
369
|
+
const rayOrigins = [
|
|
370
|
+
{ at: [0.5, 1.1], aim: -90, burst: true },
|
|
371
|
+
{ at: [-0.06, -0.06], aim: 45, burst: true },
|
|
372
|
+
{ at: [0.5, 0.56], aim: -90, burst: true },
|
|
373
|
+
{ at: [-0.1, 0.82], aim: -25, burst: false },
|
|
374
|
+
{ at: [1.08, 0.12], aim: 150, burst: false },
|
|
375
|
+
{ at: [0.5, -0.12], aim: 90, burst: false },
|
|
376
|
+
];
|
|
377
|
+
/** A sunburst, or beams of light falling from one point. */
|
|
378
|
+
function rays(x) {
|
|
379
|
+
const { r, w, h, s } = x;
|
|
380
|
+
const origin = r.pick(rayOrigins);
|
|
381
|
+
const [ox, oy] = [origin.at[0] * w, origin.at[1] * h];
|
|
382
|
+
const reach = Math.sqrt(w * w + h * h) * 1.4;
|
|
383
|
+
const wedge = (from, to) => polygon([
|
|
384
|
+
[ox, oy],
|
|
385
|
+
[ox + cos(rad(from)) * reach, oy + sin(rad(from)) * reach],
|
|
386
|
+
[ox + cos(rad(to)) * reach, oy + sin(rad(to)) * reach],
|
|
387
|
+
]);
|
|
388
|
+
const burst = origin.burst && r.chance(0.7);
|
|
389
|
+
if (burst) {
|
|
390
|
+
const count = r.int(9, 14) * 2;
|
|
391
|
+
const weights = Array.from({ length: count }, () => r.range(0.6, 1.4));
|
|
392
|
+
const total = weights.reduce((sum, value) => sum + value, 0);
|
|
393
|
+
let angle = r.range(0, 360);
|
|
394
|
+
const a = x.c(0);
|
|
395
|
+
const b = mix(x.c(0), x.c(1), 45);
|
|
396
|
+
const wedges = weights.map((weight, i) => {
|
|
397
|
+
const from = angle;
|
|
398
|
+
angle += (weight / total) * 360;
|
|
399
|
+
return { key: i, d: wedge(from, angle + 0.3), color: i % 2 ? a : b };
|
|
400
|
+
});
|
|
401
|
+
return (_jsxs(_Fragment, { children: [_jsx("defs", { children: _jsx(Radial, { x: x, name: "light", at: { cx: ox, cy: oy, r: reach * 0.7 }, list: [
|
|
402
|
+
[0, light, 0.95],
|
|
403
|
+
[0.12, light, 0.5],
|
|
404
|
+
[0.4, x.c(2), 0.12],
|
|
405
|
+
[1, ground, 0.6],
|
|
406
|
+
] }) }), _jsx(Ground, { x: x, color: a }), _jsx("g", { className: "mb-artwork-drift", "data-drift": "5", style: { transformOrigin: `${n(ox)}px ${n(oy)}px` }, children: wedges.map((item) => (_jsx("path", { d: item.d, style: { fill: item.color } }, item.key))) }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("light") }), _jsx(Glow, { x: x, name: "sun", cx: ox, cy: oy, r: 0.32 * s, color: light, opacity: 0.9 })] }));
|
|
407
|
+
}
|
|
408
|
+
const beams = Array.from({ length: r.int(7, 11) }, (_, i) => {
|
|
409
|
+
const center = origin.aim + r.range(-62, 62);
|
|
410
|
+
const spread = r.range(1.2, 5.5);
|
|
411
|
+
return { key: `r${i}`, from: center - spread, to: center + spread, color: x.c(i) };
|
|
412
|
+
});
|
|
413
|
+
const washes = Array.from({ length: 3 }, (_, i) => {
|
|
414
|
+
const center = origin.aim + r.range(-40, 40);
|
|
415
|
+
const spread = r.range(9, 18);
|
|
416
|
+
return { key: `w${i}`, from: center - spread, to: center + spread, color: x.c(i + 1) };
|
|
417
|
+
});
|
|
418
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "base", to: [0, 0, 1, 1], list: [[0, mix(x.c(0), ground, 22)], [1, ground]] }), [...beams, ...washes].map((beam) => (_jsx(Radial, { x: x, name: beam.key, at: { cx: ox, cy: oy, r: reach * 0.75 }, list: [
|
|
419
|
+
[0, light, 0.95],
|
|
420
|
+
[0.22, beam.color, 0.7],
|
|
421
|
+
[0.6, beam.color, 0.2],
|
|
422
|
+
[1, beam.color, 0],
|
|
423
|
+
] }, beam.key)))] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("base") }), _jsxs("g", { className: "mb-artwork-blend", children: [_jsx("g", { opacity: 0.45, children: washes.map((beam) => (_jsx("path", { d: wedge(beam.from, beam.to), fill: x.url(beam.key) }, beam.key))) }), _jsx("g", { className: "mb-artwork-drift", "data-drift": "5", style: { transformOrigin: `${n(ox)}px ${n(oy)}px` }, children: beams.map((beam) => (_jsx("path", { d: wedge(beam.from, beam.to), fill: x.url(beam.key) }, beam.key))) })] }), _jsx(Glow, { x: x, name: "source", cx: ox, cy: oy, r: 0.55 * s, color: light, opacity: 0.75 })] }));
|
|
424
|
+
}
|
|
425
|
+
/** A Swiss grid of circles, half circles and quarter circles. */
|
|
426
|
+
function glyph(x) {
|
|
427
|
+
const { r, w, h } = x;
|
|
428
|
+
const rows = r.pick([2, 3, 3, 4]);
|
|
429
|
+
const cols = Math.max(1, Math.round((rows * w) / h));
|
|
430
|
+
const cw = w / cols;
|
|
431
|
+
const ch = h / rows;
|
|
432
|
+
const size = Math.min(cw, ch);
|
|
433
|
+
const scheme = r.pick(["paper", "paper", "ground", "color"]);
|
|
434
|
+
const background = scheme === "paper" ? paper : scheme === "ground" ? ground : x.c(0);
|
|
435
|
+
const inks = scheme === "paper"
|
|
436
|
+
? [x.c(0), x.c(1), x.c(2), mix(ink, x.c(3), 85)]
|
|
437
|
+
: scheme === "ground"
|
|
438
|
+
? [x.c(0), x.c(1), x.c(2), light]
|
|
439
|
+
: [x.c(1), mix(ink, x.c(0), 80), light, x.c(2)];
|
|
440
|
+
const extra = r.pick(["circle", "ring", "dot", "triangle"]);
|
|
441
|
+
const shapes = ["quarter", "quarter", "half", "half", extra, rows > 2 ? "empty" : extra];
|
|
442
|
+
const cells = [];
|
|
443
|
+
for (let row = 0; row < rows; row++) {
|
|
444
|
+
for (let col = 0; col < cols; col++) {
|
|
445
|
+
const key = `${row}-${col}`;
|
|
446
|
+
const left = col * cw + (cw - size) / 2;
|
|
447
|
+
const top = row * ch + (ch - size) / 2;
|
|
448
|
+
const fillIndex = r.chance(0.5) ? r.int(0, inks.length - 1) : -1;
|
|
449
|
+
const cellFill = fillIndex >= 0 ? inks[fillIndex] : undefined;
|
|
450
|
+
const shape = r.pick(shapes);
|
|
451
|
+
let inkIndex = r.int(0, inks.length - 1);
|
|
452
|
+
if (inkIndex === fillIndex)
|
|
453
|
+
inkIndex = (inkIndex + 1 + r.int(0, inks.length - 2)) % inks.length;
|
|
454
|
+
const color = inks[inkIndex];
|
|
455
|
+
const turn = r.int(0, 3) * 90;
|
|
456
|
+
const z = n(size);
|
|
457
|
+
const half = n(size / 2);
|
|
458
|
+
const transform = `translate(${n(left)} ${n(top)}) rotate(${turn} ${half} ${half})`;
|
|
459
|
+
let mark = null;
|
|
460
|
+
if (shape === "quarter")
|
|
461
|
+
mark = _jsx("path", { d: `M0 0H${z}A${z} ${z} 0 0 1 0 ${z}Z` });
|
|
462
|
+
else if (shape === "half")
|
|
463
|
+
mark = _jsx("path", { d: `M0 0H${z}A${half} ${half} 0 0 1 0 0Z` });
|
|
464
|
+
else if (shape === "triangle")
|
|
465
|
+
mark = _jsx("path", { d: `M0 0H${z}L0 ${z}Z` });
|
|
466
|
+
else if (shape === "circle")
|
|
467
|
+
mark = _jsx("circle", { cx: half, cy: half, r: half });
|
|
468
|
+
else if (shape === "dot")
|
|
469
|
+
mark = _jsx("circle", { cx: half, cy: half, r: n(size * 0.2) });
|
|
470
|
+
else if (shape === "ring")
|
|
471
|
+
mark = _jsx("circle", { cx: half, cy: half, r: n(size * 0.33), fill: "none", style: { stroke: color }, strokeWidth: n(size * 0.15) });
|
|
472
|
+
cells.push(_jsxs("g", { transform: transform, style: { fill: color }, children: [cellFill ? _jsx("rect", { width: z, height: z, style: { fill: cellFill } }) : null, mark] }, key));
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return (_jsxs(_Fragment, { children: [_jsx(Ground, { x: x, color: background }), cells] }));
|
|
476
|
+
}
|
|
477
|
+
/** Wide ribbons that twist through space, front and back in two colors. */
|
|
478
|
+
function ribbon(x) {
|
|
479
|
+
const { r, w, h, s } = x;
|
|
480
|
+
const count = r.int(2, 4);
|
|
481
|
+
const vertical = r.chance(0.3);
|
|
482
|
+
const ribbons = Array.from({ length: count }, (_, i) => {
|
|
483
|
+
const map = ([a, b]) => (vertical ? [b * w, a * h] : [a * w, b * h]);
|
|
484
|
+
const p0 = map([-0.18, r.range(0.1, 0.9)]);
|
|
485
|
+
const p1 = map([r.range(0.15, 0.45), r.range(-0.25, 1.25)]);
|
|
486
|
+
const p2 = map([r.range(0.55, 0.85), r.range(-0.25, 1.25)]);
|
|
487
|
+
const p3 = map([1.18, r.range(0.1, 0.9)]);
|
|
488
|
+
const width = r.range(0.12, 0.22) * s;
|
|
489
|
+
const twists = r.range(0.9, 2.1);
|
|
490
|
+
const phase = r.range(0, 1);
|
|
491
|
+
const front = x.c(i);
|
|
492
|
+
const back = mix(x.c(i + 1), ground, 75);
|
|
493
|
+
const ts = [];
|
|
494
|
+
for (let k = 0; k <= 44; k++)
|
|
495
|
+
ts.push(k / 44);
|
|
496
|
+
const nodes = [];
|
|
497
|
+
for (let m = -1; m < twists + 2; m++) {
|
|
498
|
+
const t = (m + 0.5 - phase) / twists;
|
|
499
|
+
if (t > 0 && t < 1)
|
|
500
|
+
nodes.push(t);
|
|
501
|
+
}
|
|
502
|
+
const all = [...new Set([...ts, ...nodes])].sort((a, b) => a - b);
|
|
503
|
+
const sample = (t) => {
|
|
504
|
+
const u = 1 - t;
|
|
505
|
+
const point = [
|
|
506
|
+
u * u * u * p0[0] + 3 * u * u * t * p1[0] + 3 * u * t * t * p2[0] + t * t * t * p3[0],
|
|
507
|
+
u * u * u * p0[1] + 3 * u * u * t * p1[1] + 3 * u * t * t * p2[1] + t * t * t * p3[1],
|
|
508
|
+
];
|
|
509
|
+
const tangent = [
|
|
510
|
+
3 * u * u * (p1[0] - p0[0]) + 6 * u * t * (p2[0] - p1[0]) + 3 * t * t * (p3[0] - p2[0]),
|
|
511
|
+
3 * u * u * (p1[1] - p0[1]) + 6 * u * t * (p2[1] - p1[1]) + 3 * t * t * (p3[1] - p2[1]),
|
|
512
|
+
];
|
|
513
|
+
const length = Math.sqrt(tangent[0] ** 2 + tangent[1] ** 2) || 1;
|
|
514
|
+
const half = (width / 2) * (0.1 + 0.9 * Math.abs(cos(PI * (t * twists + phase))));
|
|
515
|
+
const normal = [(-tangent[1] / length) * half, (tangent[0] / length) * half];
|
|
516
|
+
return { point, left: [point[0] + normal[0], point[1] + normal[1]], right: [point[0] - normal[0], point[1] - normal[1]] };
|
|
517
|
+
};
|
|
518
|
+
const samples = all.map((t) => ({ t, ...sample(t) }));
|
|
519
|
+
const segments = [[]];
|
|
520
|
+
for (const item of samples) {
|
|
521
|
+
const current = segments[segments.length - 1];
|
|
522
|
+
current.push(item);
|
|
523
|
+
if (nodes.includes(item.t))
|
|
524
|
+
segments.push([item]);
|
|
525
|
+
}
|
|
526
|
+
const outline = polygon([...samples.map((item) => item.left), ...samples.map((item) => item.right).reverse()]);
|
|
527
|
+
return {
|
|
528
|
+
key: `r${i}`,
|
|
529
|
+
outline,
|
|
530
|
+
segments: segments
|
|
531
|
+
.filter((segment) => segment.length > 1)
|
|
532
|
+
.map((segment, k) => {
|
|
533
|
+
const first = segment[0];
|
|
534
|
+
const last = segment[segment.length - 1];
|
|
535
|
+
const middle = (first.t + last.t) / 2;
|
|
536
|
+
const faceFront = Math.floor(middle * twists + phase + 0.5) % 2 === 0;
|
|
537
|
+
return {
|
|
538
|
+
key: `r${i}s${k}`,
|
|
539
|
+
d: polygon([...segment.map((item) => item.left), ...segment.map((item) => item.right).reverse()]),
|
|
540
|
+
from: first.point,
|
|
541
|
+
to: last.point,
|
|
542
|
+
color: faceFront ? front : back,
|
|
543
|
+
};
|
|
544
|
+
}),
|
|
545
|
+
};
|
|
546
|
+
});
|
|
547
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "base", to: [0, 0, 1, 1], list: [[0, mix(x.c(0), ground, 30)], [1, ground]] }), _jsx("filter", { id: x.id("shadow"), x: "-20%", y: "-20%", width: "140%", height: "140%", children: _jsx("feGaussianBlur", { stdDeviation: n(0.025 * s) }) }), ribbons.flatMap((item) => item.segments.map((segment) => (_jsx(Linear, { x: x, name: segment.key, user: true, to: [segment.from[0], segment.from[1], segment.to[0], segment.to[1]], list: [
|
|
548
|
+
[0, mix(segment.color, ground, 45)],
|
|
549
|
+
[0.5, mix(segment.color, light, 78)],
|
|
550
|
+
[1, mix(segment.color, ground, 45)],
|
|
551
|
+
] }, segment.key))))] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("base") }), _jsx(Glow, { x: x, name: "glow", cx: x.cx, cy: x.cy, r: 0.85 * s, color: x.c(1), opacity: 0.35 }), ribbons.map((item, i) => (_jsxs("g", { className: "mb-artwork-drift", "data-drift": String((i % 3) + 1), children: [_jsx("path", { d: item.outline, fill: "black", fillOpacity: 0.4, filter: x.url("shadow"), transform: `translate(${n(0.012 * s)} ${n(0.035 * s)})` }), item.segments.map((segment) => (_jsx("path", { d: segment.d, fill: x.url(segment.key) }, segment.key)))] }, item.key)))] }));
|
|
552
|
+
}
|
|
553
|
+
/** Contour lines around a summit, filled like an elevation map. */
|
|
554
|
+
function topo(x) {
|
|
555
|
+
const { r, w, h, s } = x;
|
|
556
|
+
const px = r.range(0.25, 0.75) * w;
|
|
557
|
+
const py = r.range(0.25, 0.75) * h;
|
|
558
|
+
const farthest = Math.sqrt(Math.max(px, w - px) ** 2 + Math.max(py, h - py) ** 2);
|
|
559
|
+
const count = r.int(9, 12);
|
|
560
|
+
const step = (farthest * 1.08) / count;
|
|
561
|
+
const harmonics = [2, 3, 4, 5].map((m) => ({ m, amount: r.range(0.015, 0.045), phase: r.range(0, TAU), drift: r.range(-0.14, 0.14) }));
|
|
562
|
+
const colors = [mix(x.c(2), light, 55), x.c(0), x.c(1), mix(x.c(1), ground, 40), ground];
|
|
563
|
+
const rings = Array.from({ length: count }, (_, k) => {
|
|
564
|
+
const level = count - 1 - k;
|
|
565
|
+
const radius = step * (level + 0.7);
|
|
566
|
+
const points = Array.from({ length: 24 }, (_, j) => {
|
|
567
|
+
const theta = (j / 24) * TAU;
|
|
568
|
+
let wobble = 0;
|
|
569
|
+
for (const item of harmonics)
|
|
570
|
+
wobble += item.amount * sin(item.m * theta + item.phase + level * item.drift);
|
|
571
|
+
const rr = radius * (1 + wobble);
|
|
572
|
+
return [px + cos(theta) * rr, py + sin(theta) * rr];
|
|
573
|
+
});
|
|
574
|
+
return { key: level, d: smooth(points, true), color: ramp(colors, level / (count - 1)), index: level % 4 === 3 };
|
|
575
|
+
});
|
|
576
|
+
return (_jsxs(_Fragment, { children: [_jsx(Ground, { x: x, color: ground }), _jsx("g", { className: "mb-artwork-drift", "data-drift": "4", style: { stroke: light }, children: rings.map((ring) => (_jsx("path", { d: ring.d, style: { fill: ring.color }, strokeOpacity: ring.index ? 0.55 : 0.26, strokeWidth: n((ring.index ? 0.006 : 0.0035) * s) }, ring.key))) }), _jsx(Glow, { x: x, name: "peak", cx: px, cy: py, r: step * 2.4, color: light, opacity: 0.4 })] }));
|
|
577
|
+
}
|
|
578
|
+
/** A printed sunset: a sun sinking into a still sea, under heavy film grain. */
|
|
579
|
+
function grainVariant(x) {
|
|
580
|
+
const { r, w, h, s } = x;
|
|
581
|
+
const horizon = r.range(0.58, 0.76) * h;
|
|
582
|
+
const radius = r.range(0.13, 0.22) * s;
|
|
583
|
+
const sun = { cx: r.range(0.28, 0.72) * w, cy: horizon - radius * r.range(-0.15, 0.9), r: radius };
|
|
584
|
+
const bars = r.int(5, 8);
|
|
585
|
+
const gapY = (h - horizon) / (bars + 1.5);
|
|
586
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "sky", user: true, to: [0, 0, 0, horizon], list: [
|
|
587
|
+
[0, mix(x.c(3), ground, 40)],
|
|
588
|
+
[0.6, mix(x.c(0), x.c(3), 75)],
|
|
589
|
+
[1, mix(x.c(1), light, 78)],
|
|
590
|
+
] }), _jsx(Linear, { x: x, name: "sea", user: true, to: [0, horizon, 0, h], list: [[0, mix(x.c(1), ground, 60)], [1, ground]] }), _jsx(Linear, { x: x, name: "sun", to: [0, 0, 0, 1], list: [[0, mix(light, x.c(1), 85)], [1, mix(x.c(1), light, 70)]] })] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("sky") }), _jsxs("g", { className: "mb-artwork-drift", "data-drift": "3", children: [_jsx(Glow, { x: x, name: "glow", cx: sun.cx, cy: sun.cy, r: sun.r * 3.4, color: light, opacity: 0.55 }), _jsx("circle", { cx: n(sun.cx), cy: n(sun.cy), r: n(sun.r), fill: x.url("sun") })] }), _jsx("rect", { y: n(horizon), width: n(w), height: n(h - horizon), fill: x.url("sea") }), _jsx("g", { style: { fill: mix(light, x.c(1), 65) }, children: Array.from({ length: bars }, (_, j) => {
|
|
591
|
+
const t = j / bars;
|
|
592
|
+
const width = sun.r * 2 * (1 - t * 0.75) * r.range(0.75, 1);
|
|
593
|
+
const height = gapY * r.range(0.28, 0.45);
|
|
594
|
+
return (_jsx("rect", { x: n(sun.cx - width / 2 + r.range(-0.04, 0.04) * s), y: n(horizon + gapY * (j + 0.7)), width: n(width), height: n(height), rx: n(height / 2), opacity: n((0.85 - t * 0.65) * 100) / 100 }, j));
|
|
595
|
+
}) })] }));
|
|
596
|
+
}
|
|
597
|
+
/** Soft rounded tiles, a few of them doubled up, shaded across the grid with one or two bright accents. */
|
|
598
|
+
function mosaic(x) {
|
|
599
|
+
const { r, w, h, s } = x;
|
|
600
|
+
const cols = Math.max(3, Math.round((r.pick([4, 4, 5, 6]) * w) / s));
|
|
601
|
+
const rows = Math.max(3, Math.round((cols * h) / w));
|
|
602
|
+
const cw = w / cols;
|
|
603
|
+
const ch = h / rows;
|
|
604
|
+
const gap = r.range(0.012, 0.02) * s;
|
|
605
|
+
const corner = Math.min(cw, ch) * r.range(0.16, 0.26);
|
|
606
|
+
const angle = r.range(0, TAU);
|
|
607
|
+
const [dx, dy] = [cos(angle), sin(angle)];
|
|
608
|
+
const spot = { x: r.range(0.15, 0.85) * w, y: r.range(0.15, 0.85) * h };
|
|
609
|
+
const taken = new Set();
|
|
610
|
+
const tiles = [];
|
|
611
|
+
const place = (col, row, span) => {
|
|
612
|
+
for (let a = 0; a < span[0]; a++)
|
|
613
|
+
for (let b = 0; b < span[1]; b++)
|
|
614
|
+
if (col + a >= cols || row + b >= rows || taken.has((row + b) * cols + col + a))
|
|
615
|
+
return false;
|
|
616
|
+
for (let a = 0; a < span[0]; a++)
|
|
617
|
+
for (let b = 0; b < span[1]; b++)
|
|
618
|
+
taken.add((row + b) * cols + col + a);
|
|
619
|
+
tiles.push({ col, row, span });
|
|
620
|
+
return true;
|
|
621
|
+
};
|
|
622
|
+
const big = r.int(1, 2);
|
|
623
|
+
for (let k = 0, tries = 0; k < big && tries < 12; tries++)
|
|
624
|
+
if (place(r.int(0, cols - 2), r.int(0, rows - 2), [2, 2]))
|
|
625
|
+
k++;
|
|
626
|
+
const long = r.int(1, 3);
|
|
627
|
+
for (let k = 0, tries = 0; k < long && tries < 12; tries++) {
|
|
628
|
+
const across = r.chance(0.5);
|
|
629
|
+
if (place(r.int(0, cols - (across ? 2 : 1)), r.int(0, rows - (across ? 1 : 2)), across ? [2, 1] : [1, 2]))
|
|
630
|
+
k++;
|
|
631
|
+
}
|
|
632
|
+
for (let row = 0; row < rows; row++)
|
|
633
|
+
for (let col = 0; col < cols; col++)
|
|
634
|
+
place(col, row, [1, 1]);
|
|
635
|
+
const accents = new Set(r.shuffle(tiles.map((_, i) => i).filter((i) => tiles[i]?.span[0] === 1 && tiles[i]?.span[1] === 1)).slice(0, r.int(1, 2)));
|
|
636
|
+
const hues = [x.c(0), x.c(1), x.c(2)];
|
|
637
|
+
return (_jsxs(_Fragment, { children: [_jsx("defs", { children: _jsx(Linear, { x: x, name: "sheen", to: [0, 0, 0, 1], list: [[0, "white", 0.26], [0.45, "white", 0], [1, "black", 0.16]] }) }), _jsx(Ground, { x: x, color: mix(x.c(0), ground, 15) }), tiles.map((tile, i) => {
|
|
638
|
+
const left = tile.col * cw + gap / 2;
|
|
639
|
+
const top = tile.row * ch + gap / 2;
|
|
640
|
+
const width = tile.span[0] * cw - gap;
|
|
641
|
+
const height = tile.span[1] * ch - gap;
|
|
642
|
+
const tx = left + width / 2;
|
|
643
|
+
const ty = top + height / 2;
|
|
644
|
+
const along = clamp(((tx - x.cx) * dx + (ty - x.cy) * dy) / s + 0.5);
|
|
645
|
+
const near = smoothstep(1 - Math.sqrt((tx - spot.x) ** 2 + (ty - spot.y) ** 2) / (0.9 * s));
|
|
646
|
+
const base = accents.has(i) ? x.c(3) : ramp(hues, along);
|
|
647
|
+
const color = near > 0.5 ? mix(light, base, (near - 0.5) * 70) : mix(ground, base, (0.5 - near) * 60);
|
|
648
|
+
const props = { x: n(left), y: n(top), width: n(width), height: n(height), rx: n(corner) };
|
|
649
|
+
return (_jsxs(React.Fragment, { children: [_jsx("rect", { ...props, style: { fill: color } }), _jsx("rect", { ...props, fill: x.url("sheen") })] }, i));
|
|
650
|
+
})] }));
|
|
651
|
+
}
|
|
652
|
+
/* ── Backgrounds ──────────────────────────────────────────────────
|
|
653
|
+
* Made to sit behind an interface. They paint with three scheme-aware colors from artwork.css
|
|
654
|
+
* (pale in light mode, deep in dark mode), so text in the label color reads on them in both:
|
|
655
|
+
* base the main field deep shade and distance haze soft light
|
|
656
|
+
* Sizes follow the longer side, so a phone and a wide window both get large, calm shapes.
|
|
657
|
+
*/
|
|
658
|
+
const base = "var(--mb-artwork-base)";
|
|
659
|
+
const deep = "var(--mb-artwork-deep)";
|
|
660
|
+
const haze = "var(--mb-artwork-haze)";
|
|
661
|
+
const hues = ["var(--mb-artwork-1)", "var(--mb-artwork-2)", "var(--mb-artwork-3)", "var(--mb-artwork-4)"];
|
|
662
|
+
/** How much light a time of day lets in: brighter by day, deeper at night. */
|
|
663
|
+
const lift = { dawn: 0.2, day: 1, dusk: -0.4, night: -1 };
|
|
664
|
+
/** Large soft fields of color drifting between two or three hues, like a blurred wallpaper. */
|
|
665
|
+
function wash(x) {
|
|
666
|
+
const { r, w, h } = x;
|
|
667
|
+
const long = Math.max(w, h);
|
|
668
|
+
const angle = r.range(0, TAU);
|
|
669
|
+
const [dx, dy] = [cos(angle), sin(angle)];
|
|
670
|
+
const span = Math.sqrt(w * w + h * h) / 2;
|
|
671
|
+
const count = r.int(3, 4);
|
|
672
|
+
const fields = Array.from({ length: count }, (_, i) => {
|
|
673
|
+
const rx = r.range(0.42, 0.7) * long;
|
|
674
|
+
return {
|
|
675
|
+
key: `f${i}`,
|
|
676
|
+
cx: r.range(-0.08, 1.08) * w,
|
|
677
|
+
cy: r.range(-0.08, 1.08) * h,
|
|
678
|
+
rx,
|
|
679
|
+
ry: rx * r.range(0.55, 0.85),
|
|
680
|
+
rotate: r.range(0, 180),
|
|
681
|
+
color: mix(x.c(i + 1), base, r.range(46, 66)),
|
|
682
|
+
opacity: r.range(0.7, 0.92),
|
|
683
|
+
};
|
|
684
|
+
});
|
|
685
|
+
const side = r.range(0, TAU);
|
|
686
|
+
const light = { cx: x.cx + cos(side) * w * 0.4, cy: x.cy + sin(side) * h * 0.4 };
|
|
687
|
+
const shade = { cx: x.cx - cos(side) * w * 0.48, cy: x.cy - sin(side) * h * 0.48 };
|
|
688
|
+
const amount = x.time ? lift[x.time] : 0;
|
|
689
|
+
const half = Math.ceil(count / 2);
|
|
690
|
+
const field = (f) => (_jsx("ellipse", { cx: n(f.cx), cy: n(f.cy), rx: n(f.rx), ry: n(f.ry), transform: `rotate(${n(f.rotate)} ${n(f.cx)} ${n(f.cy)})`, fill: x.url(f.key) }, f.key));
|
|
691
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "base", user: true, to: [x.cx - dx * span, x.cy - dy * span, x.cx + dx * span, x.cy + dy * span], list: [
|
|
692
|
+
[0, mix(x.c(0), base, 40)],
|
|
693
|
+
[0.5, mix(x.c(1), base, 26)],
|
|
694
|
+
[1, mix(x.c(2), base, 38)],
|
|
695
|
+
] }), fields.map((f) => (_jsx(Radial, { x: x, name: f.key, list: soft(f.color, f.opacity) }, f.key))), _jsx(Radial, { x: x, name: "shade", at: { cx: shade.cx, cy: shade.cy, r: long * 0.72 }, list: soft(deep, clamp(0.5 - amount * 0.18)) }), _jsx(Radial, { x: x, name: "light", at: { cx: light.cx, cy: light.cy, r: long * 0.6 }, list: soft(haze, clamp(0.34 + amount * 0.12)) })] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("base") }), _jsx("g", { className: "mb-artwork-drift", "data-drift": "1", children: fields.slice(0, half).map(field) }), _jsx("g", { className: "mb-artwork-drift", "data-drift": "2", children: fields.slice(half).map(field) }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("shade") }), _jsx("rect", { className: "mb-artwork-drift", "data-drift": "3", width: n(w), height: n(h), fill: x.url("light") })] }));
|
|
696
|
+
}
|
|
697
|
+
/** A sky at a time of day: bands of color down to a low glow on the horizon, and two hazy ridges. */
|
|
698
|
+
function horizon(x) {
|
|
699
|
+
const { r, w, h, s } = x;
|
|
700
|
+
const time = x.time ?? r.pick(artworkTimes);
|
|
701
|
+
const line = r.range(0.58, 0.7) * h;
|
|
702
|
+
const sunX = r.range(0.2, 0.8) * w;
|
|
703
|
+
const [h1, h2, h3, h4] = hues;
|
|
704
|
+
const sky = {
|
|
705
|
+
dawn: [mix(h4, deep, 42), mix(h1, base, 50), mix(h3, base, 52), mix(h2, haze, 60)],
|
|
706
|
+
day: [mix(h1, deep, 50), mix(h1, base, 38), mix(h3, base, 28), mix(haze, h2, 80)],
|
|
707
|
+
dusk: [mix(h4, deep, 60), mix(h1, deep, 52), mix(h3, base, 56), mix(h2, base, 76)],
|
|
708
|
+
night: [deep, mix(h4, deep, 34), mix(h1, deep, 40), mix(h1, base, 42)],
|
|
709
|
+
};
|
|
710
|
+
const suns = {
|
|
711
|
+
dawn: { y: line - 0.015 * h, r: 0.09 * s, glow: 0.62, core: 0.75 },
|
|
712
|
+
day: { y: r.range(0.16, 0.3) * h, r: 0.075 * s, glow: 0.45, core: 0.85 },
|
|
713
|
+
dusk: { y: line + 0.025 * h, r: 0.11 * s, glow: 0.58, core: 0.65 },
|
|
714
|
+
night: { y: r.range(0.16, 0.3) * h, r: 0.04 * s, glow: 0.24, core: 0.6 },
|
|
715
|
+
};
|
|
716
|
+
const ramp4 = sky[time];
|
|
717
|
+
const sun = suns[time];
|
|
718
|
+
const glow = time === "night" ? haze : mix(h2, haze, 55);
|
|
719
|
+
const ridges = [0, 1].map((i) => {
|
|
720
|
+
const top = line + (i === 0 ? 0.008 : 0.085) * h + r.range(-0.01, 0.01) * h;
|
|
721
|
+
const amplitude = r.range(0.012, 0.028) * h * (1 + i * 0.8);
|
|
722
|
+
const frequency = (r.range(0.6, 1.3) * TAU) / w;
|
|
723
|
+
const phase = r.range(0, TAU);
|
|
724
|
+
const points = Array.from({ length: 10 }, (_, k) => {
|
|
725
|
+
const px = -0.05 * w + (k / 9) * 1.1 * w;
|
|
726
|
+
return [px, top + amplitude * sin(frequency * px + phase) + amplitude * 0.35 * sin(frequency * 2.3 * px + phase * 1.7)];
|
|
727
|
+
});
|
|
728
|
+
const crest = smooth(points, false);
|
|
729
|
+
return { key: `r${i}`, top, d: `${crest}L${n(1.05 * w)} ${n(h + 2)}L${n(-0.05 * w)} ${n(h + 2)}Z` };
|
|
730
|
+
});
|
|
731
|
+
const [far, near] = ridges;
|
|
732
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "sky", user: true, to: [0, 0, 0, line], list: [
|
|
733
|
+
[0, ramp4[0]],
|
|
734
|
+
[0.42, ramp4[1]],
|
|
735
|
+
[0.78, ramp4[2]],
|
|
736
|
+
[1, ramp4[3]],
|
|
737
|
+
] }), _jsx(Radial, { x: x, name: "band", list: soft(glow, sun.glow * 0.55) }), _jsx(Radial, { x: x, name: "glow", list: soft(glow, sun.glow) }), _jsx(Radial, { x: x, name: "sun", list: [
|
|
738
|
+
[0, mix(haze, h2, 82), sun.core],
|
|
739
|
+
[0.72, mix(haze, h2, 70), sun.core],
|
|
740
|
+
[1, mix(haze, h2, 70), 0],
|
|
741
|
+
] }), _jsx(Linear, { x: x, name: far.key, user: true, to: [0, far.top - 0.03 * h, 0, h], list: [[0, mix(ramp4[2], deep, 48), 0.55], [0.12, mix(ramp4[2], deep, 44)], [1, mix(h4, deep, 40)]] }), _jsx(Linear, { x: x, name: near.key, user: true, to: [0, near.top - 0.03 * h, 0, h], list: [[0, mix(h4, deep, 42), 0.7], [0.1, mix(h4, deep, 40)], [1, deep]] })] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("sky") }), _jsx("ellipse", { cx: n(sunX), cy: n(line), rx: n(0.85 * w), ry: n(0.16 * h), fill: x.url("band") }), _jsxs("g", { className: "mb-artwork-drift", "data-drift": "3", children: [_jsx("circle", { cx: n(sunX), cy: n(sun.y), r: n(sun.r * 4.6), fill: x.url("glow") }), _jsx("circle", { cx: n(sunX), cy: n(sun.y), r: n(sun.r), fill: x.url("sun") })] }), _jsx("path", { d: far.d, fill: x.url(far.key), opacity: 0.88 }), _jsx("path", { d: near.d, fill: x.url(near.key) })] }));
|
|
742
|
+
}
|
|
743
|
+
/** Light from a window falling across a wall: a few panes, stretched and slanted, and a faint beam. */
|
|
744
|
+
function windowLight(x) {
|
|
745
|
+
const { r, w, h, s } = x;
|
|
746
|
+
const long = Math.max(w, h);
|
|
747
|
+
const fromLeft = r.chance(0.5);
|
|
748
|
+
const slope = r.range(0.3, 0.62) * (fromLeft ? 1 : -1);
|
|
749
|
+
// A paned window, a pair of tall doors, or light through blinds.
|
|
750
|
+
const layout = r.pick(["panes", "panes", "doors", "blinds"]);
|
|
751
|
+
const cols = layout === "blinds" ? 1 : layout === "doors" ? 2 : r.int(2, 3);
|
|
752
|
+
const rows = layout === "blinds" ? r.int(6, 9) : layout === "doors" ? r.int(1, 3) : r.int(2, 3);
|
|
753
|
+
const bw = Math.min(r.range(0.32, 0.46) * Math.sqrt(w * h) * (layout === "blinds" ? 1.2 : 1), 0.66 * w);
|
|
754
|
+
const bh = Math.min(bw * r.range(1.1, 1.6) * (layout === "doors" ? 1.25 : 1), 0.66 * h);
|
|
755
|
+
const bx = r.range(-0.06, 1.06 - bw / w) * w;
|
|
756
|
+
const by = r.range(0.1, 0.26) * h - (slope < 0 ? slope * bw : 0);
|
|
757
|
+
const gap = layout === "blinds" ? (bh / rows) * r.range(0.3, 0.45) : 0.02 * s;
|
|
758
|
+
const at = (px, py) => [px, py + (px - bx) * slope];
|
|
759
|
+
let panes = "";
|
|
760
|
+
for (let i = 0; i < rows; i++) {
|
|
761
|
+
for (let j = 0; j < cols; j++) {
|
|
762
|
+
const x0 = bx + (j * bw) / cols + gap / 2;
|
|
763
|
+
const x1 = bx + ((j + 1) * bw) / cols - gap / 2;
|
|
764
|
+
const y0 = by + (i * bh) / rows + gap / 2;
|
|
765
|
+
const y1 = by + ((i + 1) * bh) / rows - gap / 2;
|
|
766
|
+
panes += polygon([at(x0, y0), at(x1, y0), at(x1, y1), at(x0, y1)]);
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
const near = at(fromLeft ? bx : bx + bw, by);
|
|
770
|
+
const far = at(fromLeft ? bx + bw : bx, by + bh);
|
|
771
|
+
const source = [fromLeft ? -0.25 * w : 1.25 * w, -0.3 * h];
|
|
772
|
+
const beam = polygon([
|
|
773
|
+
[source[0] - 0.12 * w, source[1]],
|
|
774
|
+
[source[0] + 0.12 * w, source[1]],
|
|
775
|
+
at(fromLeft ? bx + bw : bx, by + bh),
|
|
776
|
+
at(fromLeft ? bx : bx + bw, by),
|
|
777
|
+
]);
|
|
778
|
+
const time = x.time ?? "day";
|
|
779
|
+
const sunlit = time === "day" ? mix(haze, x.c(1), 82) : mix(x.c(1), haze, time === "night" ? 70 : 48);
|
|
780
|
+
const strength = time === "night" ? 0.55 : time === "dusk" ? 0.8 : 1;
|
|
781
|
+
const floor = r.chance(0.6) ? r.range(0.8, 0.88) * h : null;
|
|
782
|
+
const [cx, cy] = [bx + bw / 2, by + bh / 2 + (bw / 2) * slope];
|
|
783
|
+
const wall = lift[time] * 8;
|
|
784
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "wall", to: [fromLeft ? 0 : 1, 0, fromLeft ? 1 : 0, 1], list: [
|
|
785
|
+
[0, mix(x.c(0), base, 36 - wall)],
|
|
786
|
+
[0.6, mix(x.c(2), base, 28)],
|
|
787
|
+
[1, mix(x.c(3), deep, 44)],
|
|
788
|
+
] }), _jsx(Linear, { x: x, name: "panes", user: true, to: [near[0], near[1], far[0], far[1]], list: [
|
|
789
|
+
[0, sunlit, 0.5 * strength],
|
|
790
|
+
[0.55, sunlit, 0.26 * strength],
|
|
791
|
+
[1, sunlit, 0.06 * strength],
|
|
792
|
+
] }), _jsx(Linear, { x: x, name: "beam", user: true, to: [source[0], source[1], cx, cy], list: [
|
|
793
|
+
[0, sunlit, 0],
|
|
794
|
+
[0.7, sunlit, 0.12 * strength],
|
|
795
|
+
[1, sunlit, 0.05 * strength],
|
|
796
|
+
] }), _jsx(Radial, { x: x, name: "shade", at: { cx: fromLeft ? w * 1.05 : -0.05 * w, cy: h, r: long * 0.85 }, list: soft(deep, 0.55) }), floor ? _jsx(Linear, { x: x, name: "floor", user: true, to: [0, floor, 0, h], list: [[0, deep, 0], [0.3, deep, 0.24], [1, deep, 0.5]] }) : null] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("wall") }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("shade") }), floor ? _jsx("rect", { y: n(floor), width: n(w), height: n(h - floor), fill: x.url("floor") }) : null, _jsx(Glow, { x: x, name: "spill", cx: cx, cy: cy, r: long * 0.5, color: sunlit, opacity: 0.3 * strength }), _jsxs("g", { className: "mb-artwork-drift", "data-drift": "3", children: [_jsx("path", { d: beam, fill: x.url("beam") }), _jsx("path", { d: panes, fill: x.url("panes"), stroke: x.url("panes"), strokeOpacity: 0.32, strokeWidth: n(0.03 * s), strokeLinejoin: "round" })] })] }));
|
|
797
|
+
}
|
|
798
|
+
/** A camera's view without the place: a dim field, out-of-focus lights, a faint sensor scan and a vignette. */
|
|
799
|
+
function lens(x) {
|
|
800
|
+
const { r, w, h, s } = x;
|
|
801
|
+
const night = x.time === "night";
|
|
802
|
+
// Infrared at night: the same picture with the color drained out.
|
|
803
|
+
const tint = (i) => (night ? `oklch(from ${x.c(i)} l 0.012 h)` : x.c(i));
|
|
804
|
+
const dark = night ? "oklch(from var(--mb-artwork-ground) 0.17 0.006 h)" : ground;
|
|
805
|
+
const glare = night ? "oklch(0.92 0 0)" : light;
|
|
806
|
+
const split = r.range(0.42, 0.62);
|
|
807
|
+
const lamp = { cx: r.range(0.15, 0.85) * w, cy: r.range(0.14, 0.42) * h };
|
|
808
|
+
const count = r.int(5, 8);
|
|
809
|
+
const discs = Array.from({ length: count }, (_, i) => {
|
|
810
|
+
const angle = r.range(0, TAU);
|
|
811
|
+
const distance = r.range(0.04, 0.62) * s;
|
|
812
|
+
return {
|
|
813
|
+
key: i,
|
|
814
|
+
cx: lamp.cx + cos(angle) * distance * (w / s > 1 ? 1.4 : 1),
|
|
815
|
+
cy: lamp.cy + sin(angle) * distance * 0.7,
|
|
816
|
+
r: r.range(0.03, 0.09) * s,
|
|
817
|
+
tone: i % 3,
|
|
818
|
+
opacity: n(r.range(0.45, 0.95) * 100) / 100,
|
|
819
|
+
};
|
|
820
|
+
});
|
|
821
|
+
return (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "field", user: true, to: [0, 0, 0, h], list: [
|
|
822
|
+
[0, mix(tint(0), dark, 30)],
|
|
823
|
+
[split - 0.08, mix(tint(1), dark, 26)],
|
|
824
|
+
[split + 0.06, mix(tint(2), dark, 16)],
|
|
825
|
+
[1, mix(tint(2), dark, 8)],
|
|
826
|
+
] }), [0, 1, 2].map((i) => {
|
|
827
|
+
const color = mix(tint(i + 1), glare, 42);
|
|
828
|
+
return (_jsx(Radial, { x: x, name: `d${i}`, list: [
|
|
829
|
+
[0, color, 0.1],
|
|
830
|
+
[0.72, color, 0.16],
|
|
831
|
+
[0.9, color, 0.34],
|
|
832
|
+
[1, color, 0],
|
|
833
|
+
] }, i));
|
|
834
|
+
}), _jsx("pattern", { id: x.id("scan"), width: n(w), height: 0.8, patternUnits: "userSpaceOnUse", children: _jsx("rect", { width: n(w), height: 0.3, fill: "black", fillOpacity: 0.1 }) }), _jsx("radialGradient", { id: x.id("vignette"), cx: "50%", cy: "50%", r: "75%", children: stops([
|
|
835
|
+
[0.42, "black", 0],
|
|
836
|
+
[0.78, "black", 0.32],
|
|
837
|
+
[1, "black", 0.66],
|
|
838
|
+
]) })] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("field") }), _jsx(Glow, { x: x, name: "lamp", cx: lamp.cx, cy: lamp.cy, r: 0.6 * s, color: mix(glare, tint(3), 55), opacity: 0.3 }), _jsx("g", { className: "mb-artwork-drift", "data-drift": "2", children: discs.map((d) => (_jsx("circle", { cx: n(d.cx), cy: n(d.cy), r: n(d.r), fill: x.url(`d${d.tone}`), opacity: d.opacity }, d.key))) }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("scan") }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("vignette") })] }));
|
|
839
|
+
}
|
|
840
|
+
const painters = {
|
|
841
|
+
aurora,
|
|
842
|
+
bloom,
|
|
843
|
+
orbit,
|
|
844
|
+
strata,
|
|
845
|
+
prism,
|
|
846
|
+
halftone,
|
|
847
|
+
rays,
|
|
848
|
+
glyph,
|
|
849
|
+
ribbon,
|
|
850
|
+
topo,
|
|
851
|
+
grain: grainVariant,
|
|
852
|
+
mosaic,
|
|
853
|
+
wash,
|
|
854
|
+
horizon,
|
|
855
|
+
window: windowLight,
|
|
856
|
+
lens,
|
|
857
|
+
};
|
|
858
|
+
function Finish({ x, finish, grain, noiseSeed }) {
|
|
859
|
+
if (finish === "flat" && grain === 0)
|
|
860
|
+
return null;
|
|
861
|
+
const { w, h } = x;
|
|
862
|
+
return (_jsxs("g", { className: "mb-artwork-finish", "aria-hidden": "true", children: [finish !== "flat" ? (_jsxs(_Fragment, { children: [_jsxs("defs", { children: [_jsx(Linear, { x: x, name: "sheen-top", to: [0, 0, 0, 1], list: [[0, "white", 0.22], [0.1, "white", 0.08], [0.42, "white", 0]] }), _jsx("radialGradient", { id: x.id("vignette"), cx: "50%", cy: "42%", r: "78%", children: stops([
|
|
863
|
+
[0.5, "black", 0],
|
|
864
|
+
[0.8, "black", 0.12],
|
|
865
|
+
[1, "black", 0.3],
|
|
866
|
+
]) })] }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("vignette") }), _jsx("rect", { width: n(w), height: n(h), fill: x.url("sheen-top") })] })) : null, grain > 0 ? (_jsxs(_Fragment, { children: [_jsxs("filter", { id: x.id("grain"), x: "0", y: "0", width: n(w), height: n(h), filterUnits: "userSpaceOnUse", children: [_jsx("feTurbulence", { type: "fractalNoise", baseFrequency: "2.4", numOctaves: 2, seed: noiseSeed % 997, stitchTiles: "stitch" }), _jsx("feColorMatrix", { type: "matrix", values: "1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 1" })] }), _jsx("rect", { className: "mb-artwork-grain", width: n(w), height: n(h), filter: x.url("grain"), opacity: grain })] })) : null] }));
|
|
867
|
+
}
|
|
868
|
+
// `auto` picks among the cover variants and palettes only, so adding backgrounds didn't change any seed's picture.
|
|
869
|
+
const coverVariants = artworkVariants.filter((name) => !artworkBackgrounds.includes(name));
|
|
870
|
+
const autoPalettes = ["sunset", "ocean", "forest", "berry", "citrus", "dusk", "ember", "glacier", "candy"];
|
|
871
|
+
const timePalettes = { dawn: "dawn", day: "sky", dusk: "dusk", night: "night" };
|
|
872
|
+
function resolveVariant(seed, variant) {
|
|
873
|
+
return variant === "auto" ? coverVariants[hash(`${seed}#variant`) % coverVariants.length] : variant;
|
|
874
|
+
}
|
|
875
|
+
function resolvePalette(seed, palette, time) {
|
|
876
|
+
if (palette !== "auto")
|
|
877
|
+
return palette;
|
|
878
|
+
if (time)
|
|
879
|
+
return timePalettes[time];
|
|
880
|
+
return autoPalettes[hash(`${seed}#palette`) % autoPalettes.length];
|
|
881
|
+
}
|
|
882
|
+
function length(value) {
|
|
883
|
+
return typeof value === "number" ? `${value}px` : value;
|
|
884
|
+
}
|
|
885
|
+
/** An abstract picture drawn from a seed: album and playlist covers, card headers, placeholders. */
|
|
886
|
+
function Artwork(props) {
|
|
887
|
+
return renderArtwork(props, React.useId());
|
|
888
|
+
}
|
|
889
|
+
/** Artwork without hooks, for renderers that can't run them, like social images drawn at build time. */
|
|
890
|
+
function renderArtwork({ seed, variant = "auto", palette = "auto", colors, shape = "rounded", radius, aspect = 1, size, finish: finishProp, animated = false, title, time, dim, id, className, style, children, "aria-label": ariaLabel, ...props }, reactId) {
|
|
891
|
+
const prefix = `mb-art-${(id ?? reactId).replace(/[^A-Za-z0-9_-]/g, "")}`;
|
|
892
|
+
const key = String(seed);
|
|
893
|
+
const kind = resolveVariant(key, variant);
|
|
894
|
+
const custom = colors && colors.length > 0 ? colors : undefined;
|
|
895
|
+
const paletteName = custom ? "custom" : resolvePalette(key, palette, time);
|
|
896
|
+
const background = artworkBackgrounds.includes(kind);
|
|
897
|
+
const finish = finishProp ?? (background ? "flat" : "gloss");
|
|
898
|
+
const veil = dim !== undefined && Number.isFinite(dim) ? clamp(dim) : 0;
|
|
899
|
+
const ratio = Number.isFinite(aspect) && aspect > 0 ? aspect : 1;
|
|
900
|
+
const w = ratio >= 1 ? 100 * ratio : 100;
|
|
901
|
+
const h = ratio >= 1 ? 100 : 100 / ratio;
|
|
902
|
+
const seedNumber = hash(`${key}:${kind}`);
|
|
903
|
+
const r = createRng(seedNumber);
|
|
904
|
+
const first = r.chance(0.5) ? [1, 2] : [2, 1];
|
|
905
|
+
const order = [...first, ...r.shuffle([3, 4])];
|
|
906
|
+
const x = {
|
|
907
|
+
r,
|
|
908
|
+
w,
|
|
909
|
+
h,
|
|
910
|
+
s: Math.min(w, h),
|
|
911
|
+
cx: w / 2,
|
|
912
|
+
cy: h / 2,
|
|
913
|
+
id: (name) => `${prefix}-${name}`,
|
|
914
|
+
url: (name) => `url(#${prefix}-${name})`,
|
|
915
|
+
c: (i) => `var(--mb-artwork-${order[((i % 4) + 4) % 4]})`,
|
|
916
|
+
time,
|
|
917
|
+
};
|
|
918
|
+
const vars = { "--mb-artwork-aspect": String(Math.round(ratio * 10000) / 10000) };
|
|
919
|
+
if (size !== undefined)
|
|
920
|
+
vars["--mb-artwork-size"] = length(size);
|
|
921
|
+
if (radius !== undefined)
|
|
922
|
+
vars["--mb-artwork-radius"] = length(radius);
|
|
923
|
+
if (veil > 0)
|
|
924
|
+
vars["--mb-artwork-dim"] = String(Math.round(veil * 1000) / 1000);
|
|
925
|
+
if (custom) {
|
|
926
|
+
for (let i = 0; i < 4; i++)
|
|
927
|
+
vars[`--mb-artwork-${i + 1}`] = custom[i % Math.min(custom.length, 4)];
|
|
928
|
+
if (custom[4])
|
|
929
|
+
vars["--mb-artwork-ground"] = custom[4];
|
|
930
|
+
}
|
|
931
|
+
const name = ariaLabel ?? title;
|
|
932
|
+
const grain = kind === "grain" ? 0.5 : finish === "grain" ? 0.32 : 0;
|
|
933
|
+
return (_jsxs("span", { ...props, id: id, "data-variant": kind, "data-palette": paletteName, "data-shape": radius === undefined ? shape : undefined, "data-finish": finish, "data-time": time, "data-dim": veil > 0 ? "" : undefined, "data-animated": animated ? "" : undefined, className: join("mb-artwork", className), style: { ...vars, ...style }, children: [_jsxs("svg", { className: "mb-artwork-svg", viewBox: `0 0 ${n(w)} ${n(h)}`, preserveAspectRatio: "xMidYMid slice", focusable: "false", ...(name ? { role: "img", "aria-label": name } : { "aria-hidden": true }), children: [title ? _jsx("title", { children: title }) : null, painters[kind](x), _jsx(Finish, { x: x, finish: finish, grain: grain, noiseSeed: seedNumber })] }), children ? _jsx("span", { className: "mb-artwork-content", children: children }) : null] }));
|
|
934
|
+
}
|
|
935
|
+
export { Artwork, artworkBackgrounds, artworkPalettes, artworkTimes, artworkVariants, renderArtwork };
|