@weasel-js/paint-kinds 0.0.0-stage → 1.19.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 +16 -2
- package/dist/chunk-OZAYBSMO.js +176 -0
- package/dist/chunk-OZAYBSMO.js.map +1 -0
- package/dist/chunk-QJ5FJFNR.js +25 -0
- package/dist/chunk-QJ5FJFNR.js.map +1 -0
- package/dist/icons.table.d.ts +6 -0
- package/dist/icons.table.js +54 -0
- package/dist/icons.table.js.map +1 -0
- package/dist/icons.table.json +46 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.js +46 -0
- package/dist/index.js.map +1 -0
- package/dist/mesh.d.ts +11 -0
- package/dist/mesh.js +8 -0
- package/dist/mesh.js.map +1 -0
- package/dist/meshKindLazy.d.ts +6 -0
- package/dist/meshKindLazy.js +1664 -0
- package/dist/meshKindLazy.js.map +1 -0
- package/dist/paintKindEntry-Ct0YJP8X.d.ts +89 -0
- package/dist/react.d.ts +20 -0
- package/dist/react.js +17 -0
- package/dist/react.js.map +1 -0
- package/dist/test-seams.d.ts +4 -0
- package/dist/test-seams.js +11 -0
- package/dist/test-seams.js.map +1 -0
- package/package.json +82 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meshKindLazy.js","names":["invert","invertAffine","asMesh","asFill"],"sources":["../../geom/src/scalar.ts","../../geom/src/angle.ts","../../geom/src/affine.ts","../../geom/src/glMat3.ts","../../paint/src/hue.ts","../../paint/src/lerp.ts","../../paint/src/hex.ts","../../paint/src/hsl.ts","../../paint/src/shortArc.ts","../../paint/src/colorSpaces.ts","../../paint/src/color.ts","../../renderer/src/meshPaint/surface.ts","../../renderer/src/meshPaint/bake.ts","../../renderer/src/meshPaint/bakeCache.ts","../../renderer/src/meshPaint/meshShader.ts","../../renderer/src/gpu/webgpu/wgsl/common.ts","../../renderer/src/gpu/webgpu/wgsl/idOut.ts","../../renderer/src/gpu/webgpu/wgsl/paintVertex.ts","../../renderer/src/gpu/webgpu/wgsl/meshPaint.ts","../../renderer/src/meshPaint/meshPaint.ts","../src/meshKind.ts"],"sourcesContent":["/**\n * Scalar / 2-vector primitives and the kernel-wide epsilon policy.\n *\n * Points are scalar pairs (px, py); there is no point struct. All math is\n * f64 (JS-native). Epsilons are f32-SCALE and magnitude-relative, because\n * stored coords are quantized to Float32 (~7 significant digits).\n */\n\n/** Base relative epsilon, sized for Float32 storage (~1 part in 1e-6). */\nexport const EPS = 1e-6;\n\n/** The reciprocal of the largest condition number a matrix may have and still invert, and the fraction of a\n * quantity's own scale below which it counts as zero. Dimensionless, so a uniformly tiny matrix still inverts\n * while a large one whose determinant is only rounding does not. */\nexport const SINGULAR_RATIO = 1e-12;\n\n/** Whether a matrix whose 1-norm is `norm`, and its inverse's `inverseNorm`, is well enough conditioned to\n * invert: their product, the matrix's condition number, stays under `1 / SINGULAR_RATIO`. Both `invert`s use\n * it, so 2D and 3D refuse the same matrices. `NaN` and `Infinity` count as refused. */\nexport function invertible(norm: number, inverseNorm: number): boolean {\n return norm * inverseNorm < 1 / SINGULAR_RATIO;\n}\n\n/** `v` held to `lo`..`hi`. `lo` wins when the bounds cross; `NaN` passes through. */\nexport function clamp(v: number, lo: number, hi: number): number {\n const c = v > hi ? hi : v;\n return c < lo ? lo : c;\n}\n\n/** `v` held to `0`..`1`; `NaN` passes through. */\nexport function clamp01(v: number): number {\n return v < 0 ? 0 : v > 1 ? 1 : v;\n}\n\n/** `n` rounded to `places` decimals and written as JavaScript writes it, for a number in a file: SVG path data,\n * an attribute. A non-finite `n` writes `'0'`. */\nexport function trimNumber(n: number, places = 6): string {\n if (!Number.isFinite(n)) return '0';\n const k = 10 ** places;\n const rounded = Math.round(n * k) / k;\n // Past about 1e302, `n * k` overflows; a number that large has no decimals to round.\n return String(Number.isFinite(rounded) ? rounded : n);\n}\n\n/** The number `t` of the way from `a` to `b`; `t` outside [0, 1] extrapolates. Exactly `b` at `t = 1`, which\n * `a + (b - a) * t` can miss by an ulp, and finite where `b - a` would overflow. */\nexport function lerp(a: number, b: number, t: number): number {\n if (t === 1) return b;\n if (a === b) return a;\n const d = b - a;\n return Number.isFinite(d) ? a + d * t : a * (1 - t) + b * t;\n}\n\n/** 2D cross (wedge) product of vectors (ax,ay) and (bx,by). */\nexport function cross(ax: number, ay: number, bx: number, by: number): number {\n return ax * by - ay * bx;\n}\n\n/** Whether directions (rx,ry) and (sx,sy) are parallel to within rounding: their cross product is under\n * `SINGULAR_RATIO` of the product of their lengths. A zero vector is parallel to every direction. Points rounded\n * onto one line leave a cross product of noise, which divides to an arbitrary crossing. */\nexport function nearlyParallel(rx: number, ry: number, sx: number, sy: number): boolean {\n return !(Math.abs(rx * sy - ry * sx) > SINGULAR_RATIO * Math.hypot(rx, ry) * Math.hypot(sx, sy));\n}\n\n/** 2D dot product. */\nexport function dot(ax: number, ay: number, bx: number, by: number): number {\n return ax * bx + ay * by;\n}\n\n/** Component difference (ax-bx, ay-by) as a tuple. Cold-path use only. */\nexport function sub(ax: number, ay: number, bx: number, by: number): [number, number] {\n return [ax - bx, ay - by];\n}\n\n/** Squared length of (x,y). Avoids the sqrt; compare against squared thresholds. */\nexport function len2(x: number, y: number): number {\n return x * x + y * y;\n}\n\n/** Three-valued sign. */\nexport function sign(n: number): -1 | 0 | 1 {\n return n > 0 ? 1 : n < 0 ? -1 : 0;\n}\n\n/**\n * Magnitude-scaled approximate equality. Two values are equal when their\n * absolute difference is within EPS scaled by the larger magnitude. Every\n * comparison of two *computed coordinates* goes through this — never `===`,\n * never an f64-tight literal.\n *\n * The exception is a guard against an exact algebraic value that a formula\n * produces bit-for-bit: a homogeneous `w === 1`, a ray's `d === 0`. Those are\n * testing a branch, not comparing coordinates. Widening one to `approxEq`\n * would change which branch runs, not how precisely it runs.\n */\nexport function approxEq(a: number, b: number, eps: number = EPS): boolean {\n if (a === b) return true; // also the only way two infinities compare equal\n const diff = Math.abs(a - b);\n // Infinity/Infinity is 1, so an unguarded relative test calls every finite\n // number equal to an infinity.\n if (!Number.isFinite(diff)) return false;\n const scale = Math.max(1, Math.abs(a), Math.abs(b));\n return diff <= eps * scale;\n}\n\n/**\n * The least of `values`, or with `of`, the least `of(item, index)` over `items` without building the mapped\n * array. Answers as `Math.min(...values)` does, `Infinity` for none and `NaN` if any is `NaN`, but reads them\n * in a loop: a spread passes every value as an argument, and past about 125,000 of them throws a `RangeError`.\n */\nexport function minOf(values: Iterable<number>): number;\nexport function minOf<T>(items: Iterable<T>, of: (item: T, index: number) => number): number;\nexport function minOf<T>(items: Iterable<T>, of?: (item: T, index: number) => number): number {\n let least = Infinity;\n let i = 0;\n for (const item of items) least = Math.min(least, of ? of(item, i++) : (item as number));\n return least;\n}\n\n/** The greatest of `values`, or of `of(item, index)` over `items`: {@link minOf}'s twin, answering as\n * `Math.max(...values)` does (`-Infinity` for none, `NaN` if any is `NaN`) without spreading them. */\nexport function maxOf(values: Iterable<number>): number;\nexport function maxOf<T>(items: Iterable<T>, of: (item: T, index: number) => number): number;\nexport function maxOf<T>(items: Iterable<T>, of?: (item: T, index: number) => number): number {\n let most = -Infinity;\n let i = 0;\n for (const item of items) most = Math.max(most, of ? of(item, i++) : (item as number));\n return most;\n}\n","/** Angle units and wrapping: one definition of each, so callers agree on where a half turn lands. */\n\nconst TAU = Math.PI * 2;\n\n/** Multiply degrees by this to get radians. */\nexport const DEG_TO_RAD = Math.PI / 180;\n\n/** Multiply radians by this to get degrees. */\nexport const RAD_TO_DEG = 180 / Math.PI;\n\n/**\n * Where {@link wrapAngle} puts a half turn, the one angle with two names:\n * `'max'` at `π`, `'min'` at `-π`, and `'sign'` at whichever of the two has\n * the input's sign, so `-3π` stays a turn the negative way.\n */\nexport type HalfTurn = 'max' | 'min' | 'sign';\n\n/**\n * `a` radians as the turn of at most half a circle that reaches it, in\n * `(-π, π]` by default. `half` picks the closed end (see {@link HalfTurn}).\n * `NaN` and infinities give `NaN`.\n */\nexport function wrapAngle(a: number, half: HalfTurn = 'max'): number {\n let r = a % TAU;\n if (r > Math.PI) r -= TAU;\n else if (r < -Math.PI) r += TAU;\n if (r === Math.PI) return half === 'min' ? -Math.PI : r;\n if (r === -Math.PI) return half === 'max' ? Math.PI : r;\n return r;\n}\n\n/**\n * `a` in `[0, period)`: radians by default, `wrapPositive(deg, 360)` for\n * degrees. Never returns `period` itself, however close to zero a negative\n * `a` is. `NaN` and infinities give `NaN`.\n */\nexport function wrapPositive(a: number, period: number = TAU): number {\n return ((a % period) + period) % period;\n}\n","/**\n * 2D affine transforms in canvas/DOMMatrix order: [a, b, c, d, e, f].\n * x' = a·x + c·y + e\n * y' = b·x + d·y + f\n * Represented as a readonly 6-tuple (f64). The affine tier of the kernel.\n *\n * `glMat3.ts` beside this file holds the renderer's matrix: a 9-element\n * column-major array (a full 3×3) laid out for `uniformMatrix3fv`. Its\n * *logical element order* is identical to ours.\n */\nimport { invertible } from './scalar';\n\n/** `[a, b, c, d, e, f]`: `x' = a·x + c·y + e`, `y' = b·x + d·y + f`. */\nexport type Affine = readonly [number, number, number, number, number, number];\n\n/** The transform that leaves a point where it is. */\nexport function identity(): Affine {\n return [1, 0, 0, 1, 0, 0];\n}\n\n/** A pure translation by `(tx, ty)`. */\nexport function translate(tx: number, ty: number): Affine {\n return [1, 0, 0, 1, tx, ty];\n}\n\n/** A pure scale about the origin. Scale about another point by composing\n * translate → scale → inverse translate with `multiply`. */\nexport function scale(sx: number, sy: number): Affine {\n return [sx, 0, 0, sy, 0, 0];\n}\n\n/** A pure rotation about the origin, in radians, clockwise in canvas\n * coordinates (y down). */\nexport function rotate(rad: number): Affine {\n const c = Math.cos(rad);\n const s = Math.sin(rad);\n return [c, s, -s, c, 0, 0];\n}\n\n/** Compose: result applies `n` first, then `m` (m·n). */\nexport function multiply(m: Affine, n: Affine): Affine {\n return [\n m[0] * n[0] + m[2] * n[1],\n m[1] * n[0] + m[3] * n[1],\n m[0] * n[2] + m[2] * n[3],\n m[1] * n[2] + m[3] * n[3],\n m[0] * n[4] + m[2] * n[5] + m[4],\n m[1] * n[4] + m[3] * n[5] + m[5],\n ];\n}\n\n/** Inverse, or null when the matrix is singular, non-finite, or too ill-conditioned to invert meaningfully\n * (`invertible`). */\nexport function invert(m: Affine): Affine | null {\n const id = 1 / (m[0] * m[3] - m[1] * m[2]);\n const a = m[3] * id;\n const b = -m[1] * id;\n const c = -m[2] * id;\n const d = m[0] * id;\n // Translation never costs an inverse its precision, so only the linear part is judged.\n const norm = Math.max(Math.abs(m[0]) + Math.abs(m[1]), Math.abs(m[2]) + Math.abs(m[3]));\n if (!invertible(norm, Math.max(Math.abs(a) + Math.abs(b), Math.abs(c) + Math.abs(d)))) return null;\n if (!Number.isFinite(m[4]) || !Number.isFinite(m[5])) return null;\n return [a, b, c, d, -(m[4] * a + m[5] * c), -(m[4] * b + m[5] * d)];\n}\n\n/** Apply to a point, returning a tuple. Cold-path use; hot loops inline. */\nexport function transformPoint(m: Affine, x: number, y: number): [number, number] {\n return [m[0] * x + m[2] * y + m[4], m[1] * x + m[3] * y + m[5]];\n}\n\n/** The factor taking an extent of `from` to one of `to`: 1 where there is none to read, `from` being 0, or so\n * small (subnormal) that the ratio overflows, so a collapsed axis keeps its scale rather than turning infinite. */\nexport function extentScale(from: number, to: number): number {\n const k = to / from;\n return from !== 0 && Number.isFinite(k) ? k : 1;\n}\n\n/** Affine that maps source box (sx,sy,sw,sh) onto destination box (dx,dy,dw,dh). */\nexport function boxToBox(\n sx: number, sy: number, sw: number, sh: number,\n dx: number, dy: number, dw: number, dh: number,\n): Affine {\n const kx = extentScale(sw, dw);\n const ky = extentScale(sh, dh);\n // translate(dx,dy) · scale(kx,ky) · translate(-sx,-sy)\n return [kx, 0, 0, ky, dx - sx * kx, dy - sy * ky];\n}\n\n/** Rotation by `rad` about pivot (cx,cy): translate(c)·rotate·translate(-c). */\nexport function rotateAboutPoint(cx: number, cy: number, rad: number): Affine {\n return multiply(translate(cx, cy), multiply(rotate(rad), translate(-cx, -cy)));\n}\n\n/**\n * Apply an affine to an interleaved coord stream, returning a fresh f64\n * buffer. Command codes are unaffected — for a Bezier the transformed control\n * points define the transformed curve exactly (affine invariance), so callers\n * pass `path.coords` straight through and keep `path.commands` as-is.\n */\nexport function transformCoords(coords: ArrayLike<number>, m: Affine): Float64Array {\n const out = new Float64Array(coords.length);\n const a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];\n for (let i = 0; i + 1 < coords.length; i += 2) {\n const x = coords[i], y = coords[i + 1];\n out[i] = a * x + c * y + e;\n out[i + 1] = b * x + d * y + f;\n }\n return out;\n}\n","/**\n * 2D affine matrix utilities. Column-major 9 elements, matching\n * `WebGL2RenderingContext.uniformMatrix3fv` element order so an upload needs\n * no transpose flag.\n *\n * Layout (column-major):\n * [m00, m10, 0,\n * m01, m11, 0,\n * tx, ty, 1]\n */\n\nimport { invert as invertAffine, type Affine } from './affine';\n\n/**\n * A 2D affine transform as a column-major 9-element array, laid out as above.\n *\n * Every matrix the kit builds is a `Float64Array`: a view translation far\n * from the origin at high zoom needs more than a float32's 24 bits to hold a\n * fraction of a pixel. A `Float32Array` is accepted wherever one is read.\n * `mat3.toUniform` makes the float32 copy a GL uniform upload wants.\n */\nexport type GlMat3 = Float32Array | Float64Array;\n\nfunction create(a: number, b: number, c: number, d: number, tx: number, ty: number): GlMat3 {\n // Column-major:\n // col 0: (a, b, 0)\n // col 1: (c, d, 0)\n // col 2: (tx, ty, 1)\n return new Float64Array([a, b, 0, c, d, 0, tx, ty, 1]);\n}\n\nfunction identity(): GlMat3 {\n return create(1, 0, 0, 1, 0, 0);\n}\n\nfunction multiply(out: GlMat3, m: GlMat3): GlMat3 {\n // out := out · m (right-multiply by m).\n const a = out[0], b = out[1];\n const c = out[3], d = out[4];\n const tx = out[6], ty = out[7];\n const ma = m[0], mb = m[1];\n const mc = m[3], md = m[4];\n const mtx = m[6], mty = m[7];\n\n return create(\n a * ma + c * mb, // new a\n b * ma + d * mb, // new b\n a * mc + c * md, // new c\n b * mc + d * md, // new d\n a * mtx + c * mty + tx, // new tx\n b * mtx + d * mty + ty, // new ty\n );\n}\n\n/** `m · T(tx, ty)`: composes onto `m`, where `@weasel-js/geom`'s `translate`\n * constructs a fresh matrix. */\nfunction translated(m: GlMat3, tx: number, ty: number): GlMat3 {\n const t = create(1, 0, 0, 1, tx, ty);\n return multiply(m, t);\n}\n\n/** `m · S(sx, sy)`: composes onto `m`, where geom's `scale` constructs one. */\nfunction scaled(m: GlMat3, sx: number, sy: number): GlMat3 {\n const s = create(sx, 0, 0, sy, 0, 0);\n return multiply(m, s);\n}\n\n/** This layout read as the kernel's 6-element affine. The two carry the same\n * logical order, so the conversion is a repack and nothing else. */\nfunction toAffine(m: GlMat3): Affine {\n return [m[0], m[1], m[3], m[4], m[6], m[7]];\n}\n\n/** The kernel's affine in this layout. The inverse of {@link toAffine}. */\nfunction fromAffine(a: Affine): GlMat3 {\n return create(a[0], a[1], a[2], a[3], a[4], a[5]);\n}\n\n/** Inverse of an affine matrix, or `null` when `@weasel-js/geom`'s `invert`\n * finds it singular — the same rule, read through this layout. */\nfunction invert(m: GlMat3): GlMat3 | null {\n const inv = invertAffine(toAffine(m));\n return inv && fromAffine(inv);\n}\n\n/** A float32 copy of `m`, for `uniformMatrix3fv` or a shader uniform value. */\nfunction toUniform(m: GlMat3): Float32Array {\n return Float32Array.from(m);\n}\n\nfunction apply(m: GlMat3, x: number, y: number): [number, number] {\n const a = m[0], b = m[1];\n const c = m[3], d = m[4];\n const tx = m[6], ty = m[7];\n return [a * x + c * y + tx, b * x + d * y + ty];\n}\n\n/**\n * Map screen pixel coords (0..width on X, 0..height on Y, top-left origin)\n * into clip space (-1..1 on X, 1..-1 on Y — note Y flip so screen-down\n * matches clip-down).\n */\nfunction screenToClip(width: number, height: number): GlMat3 {\n return create(\n 2 / width, // a\n 0, // b\n 0, // c\n -2 / height, // d\n -1, // tx\n 1, // ty\n );\n}\n\n/**\n * Uniform-equivalent scale factor: the square root of the absolute\n * determinant of the linear part, i.e. the geometric mean of the two axis\n * scales. Rotation-invariant. Under non-uniform scale it is between the two\n * axes and exact on neither — the same compromise `meanScale` documents.\n */\nfunction meanScaleOf(m: GlMat3): number {\n return Math.sqrt(Math.abs(m[0] * m[4] - m[1] * m[3]));\n}\n\n/** The least any direction is scaled by the linear part — its smaller singular\n * value. What a screen length is worth in world units, at most. */\nfunction minScaleOf(m: GlMat3): number {\n const sum = m[0] * m[0] + m[1] * m[1] + m[3] * m[3] + m[4] * m[4];\n const det = m[0] * m[4] - m[1] * m[3];\n // The larger value has no cancellation; the smaller is the determinant over it.\n const max = Math.sqrt((sum + Math.sqrt(Math.max(0, sum * sum - 4 * det * det))) / 2);\n return max > 0 ? Math.abs(det) / max : 0;\n}\n\n/** The renderer's 3x3 matrix operations, as one namespace. These work on the\n * 9-element form the GL uniform upload wants — distinct from the 6-element\n * `Affine`, though the logical element order is the same. */\nexport const mat3 = {\n identity,\n toAffine,\n fromAffine,\n multiply,\n translated,\n scaled,\n invert,\n toUniform,\n apply,\n screenToClip,\n meanScaleOf,\n minScaleOf,\n};\n","/** Which way a polar space's hue goes between two endpoints, as CSS\n * `hue-interpolation-method`: the arc of at most 180°, or the other one. */\nexport type HueInterpolation = 'shorter' | 'longer';\n\n/** The hue `t` of the way from `h1` to `h2`, in degrees, along the arc `method` names, in [0, 360). Both hues are\n * taken into [0, 360) first, and a half turn keeps the sign of `h2 - h1`, as CSS's fixup does: 180° to 0° passes\n * 90°. Equal hues stay put under `longer`, where CSS would go a full turn. */\nexport function lerpHueDeg(h1: number, h2: number, t: number, method: HueInterpolation = 'shorter'): number {\n const a = wrapDeg(h1);\n let dh = wrapDeg(h2) - a;\n if (method === 'shorter') {\n if (dh > 180) dh -= 360;\n else if (dh < -180) dh += 360;\n } else if (dh > 0 && dh < 180) {\n dh -= 360;\n } else if (dh < 0 && dh > -180) {\n dh += 360;\n }\n return wrapDeg(a + dh * t);\n}\n\n/** `h` degrees in `[0, 360)`. */\nexport const wrapDeg = (h: number): number => ((h % 360) + 360) % 360;\n","/** geom's `lerp`, which this package cannot import: exactly `b` at `t = 1`, and finite where `b - a` would overflow. */\nexport function lerp(a: number, b: number, t: number): number {\n if (t === 1) return b;\n if (a === b) return a;\n const d = b - a;\n return Number.isFinite(d) ? a + d * t : a * (1 - t) + b * t;\n}\n","const HEX = /^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;\n\n/**\n * The kit's one hex color reader: `#rgb`, `#rgba`, `#rrggbb`, or `#rrggbbaa`,\n * in any case, as four 0..255 channels with alpha last (255 when the color\n * names none). `null` for anything else, a missing `#` included.\n */\nexport function parseHexBytes(input: string): [number, number, number, number] | null {\n if (!HEX.test(input)) return null;\n const digits = input.slice(1);\n const long = digits.length <= 4 ? digits.replace(/./g, '$&$&') : digits;\n const byte = (i: number): number => Number.parseInt(long.slice(i, i + 2), 16);\n return [byte(0), byte(2), byte(4), long.length === 8 ? byte(6) : 255];\n}\n\n/** The kit's one hex color writer: a 0..255 channel as two hex digits, rounded and clamped; NaN as 0. */\nexport function byteHex(v: number): string {\n return (Math.max(0, Math.min(255, Math.round(v))) || 0).toString(16).padStart(2, '0');\n}\n\n/** A hex color's red, green, and blue as 0..255, its alpha dropped. Throws on anything {@link parseHexBytes} does not read. */\nexport function hexToRgbBytes(input: string): [number, number, number] {\n const bytes = parseHexBytes(input);\n if (!bytes) throw new Error(`hexToRgbBytes: not a hex color \"${input}\"; pass #rgb, #rgba, #rrggbb or #rrggbbaa, or use parseColor for any CSS color`);\n return [bytes[0], bytes[1], bytes[2]];\n}\n\n/** An RGBA pixel's bytes as `#rrggbb`, or `null` where it is fully transparent: the color a\n * sampler reports for what is drawn at a point. Alpha is dropped, not composited. */\nexport function rgbaHex(rgba: ArrayLike<number>): string | null {\n if (rgba[3] === 0) return null;\n return `#${byteHex(rgba[0])}${byteHex(rgba[1])}${byteHex(rgba[2])}`;\n}\n","// HSL, the polar form of gamma-encoded sRGB that CSS `hsl()` writes.\n\nimport { wrapDeg } from './hue';\n\n/** HSL to sRGB. Hue in degrees, any number of turns; saturation, lightness and output all 0..1. */\nexport function hslToSrgb(h: number, s: number, l: number): [number, number, number] {\n if (s === 0) return [l, l, l];\n const q = l < 0.5 ? l * (1 + s) : l + s - l * s;\n const p = 2 * l - q;\n const turn = h / 360;\n const hk = turn >= 0 && turn < 1 ? turn : turn - Math.floor(turn);\n return [hueToChannel(p, q, hk + 1 / 3), hueToChannel(p, q, hk), hueToChannel(p, q, hk - 1 / 3)];\n}\n\nfunction hueToChannel(p: number, q: number, t: number): number {\n if (t < 0) t += 1;\n if (t > 1) t -= 1;\n if (t < 1 / 6) return p + (q - p) * 6 * t;\n if (t < 1 / 2) return q;\n if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;\n return p;\n}\n\n/** sRGB (0..1) to HSL: `[hue°, saturation, lightness]`, hue in 0..360. An\n * achromatic color reports hue 0 and saturation 0. */\nexport function srgbToHsl(r: number, g: number, b: number): [number, number, number] {\n const max = Math.max(r, g, b);\n const min = Math.min(r, g, b);\n const l = (max + min) / 2;\n const d = max - min;\n if (d === 0) return [0, 0, l];\n // Near white or black the denominator cancels to 0, or below d, while d does not.\n const s = Math.min(1, d / (1 - Math.abs(2 * l - 1)));\n let h: number;\n if (max === r) h = ((g - b) / d) % 6;\n else if (max === g) h = (b - r) / d + 2;\n else h = (r - g) / d + 4;\n return [wrapDeg(h * 60), s, l];\n}\n","const TWO_PI = Math.PI * 2;\n\n/** `dh` radians as the shorter arc, in [-π, π]: a half turn keeps its sign. NaN for NaN and ±∞.\n * geom's `wrapAngle(dh, 'sign')`, kept here because paint does not depend on geom. */\nexport function shortArc(dh: number): number {\n const r = dh % TWO_PI;\n return r > Math.PI ? r - TWO_PI : r < -Math.PI ? r + TWO_PI : r;\n}\n","// sRGB ↔ OKLab conversion. Reference: https://bottosson.github.io/posts/oklab/\n\nimport { lerpHueDeg, wrapDeg, type HueInterpolation } from './hue';\nimport { lerp } from './lerp';\nimport { byteHex, hexToRgbBytes } from './hex';\nimport { hslToSrgb, srgbToHsl } from './hsl';\nimport { shortArc } from './shortArc';\n\nconst SRGB_TO_LINEAR: Float64Array = (() => {\n const lut = new Float64Array(256);\n for (let i = 0; i < 256; i++) {\n const c = i / 255;\n lut[i] = c <= 0.04045 ? c / 12.92 : Math.pow((c + 0.055) / 1.055, 2.4);\n }\n return lut;\n})();\n\nfunction linearToSrgbByte(c: number): number {\n if (c <= 0) return 0;\n if (c >= 1) return 255;\n const v = c <= 0.0031308 ? c * 12.92 : 1.055 * Math.pow(c, 1 / 2.4) - 0.055;\n return Math.round(v * 255);\n}\n\n/** 0..1 float channel to the 8-bit index the LUTs are cut for. Rounds and\n * clamps; `& 0xff` would truncate, and wrap anything out of range. */\nconst f2u = (v: number): number => Math.max(0, Math.min(255, Math.round(v * 255)));\n\n/**\n * Convert a 0..1 float sRGB triple to OKLab — the renderer's own color space,\n * and what a caller holding a `parseColor` result has. Rounds into the u8\n * grid the way every other float→u8 crossing in this file does, rather than\n * leaving each caller to pick a convention.\n */\nexport function srgbFloatToOklab(r: number, g: number, b: number): [number, number, number] {\n return srgbU8ToOklab(f2u(r), f2u(g), f2u(b));\n}\n\n/** Convert an 8-bit sRGB triple to OKLab. Channels are indices into a 256-entry\n * LUT: pass integers, or `srgbFloatToOklab` for 0..1 floats. */\nexport function srgbU8ToOklab(r: number, g: number, b: number): [number, number, number] {\n return linearSrgbToOklab(SRGB_TO_LINEAR[r & 0xff], SRGB_TO_LINEAR[g & 0xff], SRGB_TO_LINEAR[b & 0xff]);\n}\n\n/** Linear-light sRGB (0..1 floats, unclamped) to OKLab. */\nexport function linearSrgbToOklab(rl: number, gl: number, bl: number): [number, number, number] {\n const l = 0.4122214708 * rl + 0.5363325363 * gl + 0.0514459929 * bl;\n const m = 0.2119034982 * rl + 0.6806995451 * gl + 0.1073969566 * bl;\n const s = 0.0883024619 * rl + 0.2817188376 * gl + 0.6299787005 * bl;\n const lp = Math.cbrt(l);\n const mp = Math.cbrt(m);\n const sp = Math.cbrt(s);\n return [\n 0.2104542553 * lp + 0.7936177850 * mp - 0.0040720468 * sp,\n 1.9779984951 * lp - 2.4285922050 * mp + 0.4505937099 * sp,\n 0.0259040371 * lp + 0.7827717662 * mp - 0.8086757660 * sp,\n ];\n}\n\n/** OKLab to linear-light sRGB. Not gamut-clipped: out-of-gamut colors come\n * back with channels outside 0..1. */\nexport function oklabToLinearSrgb(L: number, A: number, B: number): [number, number, number] {\n const lp = L + 0.3963377774 * A + 0.2158037573 * B;\n const mp = L - 0.1055613458 * A - 0.0638541728 * B;\n const sp = L - 0.0894841775 * A - 1.2914855480 * B;\n const l = lp * lp * lp;\n const m = mp * mp * mp;\n const s = sp * sp * sp;\n return [\n +4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,\n -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,\n -0.0041960863 * l - 0.7034186147 * m + 1.7076147010 * s,\n ];\n}\n\nfunction inGamut(rl: number, gl: number, bl: number): boolean {\n // Small epsilon absorbs float-roundtrip noise on pure-primary colors.\n const eps = 1e-6;\n return (\n rl >= -eps && rl <= 1 + eps &&\n gl >= -eps && gl <= 1 + eps &&\n bl >= -eps && bl <= 1 + eps\n );\n}\n\nfunction clipToGamut(L: number, A: number, B: number): [number, number, number] {\n let [rl, gl, bl] = oklabToLinearSrgb(L, A, B);\n if (inGamut(rl, gl, bl)) return [rl, gl, bl];\n let lo = 0;\n let hi = 1;\n // 5 iterations → ~3% chroma precision; sufficient for u8 output.\n for (let i = 0; i < 5; i++) {\n const t = (lo + hi) / 2;\n [rl, gl, bl] = oklabToLinearSrgb(L, A * t, B * t);\n if (inGamut(rl, gl, bl)) lo = t; else hi = t;\n }\n [rl, gl, bl] = oklabToLinearSrgb(L, A * lo, B * lo);\n return [rl, gl, bl];\n}\n\n/** Convert OKLab back to an 8-bit sRGB triple, clamped into gamut. */\nexport function oklabToSrgbU8(L: number, A: number, B: number): [number, number, number] {\n const [rl, gl, bl] = clipToGamut(L, A, B);\n return [linearToSrgbByte(rl), linearToSrgbByte(gl), linearToSrgbByte(bl)];\n}\n\n/** Blend two 8-bit sRGB colors through OKLab. Perceptually even, and it does\n * not pass through the muddy midpoints an sRGB blend produces between\n * complementary hues. */\nexport function lerpOklab(\n from: readonly [number, number, number],\n to: readonly [number, number, number],\n t: number,\n): [number, number, number] {\n return [\n lerp(from[0], to[0], t),\n lerp(from[1], to[1], t),\n lerp(from[2], to[2], t),\n ];\n}\n\n/** Convert OKLab (L, a, b) to OKLCh (L, C, h). h is in radians, range [-π, π]. */\nexport function oklabToOklch(L: number, A: number, B: number): [number, number, number] {\n const C = Math.hypot(A, B);\n const h = Math.atan2(B, A);\n return [L, C, h];\n}\n\n/** Convert OKLCh (L, C, h) to OKLab (L, a, b). h is in radians. */\nexport function oklchToOklab(L: number, C: number, h: number): [number, number, number] {\n return [L, C * Math.cos(h), C * Math.sin(h)];\n}\n\n/** Lerp OKLCh values with shortest-arc hue interpolation. Lightness and\n * chroma lerp linearly. When chroma is near zero on either endpoint, hue\n * is taken from the other endpoint (avoids hue snap-from-undefined).\n * h inputs are in radians. */\nexport function lerpOklch(\n from: readonly [number, number, number],\n to: readonly [number, number, number],\n t: number,\n): [number, number, number] {\n const [L1, C1, h1Raw] = from;\n const [L2, C2, h2Raw] = to;\n const C_EPS = 1e-4;\n // When one endpoint is near-achromatic, take hue from the other endpoint\n // to avoid spurious arc rotation through undefined hue space.\n const h1 = C1 < C_EPS ? h2Raw : h1Raw;\n const h2 = C2 < C_EPS ? h1Raw : h2Raw;\n const dh = shortArc(h2 - h1);\n return [\n lerp(L1, L2, t),\n lerp(C1, C2, t),\n h1 + dh * t,\n ];\n}\n\n/** Which space a color blend is computed in. `'rgb'` is cheapest; `'oklab'`\n * is perceptually even; `'oklch'` additionally travels around the hue wheel\n * rather than through it. */\nexport type ColorSpace = 'rgb' | 'oklab' | 'oklch';\n\nconst u2f = (v: number): number => v / 255;\n\n/** Lerp a flat RGBA color array `from` toward `to`. Inputs are 0..1\n * floats (the renderer's color space); outputs are 0..1 floats too.\n * Alpha is always linearly lerped; RGB channels are lerped in the\n * requested color space. OKLab / OKLCh paths bounce through u8 because\n * the gamma-correction LUT and gamut-clip routines are byte-keyed —\n * the round-trip is lossy at <1% per channel, well under the visible\n * threshold for these animations. */\nexport function lerpColorArray(\n from: readonly number[],\n to: readonly number[],\n t: number,\n space: ColorSpace = 'rgb',\n): number[] {\n if (from.length !== to.length) {\n throw new Error(`lerpColorArray: length mismatch (from=${from.length}, to=${to.length})`);\n }\n if (from.length % 4 !== 0) {\n throw new Error(`lerpColorArray: length ${from.length} not divisible by 4`);\n }\n const out = new Array<number>(from.length);\n const n = from.length / 4;\n if (space === 'rgb') {\n // Pure float lerp — no rounding (which previously discretized 0..1\n // inputs to 0/1, giving the cycle its 'choppy 8-corner' look).\n for (let i = 0; i < from.length; i++) {\n out[i] = lerp(from[i], to[i], t);\n }\n return out;\n }\n if (space === 'oklch') {\n for (let i = 0; i < n; i++) {\n const k = i * 4;\n const fLab = srgbU8ToOklab(f2u(from[k]), f2u(from[k + 1]), f2u(from[k + 2]));\n const tLab = srgbU8ToOklab(f2u(to[k]), f2u(to[k + 1]), f2u(to[k + 2]));\n const fLch = oklabToOklch(fLab[0], fLab[1], fLab[2]);\n const tLch = oklabToOklch(tLab[0], tLab[1], tLab[2]);\n const midLch = lerpOklch(fLch, tLch, t);\n const midLab = oklchToOklab(midLch[0], midLch[1], midLch[2]);\n const [r, g, b] = oklabToSrgbU8(midLab[0], midLab[1], midLab[2]);\n out[k] = u2f(r);\n out[k + 1] = u2f(g);\n out[k + 2] = u2f(b);\n out[k + 3] = lerp(from[k + 3], to[k + 3], t);\n }\n return out;\n }\n for (let i = 0; i < n; i++) {\n const k = i * 4;\n const fLab = srgbU8ToOklab(f2u(from[k]), f2u(from[k + 1]), f2u(from[k + 2]));\n const tLab = srgbU8ToOklab(f2u(to[k]), f2u(to[k + 1]), f2u(to[k + 2]));\n const mid = lerpOklab(fLab, tLab, t);\n const [r, g, b] = oklabToSrgbU8(mid[0], mid[1], mid[2]);\n out[k] = u2f(r);\n out[k + 1] = u2f(g);\n out[k + 2] = u2f(b);\n out[k + 3] = lerp(from[k + 3], to[k + 3], t);\n }\n return out;\n}\n\n// ---------------------------------------------------------------------------\n// OKLCh in degrees\n// ---------------------------------------------------------------------------\n\n/**\n * OKLCh with the hue in **degrees**, and `#rrggbb` on the other side.\n *\n * The helpers above take radians, because that is what the math wants. Every\n * consumer that authors colors — a theme ramp, a palette generator — wants\n * degrees and a hex string, and two packages independently built the same\n * wrapper before this existed.\n */\nexport interface OklchDeg {\n readonly L: number;\n readonly C: number;\n /** 0..360. */\n readonly H: number;\n}\n\n/**\n * OKLCh (hue in degrees) to `#rrggbb`. Over-saturated requests come back at\n * the gamut boundary: `oklabToSrgbU8` clips chroma at constant lightness, which\n * is what lets a caller find a hue's ceiling by asking for far more than exists.\n */\nexport function oklchDegToHex(L: number, C: number, hueDeg: number): string {\n const [l, a, b] = oklchToOklab(L, C, (hueDeg * Math.PI) / 180);\n const [r, g, bl] = oklabToSrgbU8(l, a, b);\n return `#${byteHex(r)}${byteHex(g)}${byteHex(bl)}`;\n}\n\n/** A hex color (`#rgb`, `#rgba`, `#rrggbb`, or `#rrggbbaa`, alpha ignored) to\n * OKLCh with the hue wrapped into 0..360. Throws on anything else. */\nexport function hexToOklchDeg(hex: string): OklchDeg {\n const [L, A, B] = srgbU8ToOklab(...hexToRgbBytes(hex));\n const [l, c, h] = oklabToOklch(L, A, B);\n return { L: l, C: c, H: wrapDeg((h * 180) / Math.PI) };\n}\n\n// ---------------------------------------------------------------------------\n// Float sRGB transfer and interpolation across spaces\n// ---------------------------------------------------------------------------\n\n/** sRGB-encoded channel (0..1) to linear light. Unclamped; odd-symmetric\n * below zero, as CSS `srgb-linear` extends it. */\nexport function srgbToLinear(c: number): number {\n const a = Math.abs(c);\n const v = a <= 0.04045 ? a / 12.92 : Math.pow((a + 0.055) / 1.055, 2.4);\n return c < 0 ? -v : v;\n}\n\n/** Linear-light channel to sRGB encoding (0..1). Unclamped. */\nexport function linearToSrgb(c: number): number {\n const a = Math.abs(c);\n const v = a <= 0.0031308 ? a * 12.92 : 1.055 * Math.pow(a, 1 / 2.4) - 0.055;\n return c < 0 ? -v : v;\n}\n\n/**\n * The space a color interpolation runs in, spelled as CSS `color-mix()` spells\n * them. `'srgb'` and `'srgb-linear'` blend gamma-encoded and linear-light\n * channels; `'oklab'` blends perceptual coordinates; `'oklch'` and `'hsl'` are\n * polar, so their hue travels around the wheel rather than through it.\n *\n * Distinct from {@link ColorSpace}, the gradient and animation vocabulary,\n * which keeps its `'rgb'` spelling and its byte-precision paths.\n */\nexport type ColorInterpolationSpace = 'oklch' | 'oklab' | 'hsl' | 'srgb' | 'srgb-linear';\n\n/** An endpoint with less chroma (OKLCH) or saturation (HSL) than this has no\n * hue of its own. */\nconst ACHROMATIC_EPS = 1e-4;\n\ntype Polar = readonly [radius: number, hueDeg: number, axis: number];\n\nfunction lerpPolar(a: Polar, b: Polar, t: number, method: HueInterpolation, hueT: number): [number, number, number] {\n const h1 = a[0] < ACHROMATIC_EPS ? b[1] : a[1];\n const h2 = b[0] < ACHROMATIC_EPS ? a[1] : b[1];\n return [lerp(a[0], b[0], t), lerpHueDeg(h1, h2, hueT, method), lerp(a[2], b[2], t)];\n}\n\ntype Rgb = readonly [number, number, number];\n\nconst lerp3 = (a: Rgb, b: Rgb, t: number): [number, number, number] => [\n lerp(a[0], b[0], t),\n lerp(a[1], b[1], t),\n lerp(a[2], b[2], t),\n];\n\nconst clamp01 = (v: number): number => (v < 0 ? 0 : v > 1 ? 1 : v);\n\nconst srgbToOklabFloat = (c: Rgb): [number, number, number] =>\n linearSrgbToOklab(srgbToLinear(c[0]), srgbToLinear(c[1]), srgbToLinear(c[2]));\n\nfunction oklabToSrgbClipped(L: number, A: number, B: number): [number, number, number] {\n const [rl, gl, bl] = clipToGamut(L, A, B);\n return [clamp01(linearToSrgb(rl)), clamp01(linearToSrgb(gl)), clamp01(linearToSrgb(bl))];\n}\n\n/**\n * Interpolate between two sRGB colors (0..1 floats) in `space`, at `t` in 0..1.\n * Float precision throughout, with no byte round-trip. The result is sRGB;\n * only OKLab and OKLCH blends can leave gamut, and those come back\n * chroma-clipped at constant OKLab lightness.\n *\n * `hue` applies to the polar spaces only. An endpoint with no chroma (OKLCH)\n * or no saturation (HSL) borrows the other endpoint's hue, so a ramp to white\n * or black holds its hue instead of sweeping from red.\n */\nexport function interpolateSrgb(\n from: readonly [number, number, number],\n to: readonly [number, number, number],\n t: number,\n space: ColorInterpolationSpace = 'oklch',\n hue: HueInterpolation = 'shorter',\n): [number, number, number] {\n return interpolateSrgbSplit(from, to, t, t, space, hue);\n}\n\n/** {@link interpolateSrgb} with the hue of a polar space at `hueT` and everything else at `t`, as a premultiplied mix needs. */\nexport function interpolateSrgbSplit(\n from: Rgb,\n to: Rgb,\n t: number,\n hueT: number,\n space: ColorInterpolationSpace,\n hue: HueInterpolation,\n): [number, number, number] {\n switch (space) {\n case 'srgb':\n return lerp3(from, to, t);\n case 'srgb-linear': {\n const lin = (c: Rgb): Rgb => [srgbToLinear(c[0]), srgbToLinear(c[1]), srgbToLinear(c[2])];\n const [r, g, b] = lerp3(lin(from), lin(to), t);\n return [linearToSrgb(r), linearToSrgb(g), linearToSrgb(b)];\n }\n case 'oklab': {\n const [L, A, B] = lerp3(srgbToOklabFloat(from), srgbToOklabFloat(to), t);\n return oklabToSrgbClipped(L, A, B);\n }\n case 'oklch': {\n const polar = (c: Rgb): Polar => {\n const [L, C, h] = oklabToOklch(...srgbToOklabFloat(c));\n return [C, wrapDeg((h * 180) / Math.PI), L];\n };\n const [C, H, L] = lerpPolar(polar(from), polar(to), t, hue, hueT);\n const [l, a, b] = oklchToOklab(L, C, (H * Math.PI) / 180);\n return oklabToSrgbClipped(l, a, b);\n }\n case 'hsl': {\n const polar = (c: Rgb): Polar => {\n const [h, s, l] = srgbToHsl(c[0], c[1], c[2]);\n return [s, h, l];\n };\n const [s, h, l] = lerpPolar(polar(from), polar(to), t, hue, hueT);\n return hslToSrgb(h, s, l);\n }\n }\n}\n","import { linearToSrgb, oklabToLinearSrgb, oklchToOklab } from './colorSpaces';\nimport { hslToSrgb } from './hsl';\nimport { byteHex, parseHexBytes } from './hex';\nimport { wrapDeg } from './hue';\n\n/**\n * Parse a CSS color string into [r, g, b, a] with 0..1 components.\n *\n * Supported forms:\n * - Hex: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa` (any case)\n * - `rgb()` / `rgba()` with integer, float, or percent R/G/B; number or\n * percent alpha; commas or modern space-separated `R G B / A` syntax\n * - `hsl()` / `hsla()` with hue as a unitless number (deg) or with `deg`,\n * `rad`, `grad`, `turn` units; saturation/lightness as percent (or\n * unitless 0..100, as CSS Color 4 reads it); same alpha rules and separator rules\n * as `rgb()`\n * - The 148 CSS named colors plus `transparent`\n * - `color(srgb …)` and `color(srgb-linear …)`; `oklab()` and `oklch()`, clamped into sRGB\n *\n * Not supported: `lab()`, `lch()`, other `color()` spaces, `currentColor`, system\n * colors. Throws on anything unrecognized.\n *\n * Results are cached by input-string identity and shared, which is why the\n * tuple is read-only: renderer hot paths call this per frame.\n */\nexport function parseColor(input: string): readonly [number, number, number, number] {\n const cached = CACHE.get(input);\n if (cached !== undefined) return cached;\n const result = parseColorUncached(input);\n if (CACHE.size >= CACHE_MAX) CACHE.clear();\n CACHE.set(input, result);\n return result;\n}\n\n/** {@link parseColor}'s reading of `input`, or null where it would throw. The tuple is read-only, as there. */\nexport function tryParseColor(input: string): readonly [number, number, number, number] | null {\n try {\n return parseColor(input);\n } catch {\n return null;\n }\n}\n\nconst CACHE = new Map<string, [number, number, number, number]>();\nconst CACHE_MAX = 1024;\n\nfunction parseColorUncached(input: string): [number, number, number, number] {\n const s = input.trim();\n if (s.startsWith('#')) return parseHex(s);\n\n const lower = s.toLowerCase();\n\n if (Object.hasOwn(NAMED_COLORS, lower)) return NAMED_COLORS[lower]!;\n\n if (lower.startsWith('rgb')) {\n const parsed = parseRgbFunction(lower);\n if (parsed) return parsed;\n }\n if (lower.startsWith('hsl')) {\n const parsed = parseHslFunction(lower);\n if (parsed) return parsed;\n }\n if (lower.startsWith('color(')) {\n const parsed = parseColorFunction(lower);\n if (parsed) return parsed;\n }\n if (lower.startsWith('ok')) {\n const parsed = parseOkFunction(lower);\n if (parsed) return parsed;\n }\n\n throw new Error(`parseColor: unrecognized color \"${input}\"`);\n}\n\n/** @internal Test-only: drops the color cache so tests can assert behavior in\n * isolation. Never call from production code. */\nexport function __resetParseColorCache(): void {\n CACHE.clear();\n}\n\n/** `parseColor` as four integer 0..255 channels, alpha last, as `parseHexBytes` returns them. */\nexport function parseColorBytes(input: string): [number, number, number, number] {\n const [r, g, b, a] = parseColor(input);\n return [\n Math.round(r * 255),\n Math.round(g * 255),\n Math.round(b * 255),\n Math.round(a * 255),\n ];\n}\n\n/** The hex form {@link normalizeHex} writes: `'rgb'` drops alpha, `'rgba'` always writes it (`ff` when none was named). */\nexport type HexForm = 'rgb' | 'rgba';\n\n/**\n * Canonicalize a hex color string to lowercase `#rrggbb` or `#rrggbbaa`: the\n * latter when `form` is `'rgba'`, or with no `form`, when the input names an alpha.\n *\n * Accepts: `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, with or without the\n * leading `#`, any case. Throws on other inputs.\n */\nexport function normalizeHex(input: string, form?: HexForm): string {\n const hex = tryNormalizeHex(input, form);\n if (hex === null) throw new Error(`normalizeHex: invalid hex \"${input}\"`);\n return hex;\n}\n\n/** {@link normalizeHex}, null where it would throw, the way {@link tryParseColor} answers. */\nexport function tryNormalizeHex(input: string, form?: HexForm): string | null {\n const trimmed = input.trim();\n const hashed = trimmed.startsWith('#') ? trimmed : `#${trimmed}`;\n const bytes = parseHexBytes(hashed);\n if (!bytes) return null;\n const digits = bytes.map(byteHex).join('');\n const alpha = form ? form === 'rgba' : hashed.length === 5 || hashed.length === 9;\n return `#${alpha ? digits : digits.slice(0, 6)}`;\n}\n\n/**\n * Parse a hex color into [r, g, b, a] with 0..1 components. Accepts the same\n * forms as `normalizeHex`, including a missing leading `#`.\n */\nexport function hexToRgba(input: string): [number, number, number, number] {\n return parseHex(normalizeHex(input));\n}\n\n/**\n * Format [r, g, b, a] (0..1 components) as a hex string. Emits `#rrggbb` when\n * alpha is exactly 1 (or omitted), otherwise `#rrggbbaa`.\n */\nexport function rgbaToHex(rgba: readonly [number, number, number, number] | readonly [number, number, number]): string {\n const [r, g, b] = rgba;\n const a = rgba.length === 4 ? rgba[3] : 1;\n const f = (n: number) => byteHex(n * 255);\n const base = `#${f(r)}${f(g)}${f(b)}`;\n return a >= 1 ? base : `${base}${f(a)}`;\n}\n\nfunction parseHex(s: string): [number, number, number, number] {\n const bytes = parseHexBytes(s);\n if (!bytes) throw new Error(`parseColor: invalid hex \"${s}\"`);\n return [bytes[0] / 255, bytes[1] / 255, bytes[2] / 255, bytes[3] / 255];\n}\n\n/** Match `name( body )` and return the trimmed body, or null. */\nfunction unwrapFn(s: string, name: string): string | null {\n if (!s.startsWith(name + '(') || !s.endsWith(')')) return null;\n return s.slice(name.length + 1, -1).trim();\n}\n\n/**\n * Split a function body into the value tokens (3 channels + optional alpha).\n * Supports both legacy `r, g, b[, a]` and modern `r g b[ / a]` separators.\n * Returns null if the token count is wrong.\n */\nfunction splitChannels(body: string): { rgb: [string, string, string]; alpha: string | null } | null {\n if (body.includes(',')) {\n const parts = body.split(',').map((p) => p.trim());\n if (parts.length !== 3 && parts.length !== 4) return null;\n return {\n rgb: [parts[0], parts[1], parts[2]],\n alpha: parts.length === 4 ? parts[3] : null,\n };\n }\n // Modern syntax: whitespace-separated, with optional `/ alpha` tail.\n const slash = body.indexOf('/');\n const head = (slash === -1 ? body : body.slice(0, slash)).trim();\n const alpha = slash === -1 ? null : body.slice(slash + 1).trim();\n const parts = head.split(/\\s+/);\n if (parts.length !== 3) return null;\n if (alpha !== null && alpha === '') return null;\n return { rgb: [parts[0], parts[1], parts[2]], alpha };\n}\n\nconst CSS_NUMBER = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:e[+-]?\\d+)?$/;\n\n/** A CSS `<number>` token, or null: `Number` alone reads `''` as 0 and accepts `0x10`. */\nfunction cssNumber(tok: string): number | null {\n if (!CSS_NUMBER.test(tok)) return null;\n const n = Number(tok);\n return Number.isFinite(n) ? n : null;\n}\n\n/** Parse a channel value: integer, float, or percent. Returns 0..1 (with `max` as the integer scale). */\nfunction parseChannel(tok: string, max: number): number | null {\n const percent = tok.endsWith('%');\n const n = cssNumber(percent ? tok.slice(0, -1) : tok);\n return n === null ? null : clamp01(n / (percent ? 100 : max));\n}\n\n/** Alpha may be a number 0..1 or a percent; absent is opaque. */\nfunction parseAlpha(tok: string | null): number | null {\n return tok === null ? 1 : parseChannel(tok, 1);\n}\n\nfunction parseRgbFunction(s: string): [number, number, number, number] | null {\n const body = unwrapFn(s, 'rgba') ?? unwrapFn(s, 'rgb');\n if (body === null) return null;\n const channels = splitChannels(body);\n if (!channels) return null;\n const r = parseChannel(channels.rgb[0], 255);\n const g = parseChannel(channels.rgb[1], 255);\n const b = parseChannel(channels.rgb[2], 255);\n const a = parseAlpha(channels.alpha);\n if (r === null || g === null || b === null || a === null) return null;\n return [r, g, b, a];\n}\n\nfunction parseHslFunction(s: string): [number, number, number, number] | null {\n const body = unwrapFn(s, 'hsla') ?? unwrapFn(s, 'hsl');\n if (body === null) return null;\n const channels = splitChannels(body);\n if (!channels) return null;\n const h = parseHue(channels.rgb[0]);\n // CSS Color 4 reads a unitless saturation or lightness on the percent scale: 50 is 50%.\n const sat = parseChannel(channels.rgb[1], 100);\n const lit = parseChannel(channels.rgb[2], 100);\n const a = parseAlpha(channels.alpha);\n if (h === null || sat === null || lit === null || a === null) return null;\n const [r, g, b] = hslToSrgb(h, sat, lit);\n return [r, g, b, a];\n}\n\n/** `color(srgb …)` or `color(srgb-linear …)`, channels as numbers 0..1 or percents. */\nfunction parseColorFunction(s: string): [number, number, number, number] | null {\n const body = unwrapFn(s, 'color');\n const space = body?.match(/^(srgb-linear|srgb)\\s+/);\n if (!body || !space || body.includes(',')) return null;\n const channels = splitChannels(body.slice(space[0].length));\n if (!channels) return null;\n const rgb = channels.rgb.map((tok) => parseChannel(tok, 1));\n const a = parseAlpha(channels.alpha);\n if (rgb.some((c) => c === null) || a === null) return null;\n const [r, g, b] = (space[1] === 'srgb' ? rgb : rgb.map((c) => linearToSrgb(c as number))) as number[];\n return [clamp01(r as number), clamp01(g as number), clamp01(b as number), a];\n}\n\n/** `oklab(L a b)` or `oklch(L C h)`, clamped into sRGB. L is 0..1 or a percent; a, b and C are numbers. */\nfunction parseOkFunction(s: string): [number, number, number, number] | null {\n const lch = unwrapFn(s, 'oklch');\n const body = lch ?? unwrapFn(s, 'oklab');\n if (body === null || body.includes(',')) return null;\n const channels = splitChannels(body);\n if (!channels) return null;\n const L = parsePercentOrNumber(channels.rgb[0]);\n const second = cssNumber(channels.rgb[1]);\n const third = lch !== null ? parseHue(channels.rgb[2]) : cssNumber(channels.rgb[2]);\n const alpha = parseAlpha(channels.alpha);\n if (L === null || second === null || third === null || alpha === null) return null;\n // CSS clamps a negative chroma to 0 rather than turning the hue half a turn.\n const [, A, B] = lch !== null ? oklchToOklab(L, Math.max(0, second), third * (Math.PI / 180)) : [L, second, third];\n const [r, g, b] = oklabToLinearSrgb(L, A, B).map((c) => clamp01(linearToSrgb(c)));\n return [r as number, g as number, b as number, alpha];\n}\n\n/** Parse a hue token:`<number>`, `<number>deg`, `<number>rad`, `<number>grad`, `<number>turn`. Returns degrees 0..360 (modulo). */\nfunction parseHue(tok: string): number | null {\n const unit = /(deg|grad|rad|turn)$/.exec(tok)?.[1];\n const n = cssNumber(unit === undefined ? tok : tok.slice(0, -unit.length));\n if (n === null) return null;\n // 400grad = 360deg\n const deg = unit === 'grad' ? n * 0.9 : unit === 'rad' ? n * (180 / Math.PI) : unit === 'turn' ? n * 360 : n;\n return wrapDeg(deg);\n}\n\n/** An OKLab lightness: a percent or a unitless number 0..1. */\nfunction parsePercentOrNumber(tok: string): number | null {\n return parseChannel(tok, 1);\n}\n\nfunction clamp01(n: number): number {\n return n < 0 ? 0 : n > 1 ? 1 : n;\n}\n\n// CSS Color Module Level 4 named colors. Stored as already-resolved tuples so\n// lookup is O(1) and avoids a second parse hop.\nconst NAMED_COLORS: Record<string, [number, number, number, number]> = (() => {\n const hex: Record<string, number> = {\n aliceblue: 0xf0f8ff, antiquewhite: 0xfaebd7, aqua: 0x00ffff, aquamarine: 0x7fffd4,\n azure: 0xf0ffff, beige: 0xf5f5dc, bisque: 0xffe4c4, black: 0x000000,\n blanchedalmond: 0xffebcd, blue: 0x0000ff, blueviolet: 0x8a2be2, brown: 0xa52a2a,\n burlywood: 0xdeb887, cadetblue: 0x5f9ea0, chartreuse: 0x7fff00, chocolate: 0xd2691e,\n coral: 0xff7f50, cornflowerblue: 0x6495ed, cornsilk: 0xfff8dc, crimson: 0xdc143c,\n cyan: 0x00ffff, darkblue: 0x00008b, darkcyan: 0x008b8b, darkgoldenrod: 0xb8860b,\n darkgray: 0xa9a9a9, darkgreen: 0x006400, darkgrey: 0xa9a9a9, darkkhaki: 0xbdb76b,\n darkmagenta: 0x8b008b, darkolivegreen: 0x556b2f, darkorange: 0xff8c00, darkorchid: 0x9932cc,\n darkred: 0x8b0000, darksalmon: 0xe9967a, darkseagreen: 0x8fbc8f, darkslateblue: 0x483d8b,\n darkslategray: 0x2f4f4f, darkslategrey: 0x2f4f4f, darkturquoise: 0x00ced1, darkviolet: 0x9400d3,\n deeppink: 0xff1493, deepskyblue: 0x00bfff, dimgray: 0x696969, dimgrey: 0x696969,\n dodgerblue: 0x1e90ff, firebrick: 0xb22222, floralwhite: 0xfffaf0, forestgreen: 0x228b22,\n fuchsia: 0xff00ff, gainsboro: 0xdcdcdc, ghostwhite: 0xf8f8ff, gold: 0xffd700,\n goldenrod: 0xdaa520, gray: 0x808080, green: 0x008000, greenyellow: 0xadff2f,\n grey: 0x808080, honeydew: 0xf0fff0, hotpink: 0xff69b4, indianred: 0xcd5c5c,\n indigo: 0x4b0082, ivory: 0xfffff0, khaki: 0xf0e68c, lavender: 0xe6e6fa,\n lavenderblush: 0xfff0f5, lawngreen: 0x7cfc00, lemonchiffon: 0xfffacd, lightblue: 0xadd8e6,\n lightcoral: 0xf08080, lightcyan: 0xe0ffff, lightgoldenrodyellow: 0xfafad2, lightgray: 0xd3d3d3,\n lightgreen: 0x90ee90, lightgrey: 0xd3d3d3, lightpink: 0xffb6c1, lightsalmon: 0xffa07a,\n lightseagreen: 0x20b2aa, lightskyblue: 0x87cefa, lightslategray: 0x778899, lightslategrey: 0x778899,\n lightsteelblue: 0xb0c4de, lightyellow: 0xffffe0, lime: 0x00ff00, limegreen: 0x32cd32,\n linen: 0xfaf0e6, magenta: 0xff00ff, maroon: 0x800000, mediumaquamarine: 0x66cdaa,\n mediumblue: 0x0000cd, mediumorchid: 0xba55d3, mediumpurple: 0x9370db, mediumseagreen: 0x3cb371,\n mediumslateblue: 0x7b68ee, mediumspringgreen: 0x00fa9a, mediumturquoise: 0x48d1cc, mediumvioletred: 0xc71585,\n midnightblue: 0x191970, mintcream: 0xf5fffa, mistyrose: 0xffe4e1, moccasin: 0xffe4b5,\n navajowhite: 0xffdead, navy: 0x000080, oldlace: 0xfdf5e6, olive: 0x808000,\n olivedrab: 0x6b8e23, orange: 0xffa500, orangered: 0xff4500, orchid: 0xda70d6,\n palegoldenrod: 0xeee8aa, palegreen: 0x98fb98, paleturquoise: 0xafeeee, palevioletred: 0xdb7093,\n papayawhip: 0xffefd5, peachpuff: 0xffdab9, peru: 0xcd853f, pink: 0xffc0cb,\n plum: 0xdda0dd, powderblue: 0xb0e0e6, purple: 0x800080, rebeccapurple: 0x663399,\n red: 0xff0000, rosybrown: 0xbc8f8f, royalblue: 0x4169e1, saddlebrown: 0x8b4513,\n salmon: 0xfa8072, sandybrown: 0xf4a460, seagreen: 0x2e8b57, seashell: 0xfff5ee,\n sienna: 0xa0522d, silver: 0xc0c0c0, skyblue: 0x87ceeb, slateblue: 0x6a5acd,\n slategray: 0x708090, slategrey: 0x708090, snow: 0xfffafa, springgreen: 0x00ff7f,\n steelblue: 0x4682b4, tan: 0xd2b48c, teal: 0x008080, thistle: 0xd8bfd8,\n tomato: 0xff6347, turquoise: 0x40e0d0, violet: 0xee82ee, wheat: 0xf5deb3,\n white: 0xffffff, whitesmoke: 0xf5f5f5, yellow: 0xffff00, yellowgreen: 0x9acd32,\n };\n const rgba = (n: number): [number, number, number, number] =>\n [((n >> 16) & 0xff) / 255, ((n >> 8) & 0xff) / 255, (n & 0xff) / 255, 1];\n return {\n transparent: [0, 0, 0, 0],\n ...Object.fromEntries(Object.entries(hex).map(([name, n]) => [name, rgba(n)])),\n };\n})();\n","/**\n * Coons and tensor-product patch surfaces — PDF's shading types 6 and 7, as\n * pure geometry.\n *\n * A patch is a curved quadrilateral: four cubic Bézier edges and a color at\n * each corner. A Coons patch reads its interior off the boundary alone; a\n * tensor patch adds four interior control points that pull it around.\n */\n\n/** A point in the patch's own space. */\nexport interface MeshPoint {\n x: number;\n y: number;\n}\n\n/**\n * One patch.\n *\n * `points` walks the boundary: corner 0, the two control points of the edge\n * leaving it, corner 1, its two, and so on — twelve points, ending with the\n * two controls that return to corner 0. A tensor patch appends its four\n * interior points, in the order `(1,1)`, `(1,2)`, `(2,2)`, `(2,1)` of the\n * bicubic control net, which is PDF's own order. Twelve points is a Coons\n * patch and sixteen is a tensor patch.\n *\n * `colors` are the corner colors in the same walk order.\n */\nexport interface MeshPatch<TColor = string> {\n points: readonly MeshPoint[];\n colors: readonly [TColor, TColor, TColor, TColor];\n}\n\n/** Corner `i` of the boundary walk. */\nexport function patchCorner(patch: MeshPatch<unknown>, i: number): MeshPoint {\n return patch.points[(i & 3) * 3];\n}\n\n/** `true` when the patch carries the four interior points a tensor patch adds. */\nexport function isTensorPatch(patch: MeshPatch<unknown>): boolean {\n return patch.points.length >= 16;\n}\n\n/** A patch is twelve boundary points, or sixteen with the interior. Anything\n * else cannot be evaluated, and saying so here beats painting nonsense. */\nexport function isValidPatch(patch: MeshPatch<unknown>): boolean {\n return patch.points.length === 12 || patch.points.length === 16;\n}\n\nfunction bezier(p0: MeshPoint, p1: MeshPoint, p2: MeshPoint, p3: MeshPoint, t: number): MeshPoint {\n const s = 1 - t;\n const a = s * s * s;\n const b = 3 * s * s * t;\n const c = 3 * s * t * t;\n const d = t * t * t;\n return {\n x: a * p0.x + b * p1.x + c * p2.x + d * p3.x,\n y: a * p0.y + b * p1.y + c * p2.y + d * p3.y,\n };\n}\n\n/** The edge leaving corner `i`, as its four control points. */\nfunction edge(patch: MeshPatch<unknown>, i: number): [MeshPoint, MeshPoint, MeshPoint, MeshPoint] {\n const p = patch.points;\n const a = (i & 3) * 3;\n return [p[a], p[a + 1], p[a + 2], p[((i + 1) & 3) * 3]];\n}\n\n/**\n * The patch surface at `(u, v)`, both in `0..1`.\n *\n * `u` runs along the edge leaving corner 0 and `v` along the edge leaving\n * corner 1, so `(0,0)` is corner 0, `(1,0)` corner 1, `(1,1)` corner 2 and\n * `(0,1)` corner 3 — the same walk `colors` is in.\n */\nexport function evalPatch(patch: MeshPatch<unknown>, u: number, v: number): MeshPoint {\n return isTensorPatch(patch) ? evalTensor(patch, u, v) : evalCoons(patch, u, v);\n}\n\nfunction evalCoons(patch: MeshPatch<unknown>, u: number, v: number): MeshPoint {\n const [b0, b1, b2, b3] = edge(patch, 0); // corner 0 → 1, along u at v=0\n const [r0, r1, r2, r3] = edge(patch, 1); // corner 1 → 2, along v at u=1\n const [t0, t1, t2, t3] = edge(patch, 2); // corner 2 → 3, along u at v=1\n const [l0, l1, l2, l3] = edge(patch, 3); // corner 3 → 0, along v at u=0\n\n const bottom = bezier(b0, b1, b2, b3, u);\n const top = bezier(t0, t1, t2, t3, 1 - u); // walks 2 → 3, so reverse it\n const right = bezier(r0, r1, r2, r3, v);\n const left = bezier(l0, l1, l2, l3, 1 - v); // walks 3 → 0, so reverse it\n\n const c0 = patchCorner(patch, 0);\n const c1 = patchCorner(patch, 1);\n const c2 = patchCorner(patch, 2);\n const c3 = patchCorner(patch, 3);\n\n // The Coons construction: the two ruled surfaces between opposite edges,\n // minus the bilinear surface through the corners they both already carry.\n const ruledU = (a: number, b: number): number => (1 - v) * a + v * b;\n const ruledV = (a: number, b: number): number => (1 - u) * a + u * b;\n const corner = (k0: number, k1: number, k2: number, k3: number): number =>\n (1 - u) * (1 - v) * k0 + u * (1 - v) * k1 + u * v * k2 + (1 - u) * v * k3;\n\n return {\n x: ruledU(bottom.x, top.x) + ruledV(left.x, right.x)\n - corner(c0.x, c1.x, c2.x, c3.x),\n y: ruledU(bottom.y, top.y) + ruledV(left.y, right.y)\n - corner(c0.y, c1.y, c2.y, c3.y),\n };\n}\n\n/** The bicubic control net a tensor patch's sixteen points make, as\n * `net[i][j]` with `i` along `u` and `j` along `v`. */\nfunction tensorNet(patch: MeshPatch<unknown>): MeshPoint[][] {\n const p = patch.points;\n // Boundary, read off the same walk; interior from the four trailing points.\n return [\n [p[0], p[11], p[10], p[9]],\n [p[1], p[12], p[15], p[8]],\n [p[2], p[13], p[14], p[7]],\n [p[3], p[4], p[5], p[6]],\n ];\n}\n\nconst BERNSTEIN = (t: number): [number, number, number, number] => {\n const s = 1 - t;\n return [s * s * s, 3 * s * s * t, 3 * s * t * t, t * t * t];\n};\n\nfunction evalTensor(patch: MeshPatch<unknown>, u: number, v: number): MeshPoint {\n const net = tensorNet(patch);\n const bu = BERNSTEIN(u);\n const bv = BERNSTEIN(v);\n let x = 0;\n let y = 0;\n for (let i = 0; i < 4; i++) {\n for (let j = 0; j < 4; j++) {\n const w = bu[i] * bv[j];\n x += w * net[i][j].x;\n y += w * net[i][j].y;\n }\n }\n return { x, y };\n}\n\n/**\n * The four corner weights at `(u, v)` — bilinear, in the corner walk order.\n */\nexport function cornerWeights(u: number, v: number): [number, number, number, number] {\n return [(1 - u) * (1 - v), u * (1 - v), u * v, (1 - u) * v];\n}\n\n/** Axis-aligned bounds of a patch, sampled on a grid: control points alone\n * bound a Bézier but not tightly. */\nexport function patchBounds(\n patch: MeshPatch<unknown>, steps = 8,\n): { x: number; y: number; width: number; height: number } {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (let i = 0; i <= steps; i++) {\n for (let j = 0; j <= steps; j++) {\n const p = evalPatch(patch, i / steps, j / steps);\n if (p.x < minX) minX = p.x;\n if (p.y < minY) minY = p.y;\n if (p.x > maxX) maxX = p.x;\n if (p.y > maxY) maxY = p.y;\n }\n }\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n","/**\n * A mesh paint baked into one RGBA bitmap: each patch is subdivided into small\n * quads and rasterized forward, once per paint, into a texture the shader then\n * samples. Inverting a bicubic per fragment would be Newton iteration.\n *\n * The bitmap is straight (non-premultiplied) RGBA; the fragment shader\n * premultiplies.\n */\n\nimport { parseColor } from '@weasel-js/paint';\nimport { lerpColorArray, type ColorSpace } from '@weasel-js/paint';\nimport { evalPatch, isValidPatch, patchBounds, type MeshPatch } from './surface';\n\n/** Texels on a side of a bake when the caller names no size. The renderer\n * sizes each bake from how large the paint draws — see `meshBakeSize`. */\nexport const MESH_BAKE_SIZE = 256;\n\n/** Texels a rasterized cell spans at most. The rasterizer interpolates color\n * linearly inside a cell and draws a curved edge as its chord, so this is\n * what keeps a perceptual blend perceptual and an edge curved at any size. */\nconst TEXELS_PER_CELL = 10;\n\n/** Quads per patch on a side, never fewer than 24. */\nfunction gridFor(size: number): number {\n return Math.max(24, Math.ceil(size / TEXELS_PER_CELL));\n}\n\n/** The box a bake covers, in the paint's own space. */\nexport interface MeshBox {\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\n/** The bitmap `bakeMesh` produces, and the paint-space box it covers. */\nexport interface BakedMesh {\n /** `size` × `size` texels, straight RGBA. */\n pixels: Uint8ClampedArray;\n /** Texels on a side; `MESH_BAKE_SIZE` unless the caller asked otherwise. */\n size: number;\n /** Where the bitmap sits in paint space, which is what the shader maps a\n * fragment through. */\n box: MeshBox;\n}\n\n/** The union of every patch's bounds, or `null` when nothing is drawable. */\nexport function meshBounds(patches: readonly MeshPatch[]): MeshBox | null {\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n for (const patch of patches) {\n if (!isValidPatch(patch)) continue;\n const b = patchBounds(patch);\n minX = Math.min(minX, b.x);\n minY = Math.min(minY, b.y);\n maxX = Math.max(maxX, b.x + b.width);\n maxY = Math.max(maxY, b.y + b.height);\n }\n if (!Number.isFinite(minX) || maxX <= minX || maxY <= minY) return null;\n return { x: minX, y: minY, width: maxX - minX, height: maxY - minY };\n}\n\ntype Rgba = readonly [number, number, number, number];\n\n/**\n * Corner colors blended at `(u, v)` in `space`. Three lerps rather than four\n * weights, because a perceptual space has no meaningful four-way mix — OKLCh's\n * hue is an arc, which only two endpoints define.\n */\nfunction colorAt(corners: Rgba[], u: number, v: number, space: ColorSpace): number[] {\n const bottom = lerpColorArray(corners[0], corners[1], u, space);\n const top = lerpColorArray(corners[3], corners[2], u, space);\n return lerpColorArray(bottom, top, v, space);\n}\n\n/**\n * Rasterize `patches` into a square bitmap covering their union, or `null`\n * when no patch is drawable.\n */\nexport function bakeMesh(\n patches: readonly MeshPatch[],\n space: ColorSpace = 'rgb',\n size: number = MESH_BAKE_SIZE,\n): BakedMesh | null {\n const box = meshBounds(patches);\n if (!box) return null;\n\n const pixels = new Uint8ClampedArray(size * size * 4);\n const grid = gridFor(size);\n // The box maps onto texel *centers*, not texel edges: a corner of the mesh\n // lands at the center of the corner texel, so the outermost row and column\n // are covered rather than half-missed by a rasterizer testing centers.\n const toTexel = (p: { x: number; y: number }): { x: number; y: number } => ({\n x: ((p.x - box.x) / box.width) * (size - 1) + 0.5,\n y: ((p.y - box.y) / box.height) * (size - 1) + 0.5,\n });\n\n for (const patch of patches) {\n if (!isValidPatch(patch)) continue;\n const corners = patch.colors.map((c) => parseColor(c)) as Rgba[];\n\n for (let i = 0; i < grid; i++) {\n for (let j = 0; j < grid; j++) {\n const u0 = i / grid;\n const u1 = (i + 1) / grid;\n const v0 = j / grid;\n const v1 = (j + 1) / grid;\n const quad = [\n { at: toTexel(evalPatch(patch, u0, v0)), color: colorAt(corners, u0, v0, space) },\n { at: toTexel(evalPatch(patch, u1, v0)), color: colorAt(corners, u1, v0, space) },\n { at: toTexel(evalPatch(patch, u1, v1)), color: colorAt(corners, u1, v1, space) },\n { at: toTexel(evalPatch(patch, u0, v1)), color: colorAt(corners, u0, v1, space) },\n ];\n fillTriangle(pixels, size, quad[0], quad[1], quad[2]);\n fillTriangle(pixels, size, quad[0], quad[2], quad[3]);\n }\n }\n }\n\n return { pixels, size, box };\n}\n\ninterface Vertex {\n at: { x: number; y: number };\n color: number[];\n}\n\nconst EDGE_EPS = 1e-6;\n\n/**\n * One triangle, barycentric, colors interpolated across it. A pixel exactly on\n * an edge two cells share is claimed by both — harmless, because both carry\n * the same color there.\n */\nfunction fillTriangle(\n pixels: Uint8ClampedArray, size: number, a: Vertex, b: Vertex, c: Vertex,\n): void {\n const minX = Math.max(0, Math.floor(Math.min(a.at.x, b.at.x, c.at.x)));\n const maxX = Math.min(size - 1, Math.ceil(Math.max(a.at.x, b.at.x, c.at.x)));\n const minY = Math.max(0, Math.floor(Math.min(a.at.y, b.at.y, c.at.y)));\n const maxY = Math.min(size - 1, Math.ceil(Math.max(a.at.y, b.at.y, c.at.y)));\n if (maxX < minX || maxY < minY) return;\n\n const area = (b.at.x - a.at.x) * (c.at.y - a.at.y) - (c.at.x - a.at.x) * (b.at.y - a.at.y);\n // A degenerate cell — a patch collapsed to a line — covers nothing.\n if (Math.abs(area) < 1e-9) return;\n\n for (let y = minY; y <= maxY; y++) {\n for (let x = minX; x <= maxX; x++) {\n const px = x + 0.5;\n const py = y + 0.5;\n const w0 = ((b.at.x - px) * (c.at.y - py) - (c.at.x - px) * (b.at.y - py)) / area;\n const w1 = ((c.at.x - px) * (a.at.y - py) - (a.at.x - px) * (c.at.y - py)) / area;\n const w2 = 1 - w0 - w1;\n // An edge texel's center sits exactly on the boundary, where rounding\n // can put it a hair outside; the epsilon is what keeps the border row\n // from dropping out.\n if (w0 < -EDGE_EPS || w1 < -EDGE_EPS || w2 < -EDGE_EPS) continue;\n const k = (y * size + x) * 4;\n for (let ch = 0; ch < 4; ch++) {\n pixels[k + ch] = (w0 * a.color[ch] + w1 * b.color[ch] + w2 * c.color[ch]) * 255;\n }\n }\n }\n}\n","/**\n * How large a mesh bake is, and the bounded cache the bakes live in.\n *\n * A gradient's ramp is one-dimensional, so 256 texels cover it at any size. A\n * mesh's bake is two-dimensional and is stretched over whatever the paint\n * covers, so a fixed size shows its texels once the paint draws large. The\n * bake is sized from the device pixels it covers instead, in power-of-two\n * buckets so a zoom inside one bucket reuses the bake it already has.\n */\n\nimport { MESH_BAKE_SIZE } from './bake';\n\n/** The smallest bake: below this a texture costs more in bookkeeping than in\n * bytes. */\nexport const MESH_BAKE_MIN = 32;\n\n/** The largest bake, whatever the context allows: 16 MiB of RGBA, and a bake\n * that already takes a noticeable moment on the CPU. */\nexport const MESH_BAKE_MAX = 2048;\n\n/** Bytes of baked texture one renderer keeps before evicting the least\n * recently drawn. */\nexport const MESH_BAKE_CACHE_BYTES = 64 * 1024 * 1024;\n\n/** Bakes one renderer keeps, however small, so a scene of many tiny meshes\n * cannot hold thousands of GL textures. */\nexport const MESH_BAKE_CACHE_ENTRIES = 256;\n\n/**\n * The bake side for a paint drawn `devicePx` device pixels across, on a\n * context accepting `maxTextureSize`: the next power of two at or above it,\n * clamped to `[MESH_BAKE_MIN, MESH_BAKE_MAX]` and to the context. A size that\n * cannot be measured gets `MESH_BAKE_SIZE`.\n */\nexport function meshBakeSize(devicePx: number, maxTextureSize: number): number {\n const ceiling = Math.min(MESH_BAKE_MAX, floorPow2(maxTextureSize));\n if (Number.isNaN(devicePx)) return Math.min(MESH_BAKE_SIZE, ceiling);\n if (devicePx <= MESH_BAKE_MIN) return Math.min(MESH_BAKE_MIN, ceiling);\n if (devicePx >= ceiling) return ceiling;\n return Math.min(ceiling, 2 ** Math.ceil(Math.log2(devicePx)));\n}\n\nfunction floorPow2(n: number): number {\n if (!(n >= 1)) return MESH_BAKE_MIN;\n if (!Number.isFinite(n)) return MESH_BAKE_MAX;\n return 2 ** Math.floor(Math.log2(n));\n}\n\ninterface Entry<T> {\n value: T;\n size: number;\n /** The paint's own bucket map, which is what eviction removes it from. */\n bySize: Map<number, Entry<T>>;\n}\n\n/**\n * Bakes keyed by paint and bake size, least recently used first out.\n *\n * The paint is held weakly, so a paint nobody draws any more does not pin its\n * key; its texture stays until eviction reaches it, which the bounds keep\n * finite. `free` runs for every value that leaves, by eviction, replacement or\n * `clear`.\n */\nexport class MeshBakeCache<T> {\n private readonly byPaint = new WeakMap<object, Map<number, Entry<T>>>();\n /** Insertion order is recency: a hit is deleted and re-added. */\n private readonly order = new Set<Entry<T>>();\n private held = 0;\n\n constructor(\n private readonly free: (value: T) => void,\n private readonly budgetBytes: number = MESH_BAKE_CACHE_BYTES,\n private readonly maxEntries: number = MESH_BAKE_CACHE_ENTRIES,\n ) {}\n\n /** Bytes the held bakes occupy, as RGBA8. */\n get bytes(): number { return this.held; }\n\n /** Bakes held. */\n get size(): number { return this.order.size; }\n\n get(paint: object, size: number): T | undefined {\n const entry = this.byPaint.get(paint)?.get(size);\n if (!entry) return undefined;\n this.order.delete(entry);\n this.order.add(entry);\n return entry.value;\n }\n\n set(paint: object, size: number, value: T): void {\n let bySize = this.byPaint.get(paint);\n if (!bySize) {\n bySize = new Map();\n this.byPaint.set(paint, bySize);\n }\n const old = bySize.get(size);\n if (old) this.drop(old);\n const entry: Entry<T> = { value, size, bySize };\n bySize.set(size, entry);\n this.order.add(entry);\n this.held += size * size * 4;\n this.evict(entry);\n }\n\n /** Free every bake. The cache stays usable. */\n clear(): void {\n for (const entry of [...this.order]) this.drop(entry);\n }\n\n /** Oldest first until both bounds hold, never evicting `keep` — the bake\n * the caller is about to draw. */\n private evict(keep: Entry<T>): void {\n for (const entry of this.order) {\n if (this.held <= this.budgetBytes && this.order.size <= this.maxEntries) return;\n if (entry !== keep) this.drop(entry);\n }\n }\n\n private drop(entry: Entry<T>): void {\n if (!this.order.delete(entry)) return;\n entry.bySize.delete(entry.size);\n this.held -= entry.size * entry.size * 4;\n this.free(entry.value);\n }\n}\n","/**\n * GLSL ES 3.0 sources for the mesh-gradient paint.\n *\n * Everything outside the bake's box is transparent: a mesh covers the area its\n * patches cover, not the whole shape it is filling, and a clamped read would\n * otherwise smear its border colors across the rest.\n *\n * `u_meshSize` is the bake's box in paint space, measured from its corner,\n * which `u_worldInv` puts at zero; the bake maps that box onto texel\n * *centers*, which is the half-texel the uv rescale accounts for. Output is PREMULTIPLIED alpha.\n */\n\n/** The id this program is registered under. */\nexport const MESH_PROGRAM_ID = 'kit:mesh-gradient';\n\nexport const MESH_VERT_SRC = /* glsl */ `#version 300 es\nin vec2 a_position;\nuniform mat3 u_proj;\nuniform mat3 u_model;\nuniform vec2 u_origin;\nuniform mat3 u_worldInv;\nout vec2 v_world;\nvoid main() {\n vec3 screen = u_model * vec3(a_position - u_origin, 1.0);\n vec3 clip = u_proj * vec3(screen.xy, 1.0);\n gl_Position = vec4(clip.xy, 0.0, 1.0);\n vec3 world = u_worldInv * vec3(screen.xy, 1.0);\n v_world = world.xy;\n}\n`;\n\nexport const MESH_FRAG_SRC = /* glsl */ `#version 300 es\nprecision highp float;\nin vec2 v_world;\nuniform sampler2D u_sampler;\nuniform vec2 u_meshSize;\nuniform float u_opacity;\nuniform float u_alpha;\nout vec4 outColor;\nvoid main() {\n vec2 t = v_world / max(u_meshSize, vec2(0.0001));\n if (t.x < 0.0 || t.x > 1.0 || t.y < 0.0 || t.y > 1.0) {\n outColor = vec4(0.0);\n return;\n }\n vec2 texels = vec2(textureSize(u_sampler, 0));\n vec2 uv = (t * (texels - 1.0) + 0.5) / texels;\n vec4 texel = texture(u_sampler, uv);\n float a = texel.a * u_opacity * u_alpha;\n outColor = vec4(texel.rgb * a, a);\n}\n`;\n\nexport const MESH_UNIFORMS = [\n 'u_proj', 'u_model', 'u_origin', 'u_worldInv', 'u_sampler',\n 'u_meshSize', 'u_opacity', 'u_alpha',\n] as const;\n\nexport const MESH_ATTRIBUTES = ['a_position'] as const;\n","/** Pieces the kit's WGSL programs are assembled from. */\n\n/**\n * Element types for a uniform array whose GLSL element is a `float` or a\n * `vec2`: WGSL's uniform address space wants a 16-byte array stride, so each\n * element sits in a struct padded to 16. Read one as `u.u_alpha[i].v`; set\n * the array by its GLSL name, flat, as GL takes it.\n */\nconst SLOT_STRUCTS: Readonly<Record<string, string>> = {\n F32Slot: 'struct F32Slot { @size(16) v: f32 }',\n Vec2Slot: 'struct Vec2Slot { @size(16) v: vec2f }',\n};\n\n/**\n * The viewport fold: a backend whose viewports must lie inside their target\n * clamps one that reaches past it, and maps clip space from the viewport asked\n * for onto the one it set by this scale (`xy`) and offset (`zw`), per draw.\n * Every vertex entry point passes its position through `weasel_clip`.\n */\nexport const NDC_WGSL = /* wgsl */ `\n@group(2) @binding(0) var<uniform> weasel_ndc: vec4f;\nfn weasel_clip(p: vec4f) -> vec4f {\n return vec4f(p.xy * weasel_ndc.xy + weasel_ndc.zw, p.zw);\n}\n`;\n\n/**\n * `struct Uniforms` at `@group(0) @binding(0)` as `u`, holding `members`\n * (`name: type` each, the GLSL uniform names) and, where `ids` is on,\n * `u_weaselId`, beside `NDC_WGSL`. A member named twice is declared once.\n */\nexport function uniformsWgsl(members: readonly string[], ids = true): string {\n const seen = new Map<string, string>();\n for (const m of [...members, ...(ids ? ['u_weaselId: vec4f'] : [])]) {\n const name = m.slice(0, m.indexOf(':')).trim();\n if (!seen.has(name)) seen.set(name, m.trim());\n }\n const body = [...seen.values()];\n const slots = Object.entries(SLOT_STRUCTS)\n .filter(([name]) => body.some((m) => m.includes(`<${name},`)))\n .map(([, decl]) => `${decl}\\n`)\n .join('');\n return `${slots}struct Uniforms {\\n${body.map((m) => ` ${m},`).join('\\n')}\\n}\n@group(0) @binding(0) var<uniform> u: Uniforms;\n${NDC_WGSL}`;\n}\n\n/** A group-1 texture `name` at `binding`, beside its sampler at `binding + 1`. */\nexport function textureWgsl(name: string, binding: number): string {\n return `@group(1) @binding(${binding}) var ${name}: texture_2d<f32>;\n@group(1) @binding(${binding + 1}) var ${name}_sampler: sampler;\n`;\n}\n\n/** What a path program's vertex stage reads. */\nexport const PATH_VERTEX_MEMBERS = ['u_proj: mat3x3f', 'u_model: mat3x3f', 'u_origin: vec2f'] as const;\n\n/** A path vertex in screen space, and a screen point in clip space. */\nexport const PATH_VERTEX_WGSL = /* wgsl */ `\nfn screenOf(a_position: vec2f) -> vec2f {\n return (u.u_model * vec3f(a_position - u.u_origin, 1.0)).xy;\n}\n\nfn clipOf(screen: vec2f) -> vec4f {\n let clip = u.u_proj * vec3f(screen, 1.0);\n return weasel_clip(vec4f(clip.xy, 0.0, 1.0));\n}\n`;\n\n/** The members `shadeMapped` reads. */\nexport const COLOR_MATRIX_MEMBERS = ['u_colorMatrix: mat4x4f', 'u_colorBias: vec4f', 'u_alpha: f32'] as const;\n\n/** A straight color through the color matrix and `u_alpha`, premultiplied. */\nexport const SHADE_MAPPED_WGSL = /* wgsl */ `\nfn shadeMapped(src: vec4f) -> vec4f {\n let mapped = saturate(u.u_colorMatrix * src + u.u_colorBias);\n let a = mapped.a * u.u_alpha;\n return vec4f(mapped.rgb * a, a);\n}\n`;\n\n/** The color of a premultiplied image texel, straight, as `STRAIGHT_RGB_GLSL`. */\nexport const STRAIGHT_RGB_WGSL = /* wgsl */ `\nfn straightRgb(premultiplied: vec4f) -> vec3f {\n return premultiplied.rgb / max(premultiplied.a, 0.0001);\n}\n`;\n","/** The id output every WGSL fragment entry writes beside its color, the\n * counterpart of `withIdOutput`'s GLSL rewrite: `id.rgb` is the id's three\n * bytes, `id.a` the least alpha a fragment claims its pixel with. A draw\n * outside an id frame has no target at location 1, and the write is dropped. */\nexport const ID_OUT_WGSL = /* wgsl */ `\nstruct WeaselOut {\n @location(0) color: vec4f,\n @location(1) id: vec4f,\n}\n\nfn weasel_out(color: vec4f, id: vec4f) -> WeaselOut {\n var o: WeaselOut;\n o.color = color;\n o.id = select(vec4f(0.0), vec4f(id.rgb, 1.0), color.a > 0.0 && color.a >= id.a);\n return o;\n}\n`;\n","import { PATH_VERTEX_MEMBERS, PATH_VERTEX_WGSL } from './common';\nimport { ID_OUT_WGSL } from './idOut';\n\n/** The vertex stage every paint drawn over a path shares, gradients, patterns\n * and the mesh: the path's vertex in clip space, and `u_worldInv` of its\n * screen point as the paint-space point `v_world`. */\nexport const PAINT_VERTEX_MEMBERS = [...PATH_VERTEX_MEMBERS, 'u_worldInv: mat3x3f'] as const;\n\nexport const PAINT_VERTEX_WGSL = /* wgsl */ `${ID_OUT_WGSL}${PATH_VERTEX_WGSL}\nstruct VOut {\n @builtin(position) position: vec4f,\n @location(0) v_world: vec2f,\n}\n\n@vertex fn vs(@location(0) a_position: vec2f) -> VOut {\n var o: VOut;\n let screen = screenOf(a_position);\n o.position = clipOf(screen);\n o.v_world = (u.u_worldInv * vec3f(screen, 1.0)).xy;\n return o;\n}\n`;\n\nexport const PAINT_FILL_LOCATIONS = { a_position: 0 } as const;\n\n/** What a paint's fragment stage is made of, so the glyph program can mask\n * the same paint the path program draws. */\nexport interface WgslPaint {\n /** Its members of `struct Uniforms`. */\n readonly members: readonly string[];\n /** `fn shadePaint(world: vec2f) -> vec4f`, premultiplied, and the group-1\n * textures it samples, at bindings 0 and 1. */\n readonly code: string;\n}\n","import { textureWgsl, uniformsWgsl } from './common';\nimport { PAINT_FILL_LOCATIONS, PAINT_VERTEX_MEMBERS, PAINT_VERTEX_WGSL } from './paintVertex';\n\n/** `meshPaint/meshShader.ts` (`kit:mesh-gradient`) in WGSL: the straight-RGBA\n * bake over `u_meshSize`, transparent outside it. */\nexport const MESH_WGSL = /* wgsl */ `${uniformsWgsl([\n ...PAINT_VERTEX_MEMBERS, 'u_meshSize: vec2f', 'u_opacity: f32', 'u_alpha: f32',\n])}\n${PAINT_VERTEX_WGSL}${textureWgsl('u_sampler', 0)}\n@fragment fn fs(in: VOut) -> WeaselOut {\n let t = in.v_world / max(u.u_meshSize, vec2f(0.0001));\n let texels = vec2f(textureDimensions(u_sampler));\n let uv = (t * (texels - 1.0) + 0.5) / texels;\n // Sampled before the box test: WGSL takes no implicit derivative past a branch on a varying.\n let texel = textureSample(u_sampler, u_sampler_sampler, uv);\n let outside = any(t < vec2f(0.0)) || any(t > vec2f(1.0));\n let a = texel.a * u.u_opacity * u.u_alpha;\n return weasel_out(select(vec4f(texel.rgb * a, a), vec4f(0.0), outside), u.u_weaselId);\n}\n`;\n\nexport const MESH_LOCATIONS = PAINT_FILL_LOCATIONS;\n","/**\n * The `mesh-gradient` paint kind — PDF's shading types 6 and 7 as a registered\n * paint: a set of curved quadrilateral patches, each with a color at every\n * corner.\n *\n * It uses only the slots `registerPaintKind` gives a consumer, so whatever it\n * can do, a consumer's own kind can do too.\n */\n\nimport type { GradStop } from '@weasel-js/paint';\nimport { DEG_TO_RAD, mat3, trimNumber, maxOf, minOf } from '@weasel-js/geom';\nimport type { PaintBindContext, PaintBinding, PaintDrawKind, PaintResources, PaintTexture } from '../paintKinds';\nimport { parseColor, rgbaToHex } from '@weasel-js/paint';\nimport { oklabToOklch, oklabToSrgbU8, oklchToOklab, srgbFloatToOklab } from '@weasel-js/paint';\nimport type { ColorSpace, Paint, PaintUnits } from '@weasel-js/paint';\nimport type { FillPoseBox } from '../fillInPoseFrame';\nimport { bakeMesh, meshBounds, type MeshBox } from './bake';\nimport { MeshBakeCache, meshBakeSize } from './bakeCache';\nimport { isValidPatch, type MeshPatch, type MeshPoint } from './surface';\nimport { MESH_FRAG_SRC, MESH_PROGRAM_ID, MESH_VERT_SRC } from './meshShader';\nimport { MESH_WGSL } from '../gpu/webgpu/wgsl/meshPaint';\n\nexport type { MeshPatch, MeshPoint } from './surface';\n\n/**\n * A mesh gradient paint.\n *\n * `patches` are in the space `units` names, the same way a gradient's\n * geometry is — under `'bounds'` every point is a fraction of the painted\n * node's box, which is what lets the paint survive a resize.\n *\n * `interpolate` is the space corner colors blend through, matching the three\n * gradients.\n */\nexport interface MeshGradientPaint {\n kind: 'mesh-gradient';\n patches: MeshPatch[];\n units?: PaintUnits;\n interpolate?: ColorSpace;\n opacity?: number;\n}\n\n/** The kind's id, as `Paint['fill']` carries it. */\nexport const MESH_GRADIENT_KIND = 'mesh-gradient';\n\n/** A mesh paint, narrowed. */\nexport function isMeshGradientPaint(fill: Paint | null | undefined): fill is Paint & MeshGradientPaint {\n // `Paint`'s discriminant stays closed over the built-in kinds — see\n // `asPaint` — so a registered kind reads it widened.\n return fill != null && (fill.kind as string | undefined) === MESH_GRADIENT_KIND;\n}\n\nfunction asMesh(fill: Paint): MeshGradientPaint {\n return fill as unknown as MeshGradientPaint;\n}\n\n// `asPaint`'s cast, kept local: this module must import nothing from the\n// registry, whose state the lazy kind's self-contained copy would duplicate.\nfunction asFill(mesh: MeshGradientPaint): Paint {\n return mesh as unknown as Paint;\n}\n\n/**\n * `color` moved in OKLCh — lightness, chroma and hue by the given deltas, with\n * its alpha kept. The seed's corners come from one color, and they have to\n * differ enough to read as a mesh rather than as a flat fill.\n */\nfunction shifted(color: string, dL: number, cScale: number, dHueDeg: number): string {\n const [r, g, b, a] = parseColor(color);\n const [L, A, B] = srgbFloatToOklab(r, g, b);\n const [, C, h] = oklabToOklch(L, A, B);\n const [nL, nA, nB] = oklchToOklab(\n Math.min(1, Math.max(0, L + dL)),\n Math.max(0, C * cScale),\n h + dHueDeg * DEG_TO_RAD,\n );\n const [nr, ng, nb] = oklabToSrgbU8(nL, nA, nB);\n return rgbaToHex([nr / 255, ng / 255, nb / 255, a]);\n}\n\n/** A one-patch square covering the unit box, its four corners four readings of\n * `color` — a mesh seeded from a solid has to show *something* curved, or\n * switching kind looks like nothing happened. */\nexport function seedMeshPatch(color: string): MeshGradientPaint {\n const corners: MeshPoint[] = [\n { x: 0, y: 0 }, { x: 1, y: 0 }, { x: 1, y: 1 }, { x: 0, y: 1 },\n ];\n const points: MeshPoint[] = [];\n for (let i = 0; i < 4; i++) {\n const a = corners[i];\n const b = corners[(i + 1) % 4];\n // Bow each edge outward by an eighth, so the seed is a patch and not a\n // rectangle wearing one's clothes.\n const nx = (b.y - a.y) * 0.125;\n const ny = -(b.x - a.x) * 0.125;\n points.push(\n a,\n { x: a.x + (b.x - a.x) / 3 + nx, y: a.y + (b.y - a.y) / 3 + ny },\n { x: a.x + (2 * (b.x - a.x)) / 3 + nx, y: a.y + (2 * (b.y - a.y)) / 3 + ny },\n );\n }\n return {\n kind: MESH_GRADIENT_KIND,\n patches: [{\n points,\n colors: [\n color,\n shifted(color, 0.14, 0.85, 0),\n shifted(color, -0.06, 1.1, 38),\n shifted(color, -0.16, 1.0, -22),\n ],\n }],\n units: 'bounds',\n };\n}\n\n/** The straight-edged patch covering `[x0, x1] × [0, 1]`, in walk order. */\nfunction bandPatch(x0: number, x1: number, left: string, right: string): MeshPatch {\n const corners: MeshPoint[] = [{ x: x0, y: 0 }, { x: x1, y: 0 }, { x: x1, y: 1 }, { x: x0, y: 1 }];\n const points: MeshPoint[] = [];\n for (let i = 0; i < 4; i++) {\n const a = corners[i];\n const b = corners[(i + 1) % 4];\n points.push(a, { x: a.x + (b.x - a.x) / 3, y: a.y + (b.y - a.y) / 3 }, { x: a.x + (2 * (b.x - a.x)) / 3, y: a.y + (2 * (b.y - a.y)) / 3 });\n }\n return { points, colors: [left, right, right, left] };\n}\n\n/**\n * A stop list as a mesh: one full-height band per gap between neighboring\n * stops, colored left to right. The bands blend exactly the way the ramp\n * does, so a horizontal gradient survives the switch unchanged. A zero-width\n * gap is a hard break and gets no band.\n */\nexport function meshFromStops(stops: readonly GradStop[]): MeshGradientPaint {\n const sorted = [...stops].sort((a, b) => a.offset - b.offset);\n if (sorted.length === 1) sorted.push({ offset: 1, color: sorted[0].color });\n if (sorted.length === 0) return seedMeshPatch('#000000ff');\n const patches: MeshPatch[] = [];\n for (let i = 0; i < sorted.length - 1; i++) {\n const a = sorted[i];\n const b = sorted[i + 1];\n if (b.offset > a.offset) patches.push(bandPatch(a.offset, b.offset, a.color, b.color));\n }\n return { kind: MESH_GRADIENT_KIND, patches, units: 'bounds' };\n}\n\n/**\n * A mesh read as a stop list: every patch's top edge — corner 0 to corner 1 —\n * placed by its `x` across the mesh's horizontal extent. The inverse of\n * `meshFromStops`, and for any other mesh the ramp across its top.\n */\nexport function meshStops(mesh: MeshGradientPaint): GradStop[] {\n const valid = mesh.patches.filter(isValidPatch);\n if (valid.length === 0) return [];\n const xs = valid.flatMap((p) => [p.points[0].x, p.points[3].x]);\n const lo = minOf(xs);\n const span = maxOf(xs) - lo;\n const offsetOf = (x: number) => (span > 0 ? (x - lo) / span : 0);\n const stops: GradStop[] = [];\n const seen = new Set<string>();\n for (const patch of valid) {\n for (const [point, color] of [[patch.points[0], patch.colors[0]], [patch.points[3], patch.colors[1]]] as const) {\n const offset = offsetOf(point.x);\n const key = `${offset} ${color}`;\n if (seen.has(key)) continue;\n seen.add(key);\n stops.push({ offset, color });\n }\n }\n return stops.sort((a, b) => a.offset - b.offset);\n}\n\n/** Every patch mapped through `move`. */\nfunction mapPatches(mesh: MeshGradientPaint, move: (p: MeshPoint) => MeshPoint): MeshPatch[] {\n return mesh.patches.map((patch) => ({ ...patch, points: patch.points.map(move) }));\n}\n\n// ─── The bake cache ─────────────────────────────────────────────────────────\n//\n// A kind owns its own GPU state; the registry hands it a way to make textures\n// and a resource lifetime. One cache per lifetime, so two renderers — or one renderer past a\n// context restore — never trade textures, and the lifetime's end frees them.\n\ninterface CachedBake {\n texture: PaintTexture;\n /** Where the mesh being bound sits in paint space. The texels are shared by\n * every pose-frame copy of one paint; the box is each copy's own. */\n box: MeshBox;\n}\n\n/** The paint a pose-frame copy was made from. A copy is rebuilt whenever its\n * node's pose changes, and bakes the same texels as its source. */\nconst BAKE_SOURCE = new WeakMap<object, object>();\n\nconst CACHES = new WeakMap<PaintResources, MeshBakeCache<PaintTexture>>();\n\nfunction cacheFor(ctx: PaintBindContext): MeshBakeCache<PaintTexture> {\n let cache = CACHES.get(ctx.resources);\n if (!cache) {\n const made = new MeshBakeCache<PaintTexture>((texture) => ctx.deleteTexture(texture));\n ctx.resources.onRelease(() => {\n made.clear();\n CACHES.delete(ctx.resources);\n });\n CACHES.set(ctx.resources, made);\n cache = made;\n }\n return cache;\n}\n\n/** Device pixels the larger side of `box` covers when drawn in `units`. */\nfunction devicePixelsOf(ctx: PaintBindContext, mesh: MeshGradientPaint, box: MeshBox): number {\n const m = ctx.spaceToDevice(mesh.units);\n if (!m) return Number.NaN;\n return Math.max(box.width * Math.hypot(m[0], m[1]), box.height * Math.hypot(m[3], m[4]));\n}\n\nfunction bakeFor(ctx: PaintBindContext, mesh: MeshGradientPaint): CachedBake | null {\n const box = meshBounds(mesh.patches);\n if (!box) return null;\n const size = meshBakeSize(devicePixelsOf(ctx, mesh, box), ctx.maxTextureSize);\n\n const cache = cacheFor(ctx);\n const key = BAKE_SOURCE.get(mesh) ?? mesh;\n const hit = cache.get(key, size);\n if (hit) return { texture: hit, box };\n\n const baked = bakeMesh(mesh.patches, mesh.interpolate ?? 'rgb', size);\n if (!baked) return null;\n\n const texture = ctx.createTexture(baked.size, baked.size, baked.pixels);\n\n cache.set(key, size, texture);\n return { texture, box };\n}\n\nfunction bindMesh(ctx: PaintBindContext, fill: Paint): PaintBinding | null {\n const mesh = asMesh(fill);\n if (!mesh.patches.some(isValidPatch)) return null;\n\n const entry = bakeFor(ctx, mesh);\n if (!entry) return null;\n\n const { box } = entry;\n const inverse = ctx.spaceInverse(mesh.units, box);\n if (!inverse) return null;\n\n return {\n program: MESH_PROGRAM_ID,\n uniforms: {\n u_worldInv: mat3.toUniform(inverse),\n u_sampler: entry.texture,\n u_meshSize: [box.width, box.height],\n u_opacity: mesh.opacity ?? 1,\n u_alpha: ctx.alpha,\n },\n };\n}\n\n/** The kind's draw half, shader program included. Core adds the editor's\n * slots and registers the whole entry. */\nexport const meshDrawKind: PaintDrawKind = {\n id: MESH_GRADIENT_KIND,\n programs: { [MESH_PROGRAM_ID]: { glsl: { vert: MESH_VERT_SRC, frag: MESH_FRAG_SRC }, wgsl: { frag: MESH_WGSL } } },\n bind: bindMesh,\n inPoseFrame: (fill, box: FillPoseBox) => {\n const mesh = asMesh(fill);\n if (mesh.units !== 'bounds') return fill;\n const posed = asFill({\n ...mesh,\n patches: mapPatches(mesh, (p) => ({\n x: box.x + p.x * box.width,\n y: box.y + p.y * box.height,\n })),\n units: 'local' as const,\n });\n BAKE_SOURCE.set(posed, fill);\n return posed;\n },\n toBoundsFrame: (fill, box: FillPoseBox) => {\n const mesh = asMesh(fill);\n if (mesh.units === 'bounds' || box.width === 0 || box.height === 0) return fill;\n return asFill({\n ...mesh,\n patches: mapPatches(mesh, (p) => ({\n x: (p.x - box.x) / box.width,\n y: (p.y - box.y) / box.height,\n })),\n units: 'bounds' as const,\n });\n },\n};\n\n/**\n * The `<defs>` entry for a mesh paint, in weasel's own namespace.\n *\n * Not SVG's abandoned `<meshgradient>`: that vocabulary only reaches Coons\n * patches, shares patch edges implicitly — a reader that gets the sharing\n * wrong tears the surface rather than failing outright — and has exactly one\n * implementation in the world. Ours writes every patch's points in full.\n * `@weasel-js/svg` puts the paint fallback color beside the reference, so a\n * foreign renderer paints flat instead of nothing.\n */\nexport function meshGradientXml(id: string, mesh: MeshGradientPaint): string {\n const P = 'wzl';\n const units = mesh.units === 'bounds' ? 'objectBoundingBox' : 'userSpaceOnUse';\n const space = mesh.interpolate && mesh.interpolate !== 'rgb'\n ? ` interpolate=\"${mesh.interpolate}\"` : '';\n const patches = mesh.patches.map((patch) => {\n const points = patch.points.map((p) => `${trimNumber(p.x)},${trimNumber(p.y)}`).join(' ');\n const colors = patch.colors.join(' ');\n return `<${P}:patch points=\"${points}\" colors=\"${colors}\"/>`;\n }).join('');\n return (\n `<${P}:meshGradient id=\"${id}\" gradientUnits=\"${units}\"${space}>` +\n `${patches}</${P}:meshGradient>`\n );\n}\n","import type { IconRef } from '@weasel-js/icons';\nimport type { Paint } from '@weasel-js/paint';\nimport {\n meshDrawKind, meshFromStops, meshGradientXml, meshStops, seedMeshPatch, type MeshGradientPaint,\n} from '@weasel-js/renderer/mesh';\nimport type { PaintKindEntry } from './paintKindEntry';\n\n// `asPaint`'s cast both ways, kept local: this module must import nothing\n// stateful, or `meshKindLazy`'s self-contained copy would duplicate it.\nconst asMesh = (fill: Paint): MeshGradientPaint => fill as unknown as MeshGradientPaint;\nconst asFill = (mesh: MeshGradientPaint): Paint => mesh as unknown as Paint;\n\n/** The `mesh-gradient` kind's registry entry. `./registerMesh` registers it;\n * the paint-kind registry loads it on demand otherwise. */\nexport const meshGradientKind: PaintKindEntry = {\n ...meshDrawKind,\n label: 'Mesh',\n // Written as library mode emits `icon('mesh')`: the call would pull the icons package into meshKindLazy.\n icon: /* @icon */ 'paint-kinds:mesh' as IconRef,\n seed: (color) => asFill(seedMeshPatch(color)),\n // The first corner of the first patch: a mesh has no single color, and this\n // is the one a fallback swatch and an SVG paint fallback both read.\n colorOf: (paint) => asMesh(paint).patches?.[0]?.colors?.[0],\n stopsOf: (paint) => meshStops(asMesh(paint)),\n fromStops: (stops) => asFill(meshFromStops(stops)),\n toSvg: (id, fill) => meshGradientXml(id, asMesh(fill)),\n};\n"],"mappings":";;;;AAcA,MAAa,iBAAiB;;;;AAK9B,SAAgB,WAAW,MAAc,aAA8B;CACrE,OAAO,OAAO,cAAc,IAAI;AAClC;;;AAeA,SAAgB,WAAW,GAAW,SAAS,GAAW;CACxD,IAAI,CAAC,OAAO,SAAS,CAAC,GAAG,OAAO;CAChC,MAAM,IAAI,MAAM;CAChB,MAAM,UAAU,KAAK,MAAM,IAAI,CAAC,IAAI;CAEpC,OAAO,OAAO,OAAO,SAAS,OAAO,IAAI,UAAU,CAAC;AACtD;AAuEA,SAAgB,MAAS,OAAoB,IAAiD;C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K,EAGG,EAAE,IAAI,EAAE;AAErB;;ACrTA,MAAM,UAAU,SAAmC;AACnD,MAAM,UAAU,SAAmC;;;AAInD,MAAa,mBAAmC;CAC9C,GAAG;CACH,OAAO;CAEP,MAAkB;CAClB,OAAO,UAAU,OAAO,cAAc,KAAK,CAAC;CAG5C,UAAU,UAAU,OAAO,KAAK,CAAC,CAAC,UAAU,EAAE,EAAE,SAAS;CACzD,UAAU,UAAU,UAAU,OAAO,KAAK,CAAC;CAC3C,YAAY,UAAU,OAAO,cAAc,KAAK,CAAC;CACjD,QAAQ,IAAI,SAAS,gBAAgB,IAAI,OAAO,IAAI,CAAC;AACvD"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { ComponentType } from 'react';
|
|
2
|
+
import { IconSpec } from '@weasel-js/icons';
|
|
3
|
+
import { TileKind, Paint, GradStop } from '@weasel-js/paint';
|
|
4
|
+
import { PaintDrawKind } from '@weasel-js/renderer';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `Paint`'s discriminant, open on the string the way `ChromeId` is: the
|
|
8
|
+
* kinds the kit ships, plus whatever a consumer registers.
|
|
9
|
+
*/
|
|
10
|
+
type PaintKind = 'solid' | 'linear-gradient' | 'radial-gradient' | 'conic-gradient' | TileKind | 'image' | 'texture' | (string & {});
|
|
11
|
+
/**
|
|
12
|
+
* A set of kinds an editor offers as one choice. Kinds sharing a family show
|
|
13
|
+
* as a single segment in a kind bar, named by the family, and the member is
|
|
14
|
+
* picked inside that segment's body. The built-in tiles, `image` and `texture` are the
|
|
15
|
+
* `patternFamily`.
|
|
16
|
+
*/
|
|
17
|
+
interface PaintKindFamily {
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
/** Glyph for the family's segment. */
|
|
21
|
+
icon?: IconSpec;
|
|
22
|
+
}
|
|
23
|
+
/** What a registered kind's editor renders. `PaintInput` and `GradientEditor`
|
|
24
|
+
* in `@weasel-js/ui` mount it, and draw a gradient kind's blend-space switch
|
|
25
|
+
* beneath it. */
|
|
26
|
+
interface PaintKindEditorProps {
|
|
27
|
+
value: Paint;
|
|
28
|
+
onInput?(next: Paint): void;
|
|
29
|
+
onChange(next: Paint): void;
|
|
30
|
+
/** An edit was abandoned, after `onInput` got its starting paint back. */
|
|
31
|
+
onCancel?(): void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* One paint kind: the renderer's draw slots, plus what an editor and a
|
|
35
|
+
* serializer read.
|
|
36
|
+
*
|
|
37
|
+
* `seed`, `label` and `colorOf` are the editor's slots and every kind has
|
|
38
|
+
* them. The rest are optional because a kind may not need them.
|
|
39
|
+
*/
|
|
40
|
+
interface PaintKindEntry extends PaintDrawKind {
|
|
41
|
+
label: string;
|
|
42
|
+
/** Glyph naming this kind in an editor's kind bar. A kind without one is
|
|
43
|
+
* named by its `label`. */
|
|
44
|
+
icon?: IconSpec;
|
|
45
|
+
/** The family this kind is offered under; see {@link PaintKindFamily}. A
|
|
46
|
+
* kind without one is its own segment. */
|
|
47
|
+
family?: PaintKindFamily;
|
|
48
|
+
/** A paint of this kind seeded from a color — what an editor writes when a
|
|
49
|
+
* consumer switches a solid to this kind. */
|
|
50
|
+
seed(fromColor: string): Paint;
|
|
51
|
+
/** The single color this paint shows, or `undefined` when it has none. */
|
|
52
|
+
colorOf(paint: Paint): string | undefined;
|
|
53
|
+
/** Editor slot. */
|
|
54
|
+
Editor?: ComponentType<PaintKindEditorProps>;
|
|
55
|
+
/**
|
|
56
|
+
* The stop list this paint reads as. With `fromStops`, it is what makes a
|
|
57
|
+
* kind a gradient: `listGradientKinds` returns the kinds carrying both, and
|
|
58
|
+
* `switchGradientKind` converts between any two of them through the list.
|
|
59
|
+
*/
|
|
60
|
+
stopsOf?(paint: Paint): GradStop[];
|
|
61
|
+
/** A paint of this kind built from a stop list, in `bounds` units. The
|
|
62
|
+
* converse of `stopsOf`; supply both or neither. */
|
|
63
|
+
fromStops?(stops: GradStop[]): Paint;
|
|
64
|
+
/**
|
|
65
|
+
* The `<defs>` entry backing a `url(#id)` reference.
|
|
66
|
+
*
|
|
67
|
+
* SVG has paint servers for two gradients and a pattern and nothing else, so
|
|
68
|
+
* a kind beyond those has no element to target: write a foreign-namespaced
|
|
69
|
+
* one under the `wzl:` prefix `@weasel-js/svg` declares on the root whenever
|
|
70
|
+
* a document holds such a paint. That package emits the fallback color
|
|
71
|
+
* beside the reference on its own, from `colorOf`.
|
|
72
|
+
*/
|
|
73
|
+
toSvg?(id: string, fill: Paint): string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A consumer's own paint, typed as a `Paint`.
|
|
77
|
+
*
|
|
78
|
+
* `Paint` stays a closed union: opening its discriminant would widen every
|
|
79
|
+
* built-in member and break the narrowing the kit's own branches depend on.
|
|
80
|
+
* A registered kind declares its own interface instead and passes it through
|
|
81
|
+
* here — the kit reads only `kind` and hands the whole object back to that
|
|
82
|
+
* kind's slots.
|
|
83
|
+
*/
|
|
84
|
+
declare function asPaint<T extends {
|
|
85
|
+
kind: string;
|
|
86
|
+
}>(paint: T): Paint;
|
|
87
|
+
|
|
88
|
+
export { asPaint as d };
|
|
89
|
+
export type { PaintKindEntry as P, PaintKindFamily as a, PaintKind as b, PaintKindEditorProps as c };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { PaintKindEntry } from './index.js';
|
|
2
|
+
import 'react';
|
|
3
|
+
import '@weasel-js/icons';
|
|
4
|
+
import '@weasel-js/paint';
|
|
5
|
+
import '@weasel-js/renderer';
|
|
6
|
+
|
|
7
|
+
/** Every registered paint kind, as {@link listPaintKinds} returns it,
|
|
8
|
+
* re-rendering the caller whenever a kind is registered or removed. */
|
|
9
|
+
declare function usePaintKinds(): readonly PaintKindEntry[];
|
|
10
|
+
/** Every registered gradient kind, as {@link listGradientKinds} returns it,
|
|
11
|
+
* re-rendering the caller whenever a kind is registered or removed. */
|
|
12
|
+
declare function useGradientKinds(): readonly PaintKindEntry[];
|
|
13
|
+
/**
|
|
14
|
+
* The entry for `kind`, as {@link getPaintKind} returns it — `undefined` until
|
|
15
|
+
* it is registered, and the new entry once it is. A kind with a loader starts
|
|
16
|
+
* loading on the first read.
|
|
17
|
+
*/
|
|
18
|
+
declare function usePaintKind(kind: string | undefined): PaintKindEntry | undefined;
|
|
19
|
+
|
|
20
|
+
export { useGradientKinds, usePaintKind, usePaintKinds };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { paintKindRegistry, listPaintKinds, listGradientKinds, getPaintKind } from './chunk-OZAYBSMO.js';
|
|
2
|
+
import { useSyncExternalStore, useCallback } from 'react';
|
|
3
|
+
|
|
4
|
+
function usePaintKinds() {
|
|
5
|
+
return useSyncExternalStore(paintKindRegistry.subscribe, listPaintKinds, listPaintKinds);
|
|
6
|
+
}
|
|
7
|
+
function useGradientKinds() {
|
|
8
|
+
return useSyncExternalStore(paintKindRegistry.subscribe, listGradientKinds, listGradientKinds);
|
|
9
|
+
}
|
|
10
|
+
function usePaintKind(kind) {
|
|
11
|
+
const read = useCallback(() => getPaintKind(kind), [kind]);
|
|
12
|
+
return useSyncExternalStore(paintKindRegistry.subscribe, read, read);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { useGradientKinds, usePaintKind, usePaintKinds };
|
|
16
|
+
//# sourceMappingURL=react.js.map
|
|
17
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/usePaintKinds.ts"],"names":[],"mappings":";;;AAQO,SAAS,aAAA,GAA2C;AACzD,EAAA,OAAO,oBAAA,CAAqB,iBAAA,CAAkB,SAAA,EAAW,cAAA,EAAgB,cAAc,CAAA;AACzF;AAIO,SAAS,gBAAA,GAA8C;AAC5D,EAAA,OAAO,oBAAA,CAAqB,iBAAA,CAAkB,SAAA,EAAW,iBAAA,EAAmB,iBAAiB,CAAA;AAC/F;AAOO,SAAS,aAAa,IAAA,EAAsD;AACjF,EAAA,MAAM,IAAA,GAAO,YAAY,MAAM,YAAA,CAAa,IAAI,CAAA,EAAG,CAAC,IAAI,CAAC,CAAA;AACzD,EAAA,OAAO,oBAAA,CAAqB,iBAAA,CAAkB,SAAA,EAAW,IAAA,EAAM,IAAI,CAAA;AACrE","file":"react.js","sourcesContent":["import { useCallback, useSyncExternalStore } from 'react';\nimport {\n getPaintKind, listGradientKinds, listPaintKinds, paintKindRegistry,\n} from './paintKinds';\nimport type { PaintKindEntry } from './paintKindEntry';\n\n/** Every registered paint kind, as {@link listPaintKinds} returns it,\n * re-rendering the caller whenever a kind is registered or removed. */\nexport function usePaintKinds(): readonly PaintKindEntry[] {\n return useSyncExternalStore(paintKindRegistry.subscribe, listPaintKinds, listPaintKinds);\n}\n\n/** Every registered gradient kind, as {@link listGradientKinds} returns it,\n * re-rendering the caller whenever a kind is registered or removed. */\nexport function useGradientKinds(): readonly PaintKindEntry[] {\n return useSyncExternalStore(paintKindRegistry.subscribe, listGradientKinds, listGradientKinds);\n}\n\n/**\n * The entry for `kind`, as {@link getPaintKind} returns it — `undefined` until\n * it is registered, and the new entry once it is. A kind with a loader starts\n * loading on the first read.\n */\nexport function usePaintKind(kind: string | undefined): PaintKindEntry | undefined {\n const read = useCallback(() => getPaintKind(kind), [kind]);\n return useSyncExternalStore(paintKindRegistry.subscribe, read, read);\n}\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { _reseedPaintKinds } from './chunk-OZAYBSMO.js';
|
|
2
|
+
import { _resetPaintDrawKindsForTests } from '@weasel-js/renderer/test-seams';
|
|
3
|
+
|
|
4
|
+
function _resetPaintKindsForTests() {
|
|
5
|
+
_resetPaintDrawKindsForTests();
|
|
6
|
+
_reseedPaintKinds();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export { _resetPaintKindsForTests };
|
|
10
|
+
//# sourceMappingURL=test-seams.js.map
|
|
11
|
+
//# sourceMappingURL=test-seams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/test-seams.ts"],"names":[],"mappings":";;;AASO,SAAS,wBAAA,GAAiC;AAC/C,EAAA,4BAAA,EAA6B;AAC7B,EAAA,iBAAA,EAAkB;AACpB","file":"test-seams.js","sourcesContent":["/**\n * Test seams for `@weasel-js/paint-kinds`. Not consumer surface.\n *\n * @packageDocumentation\n */\nimport { _resetPaintDrawKindsForTests } from '@weasel-js/renderer/test-seams';\nimport { _reseedPaintKinds } from './paintKinds';\n\n/** The paint-kind registry, and the renderer's draw half of it, back to the built-ins alone. */\nexport function _resetPaintKindsForTests(): void {\n _resetPaintDrawKindsForTests();\n _reseedPaintKinds();\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,84 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weasel-js/paint-kinds",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.19.1",
|
|
4
|
+
"description": "The registry of paint kinds a weasel paint can be: solid, the gradients, the tile patterns, image, texture, mesh and any a consumer registers, each with its label, glyph, seed color, editor and SVG output, and the renderer's draw slots.",
|
|
5
|
+
"weasel": {
|
|
6
|
+
"tier": "base"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "module",
|
|
10
|
+
"sideEffects": [
|
|
11
|
+
"./src/mesh.ts",
|
|
12
|
+
"./dist/mesh.js"
|
|
13
|
+
],
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./react": {
|
|
23
|
+
"types": "./dist/react.d.ts",
|
|
24
|
+
"import": "./dist/react.js"
|
|
25
|
+
},
|
|
26
|
+
"./mesh": {
|
|
27
|
+
"types": "./dist/mesh.d.ts",
|
|
28
|
+
"import": "./dist/mesh.js"
|
|
29
|
+
},
|
|
30
|
+
"./icons": {
|
|
31
|
+
"types": "./dist/icons.table.d.ts",
|
|
32
|
+
"import": "./dist/icons.table.js"
|
|
33
|
+
},
|
|
34
|
+
"./test-seams": {
|
|
35
|
+
"types": "./dist/test-seams.d.ts",
|
|
36
|
+
"import": "./dist/test-seams.js"
|
|
37
|
+
},
|
|
38
|
+
"./package.json": "./package.json"
|
|
39
|
+
},
|
|
40
|
+
"weaselIcons": {
|
|
41
|
+
"table": "./dist/icons.table.json"
|
|
42
|
+
},
|
|
43
|
+
"author": "orochi235",
|
|
44
|
+
"homepage": "https://orochi235.github.io/weasel/",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "git+https://github.com/orochi235/weasel.git",
|
|
48
|
+
"directory": "packages/paint-kinds"
|
|
49
|
+
},
|
|
50
|
+
"bugs": {
|
|
51
|
+
"url": "https://github.com/orochi235/weasel/issues"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=24"
|
|
55
|
+
},
|
|
56
|
+
"files": [
|
|
57
|
+
"dist",
|
|
58
|
+
"README.md",
|
|
59
|
+
"LICENSE"
|
|
60
|
+
],
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsup && cp src/icons.table.json dist/",
|
|
63
|
+
"test": "node ../../scripts/package-test.mjs"
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@weasel-js/geom": "1.19.1",
|
|
67
|
+
"@weasel-js/icons": "1.19.1",
|
|
68
|
+
"@weasel-js/paint": "1.19.1",
|
|
69
|
+
"@weasel-js/registry": "1.19.1",
|
|
70
|
+
"@weasel-js/renderer": "1.19.1"
|
|
71
|
+
},
|
|
72
|
+
"peerDependencies": {
|
|
73
|
+
"react": ">=18"
|
|
74
|
+
},
|
|
75
|
+
"peerDependenciesMeta": {
|
|
76
|
+
"react": {
|
|
77
|
+
"optional": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"access": "public",
|
|
82
|
+
"provenance": true
|
|
83
|
+
}
|
|
84
|
+
}
|