@pixerate/editor 0.109.0 → 0.110.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/blending-DXl06NSx.d.ts +486 -0
- package/dist/blending-aOE6Y3UE.d.cts +486 -0
- package/dist/chunk-7VOHOPLW.cjs +1136 -0
- package/dist/chunk-7VOHOPLW.cjs.map +1 -0
- package/dist/{chunk-RE77QYUF.js → chunk-DMRSJBJF.js} +3 -3
- package/dist/chunk-FTBZPI77.cjs +1 -0
- package/dist/chunk-FTBZPI77.cjs.map +1 -0
- package/dist/{chunk-WMBIJCHA.js → chunk-HNS7UHCM.js} +5 -1
- package/dist/{chunk-WMBIJCHA.js.map → chunk-HNS7UHCM.js.map} +1 -1
- package/dist/{chunk-CFMWALBM.js → chunk-LQEEDHOP.js} +2 -2
- package/dist/{chunk-D37BX2ZA.cjs → chunk-MGL4U5WA.cjs} +199 -199
- package/dist/{chunk-D37BX2ZA.cjs.map → chunk-MGL4U5WA.cjs.map} +1 -1
- package/dist/{chunk-AZTZRLDI.cjs → chunk-POGBUYWE.cjs} +92 -92
- package/dist/{chunk-AZTZRLDI.cjs.map → chunk-POGBUYWE.cjs.map} +1 -1
- package/dist/chunk-VKK5VS2T.js +1 -0
- package/dist/{chunk-SZ6KMZNM.cjs → chunk-XIOMMGPD.cjs} +6 -2
- package/dist/chunk-XIOMMGPD.cjs.map +1 -0
- package/dist/{chunk-3PHA3UKI.js → chunk-Z4BC6M74.js} +523 -121
- package/dist/chunk-Z4BC6M74.js.map +1 -0
- package/dist/{export-BLPLaE6Z.d.ts → export-CO2ryu3I.d.ts} +3 -3
- package/dist/{export-DSUc4fQD.d.cts → export-DRiLzP_j.d.cts} +3 -3
- package/dist/image-editor/index.cjs +722 -696
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +9 -9
- package/dist/image-editor/index.d.ts +9 -9
- package/dist/image-editor/index.js +31 -5
- package/dist/image-editor/index.js.map +1 -1
- package/dist/paint/index.cjs +28 -4
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +3 -89
- package/dist/paint/index.d.ts +3 -89
- package/dist/paint/index.js +27 -3
- package/dist/paint-editor/index.cjs +1052 -286
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +301 -22
- package/dist/paint-editor/index.d.ts +301 -22
- package/dist/paint-editor/index.js +848 -82
- package/dist/paint-editor/index.js.map +1 -1
- package/dist/raster/index.cjs +5 -3
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.d.cts +2 -2
- package/dist/raster/index.d.ts +2 -2
- package/dist/raster/index.js +4 -2
- package/dist/{render-C-fO_mes.d.cts → render-BEriFuqK.d.cts} +1 -1
- package/dist/{render-OLIMk_v0.d.ts → render-tjzKaik-.d.ts} +1 -1
- package/dist/{surface-CkKOHGPm.d.cts → surface-C8RRg_Bh.d.cts} +109 -1
- package/dist/{surface-CkKOHGPm.d.ts → surface-C8RRg_Bh.d.ts} +109 -1
- package/package.json +1 -1
- package/skills/pixerate-paint-editor/SKILL.md +49 -13
- package/dist/chunk-3PHA3UKI.js.map +0 -1
- package/dist/chunk-6BU5WU4R.cjs +0 -1
- package/dist/chunk-6BU5WU4R.cjs.map +0 -1
- package/dist/chunk-HUFQD4CB.cjs +0 -734
- package/dist/chunk-HUFQD4CB.cjs.map +0 -1
- package/dist/chunk-SZ6KMZNM.cjs.map +0 -1
- package/dist/chunk-XYBJKUAU.js +0 -1
- package/dist/mixer-5ziHU8OS.d.cts +0 -282
- package/dist/mixer-DNqiYXYQ.d.ts +0 -282
- /package/dist/{chunk-RE77QYUF.js.map → chunk-DMRSJBJF.js.map} +0 -0
- /package/dist/{chunk-CFMWALBM.js.map → chunk-LQEEDHOP.js.map} +0 -0
- /package/dist/{chunk-XYBJKUAU.js.map → chunk-VKK5VS2T.js.map} +0 -0
package/dist/paint/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-FTBZPI77.cjs');
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
var _chunkHUFQD4CBcjs = require('../chunk-HUFQD4CB.cjs');
|
|
30
29
|
|
|
31
30
|
|
|
32
31
|
|
|
@@ -39,7 +38,7 @@ var _chunkHUFQD4CBcjs = require('../chunk-HUFQD4CB.cjs');
|
|
|
39
38
|
|
|
40
39
|
|
|
41
40
|
|
|
42
|
-
var
|
|
41
|
+
var _chunk7VOHOPLWcjs = require('../chunk-7VOHOPLW.cjs');
|
|
43
42
|
|
|
44
43
|
|
|
45
44
|
|
|
@@ -52,6 +51,7 @@ var _chunkSZ6KMZNMcjs = require('../chunk-SZ6KMZNM.cjs');
|
|
|
52
51
|
|
|
53
52
|
|
|
54
53
|
|
|
54
|
+
var _chunkXIOMMGPDcjs = require('../chunk-XIOMMGPD.cjs');
|
|
55
55
|
|
|
56
56
|
|
|
57
57
|
|
|
@@ -78,5 +78,29 @@ var _chunkSZ6KMZNMcjs = require('../chunk-SZ6KMZNM.cjs');
|
|
|
78
78
|
|
|
79
79
|
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
exports.CoverageMap = _chunk7VOHOPLWcjs.CoverageMap; exports.DEFAULT_BLENDER = _chunk7VOHOPLWcjs.DEFAULT_BLENDER; exports.DEFAULT_BRUSH = _chunk7VOHOPLWcjs.DEFAULT_BRUSH; exports.DEFAULT_MIXER = _chunk7VOHOPLWcjs.DEFAULT_MIXER; exports.DEFAULT_SMUDGE = _chunk7VOHOPLWcjs.DEFAULT_SMUDGE; exports.DabWalker = _chunk7VOHOPLWcjs.DabWalker; exports.EMPTY_MIXER_LOAD = _chunk7VOHOPLWcjs.EMPTY_MIXER_LOAD; exports.MAX_BRUSH_SIZE = _chunk7VOHOPLWcjs.MAX_BRUSH_SIZE; exports.MIXER_DRAIN = _chunk7VOHOPLWcjs.MIXER_DRAIN; exports.MIXER_PICKUP_RATE = _chunk7VOHOPLWcjs.MIXER_PICKUP_RATE; exports.MIXING_MODELS = _chunk7VOHOPLWcjs.MIXING_MODELS; exports.MixerStroke = _chunk7VOHOPLWcjs.MixerStroke; exports.PIGMENT_BANDS = _chunkXIOMMGPDcjs.PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = _chunkXIOMMGPDcjs.PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = _chunkXIOMMGPDcjs.PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = _chunkXIOMMGPDcjs.PIGMENT_WAVELENGTHS; exports.PaintExchange = _chunk7VOHOPLWcjs.PaintExchange; exports.SmudgeTip = _chunk7VOHOPLWcjs.SmudgeTip; exports.StrokeCoverage = _chunk7VOHOPLWcjs.StrokeCoverage; exports.TileMedium = _chunk7VOHOPLWcjs.TileMedium; exports.applyStrokeToTile = _chunk7VOHOPLWcjs.applyStrokeToTile; exports.blendRadius = _chunk7VOHOPLWcjs.blendRadius; exports.blenderDab = _chunk7VOHOPLWcjs.blenderDab; exports.cleanMixer = _chunk7VOHOPLWcjs.cleanMixer; exports.coverageTileCoord = _chunk7VOHOPLWcjs.coverageTileCoord; exports.createBlenderScratch = _chunk7VOHOPLWcjs.createBlenderScratch; exports.createPigment = _chunkXIOMMGPDcjs.createPigment; exports.createPigmentTools = _chunk7VOHOPLWcjs.createPigmentTools; exports.dabCoverage = _chunk7VOHOPLWcjs.dabCoverage; exports.dabRect = _chunk7VOHOPLWcjs.dabRect; exports.exchangeRates = _chunk7VOHOPLWcjs.exchangeRates; exports.lerpPigment = _chunkXIOMMGPDcjs.lerpPigment; exports.lerpPigmentInto = _chunkXIOMMGPDcjs.lerpPigmentInto; exports.loadMixer = _chunk7VOHOPLWcjs.loadMixer; exports.mixPigments = _chunkXIOMMGPDcjs.mixPigments; exports.mixerRates = _chunk7VOHOPLWcjs.mixerRates; exports.normalizeBlender = _chunk7VOHOPLWcjs.normalizeBlender; exports.normalizeBrush = _chunk7VOHOPLWcjs.normalizeBrush; exports.normalizeMixer = _chunk7VOHOPLWcjs.normalizeMixer; exports.normalizeSmudge = _chunk7VOHOPLWcjs.normalizeSmudge; exports.rasterizeDab = _chunk7VOHOPLWcjs.rasterizeDab; exports.reflectanceToRgb = _chunkXIOMMGPDcjs.reflectanceToRgb; exports.rgbToReflectance = _chunkXIOMMGPDcjs.rgbToReflectance; exports.setPigmentColor = _chunkXIOMMGPDcjs.setPigmentColor; exports.smoothPoints = _chunk7VOHOPLWcjs.smoothPoints; exports.tipFalloff = _chunk7VOHOPLWcjs.tipFalloff; exports.tipReach = _chunk7VOHOPLWcjs.tipReach; exports.tipShape = _chunk7VOHOPLWcjs.tipShape; exports.walkDabs = _chunk7VOHOPLWcjs.walkDabs;
|
|
82
106
|
//# sourceMappingURL=index.cjs.map
|
package/dist/paint/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/paint/index.cjs"],"names":[],"mappings":"AAAA,0GAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/paint/index.cjs"],"names":[],"mappings":"AAAA,0GAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,4uFAAC","file":"/home/runner/work/editor/editor/packages/core/dist/paint/index.cjs"}
|
package/dist/paint/index.d.cts
CHANGED
|
@@ -1,98 +1,12 @@
|
|
|
1
|
-
export { B as BrushSettings, C as CoverageMap,
|
|
1
|
+
export { j as BlenderScratch, b as BlenderSettings, B as BrushSettings, C as CoverageMap, k as DEFAULT_BLENDER, l as DEFAULT_BRUSH, m as DEFAULT_MIXER, n as DEFAULT_SMUDGE, D as Dab, o as DabWalker, E as EMPTY_MIXER_LOAD, p as ExchangeRates, e as MAX_BRUSH_SIZE, q as MIXER_DRAIN, r as MIXER_PICKUP_RATE, s as MIXING_MODELS, d as MixerLoad, M as MixerSettings, h as MixerStroke, g as MixerTarget, a as MixingModel, t as PaintExchange, u as PaintMedium, v as PaintSample, P as PaintTileTarget, R as RgbTriple, w as SmudgeDab, S as SmudgeSettings, x as SmudgeTip, i as StrokeApply, f as StrokeCoverage, c as StrokePoint, T as TileMedium, y as TileMediumOptions, z as applyStrokeToTile, A as blendRadius, F as blenderDab, G as cleanMixer, H as coverageTileCoord, I as createBlenderScratch, J as dabCoverage, K as dabRect, L as exchangeRates, N as loadMixer, O as mixerRates, Q as normalizeBlender, U as normalizeBrush, V as normalizeMixer, W as normalizeSmudge, X as rasterizeDab, Y as smoothPoints, Z as tipFalloff, _ as tipReach, $ as tipShape, a0 as walkDabs } from '../blending-aOE6Y3UE.cjs';
|
|
2
|
+
export { h as PIGMENT_BANDS, j as PIGMENT_LAMBDA_MIN, k as PIGMENT_LAMBDA_STEP, l as PIGMENT_WAVELENGTHS, P as Pigment, m as PigmentOptions, n as PigmentRgb, D as createPigment, I as lerpPigment, J as lerpPigmentInto, N as mixPigments, X as reflectanceToRgb, Y as rgbToReflectance, _ as setPigmentColor } from '../surface-C8RRg_Bh.cjs';
|
|
2
3
|
import { A as AgentTool } from '../registry-BqA1AZt0.cjs';
|
|
3
|
-
import '../surface-CkKOHGPm.cjs';
|
|
4
4
|
import '../schema-Di0CS6Pe.cjs';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Pigment-like colour mixing: blue and yellow make green, red and white make pink, as paint does.
|
|
8
|
-
*
|
|
9
|
-
* Each sRGB colour is lifted to a smooth reflectance spectrum, the spectra are mixed with the
|
|
10
|
-
* Kubelka-Munk two-flux model, and the mixed spectrum is turned back into sRGB. Written from the
|
|
11
|
-
* published literature; no third-party code or data:
|
|
12
|
-
*
|
|
13
|
-
* 1. **Spectral uplift.** A colour's reflectance is a sigmoid of a quadratic in wavelength,
|
|
14
|
-
* `R(λ) = s(c₀λ² + c₁λ + c₂)` with `s(z) = ½ + z / 2√(1 + z²)` (Jakob & Hanika, "A
|
|
15
|
-
* Low-Dimensional Function Space for Efficient Spectral Upsampling", Eurographics 2019). The
|
|
16
|
-
* three coefficients are solved per colour with Newton's method so the spectrum reproduces the
|
|
17
|
-
* colour. Spectra are precomputed lazily on a 17³ lattice over sRGB and interpolated
|
|
18
|
-
* trilinearly in *linear* RGB: colour is linear in reflectance, so an interpolated spectrum
|
|
19
|
-
* still reproduces its colour exactly while staying smooth and inside 0..1.
|
|
20
|
-
* 2. **Mixing.** Each spectrum becomes `K/S = (1 − R)² / 2R` per band. Colours mix with the
|
|
21
|
-
* two-constant form `K/S = Σ cᵢSᵢ(K/S)ᵢ / Σ cᵢSᵢ`, where `cᵢ` is the weight times the colour's
|
|
22
|
-
* tinting strength and `Sᵢ` its scattering, taken from its luminance (light paints such as
|
|
23
|
-
* titanium white scatter strongly, dark ones barely). Back to reflectance with
|
|
24
|
-
* `R = 1 + K/S − √((K/S)² + 2·K/S)`.
|
|
25
|
-
* 3. **Back to sRGB.** The spectrum is weighted by the CIE 1931 2° colour-matching functions
|
|
26
|
-
* (the analytic multi-lobe fit of Wyman, Sloan & Shirley, JCGT 2013) under a 6504 K Planckian
|
|
27
|
-
* illuminant, converted to linear sRGB and normalised so a perfect white reflector is exactly
|
|
28
|
-
* white. Analytic curves keep the CIE's own (CC BY-SA) tables out of the package.
|
|
29
|
-
*
|
|
30
|
-
* Everything is plain TypeScript on typed arrays with no DOM: it runs in Node and Workers and is
|
|
31
|
-
* deterministic. Colours are straight sRGB triples in 0..1, as in `@pixerate/editor/raster`.
|
|
32
|
-
*/
|
|
33
|
-
/** An sRGB colour, each channel 0..1 (gamma-encoded, as in CSS). */
|
|
34
|
-
type PigmentRgb = readonly [number, number, number];
|
|
35
|
-
/** Number of spectral bands. */
|
|
36
|
-
declare const PIGMENT_BANDS = 36;
|
|
37
|
-
/** First band's wavelength in nm; bands are 10 nm apart (380..730 nm). */
|
|
38
|
-
declare const PIGMENT_LAMBDA_MIN = 380;
|
|
39
|
-
declare const PIGMENT_LAMBDA_STEP = 10;
|
|
40
|
-
/** Band centre wavelengths in nm. */
|
|
41
|
-
declare const PIGMENT_WAVELENGTHS: Float32Array;
|
|
42
|
-
/**
|
|
43
|
-
* The smooth reflectance spectrum (0..1 per band, `PIGMENT_BANDS` bands from 380 nm in 10 nm
|
|
44
|
-
* steps) of an sRGB colour. `reflectanceToRgb` of the result gives the colour back.
|
|
45
|
-
*/
|
|
46
|
-
declare function rgbToReflectance(r: number, g: number, b: number, out?: Float32Array): Float32Array;
|
|
47
|
-
/** The sRGB colour (0..1, clipped to the gamut) of a reflectance spectrum. */
|
|
48
|
-
declare function reflectanceToRgb(reflectance: ArrayLike<number>, out?: number[]): number[];
|
|
49
|
-
/**
|
|
50
|
-
* A colour prepared for mixing: its K/S spectrum and its weight in a mix. Make one per brush or
|
|
51
|
-
* palette colour with `createPigment` and reuse it (`setPigmentColor`) on hot paths.
|
|
52
|
-
*/
|
|
53
|
-
interface Pigment {
|
|
54
|
-
/** The sRGB colour it was made from (0..1). */
|
|
55
|
-
readonly rgb: [number, number, number];
|
|
56
|
-
/** Tinting strength (default 1): how strongly it colours a mix, relative to its weight. */
|
|
57
|
-
strength: number;
|
|
58
|
-
/** K/S per band. */
|
|
59
|
-
readonly ks: Float32Array;
|
|
60
|
-
/** Scattering from the colour's luminance (floored), before strength. */
|
|
61
|
-
scatter: number;
|
|
62
|
-
}
|
|
63
|
-
interface PigmentOptions {
|
|
64
|
-
/**
|
|
65
|
-
* Tinting strength, > 0 (default 1). A strength of 4 counts each part as four, so a little of
|
|
66
|
-
* a strong dark pigment tints a lot of white. A colour mixed only with itself is unchanged
|
|
67
|
-
* whatever its strength.
|
|
68
|
-
*/
|
|
69
|
-
strength?: number;
|
|
70
|
-
}
|
|
71
|
-
/** Prepares a colour for mixing. */
|
|
72
|
-
declare function createPigment(color: PigmentRgb, options?: PigmentOptions): Pigment;
|
|
73
|
-
/** Re-targets a pigment to another colour without allocating (the per-pixel fast path). */
|
|
74
|
-
declare function setPigmentColor(pigment: Pigment, r: number, g: number, b: number, strength?: number): Pigment;
|
|
75
|
-
/**
|
|
76
|
-
* Mixes colours like paint. `weights` are parts by amount (any non-negative scale; at least one
|
|
77
|
-
* positive). Colours may be sRGB triples (0..1) or prepared pigments (which carry a tinting
|
|
78
|
-
* strength). Returns the mixed sRGB colour (0..1).
|
|
79
|
-
*/
|
|
80
|
-
declare function mixPigments(colors: readonly (PigmentRgb | Pigment)[], weights: readonly number[]): [number, number, number];
|
|
81
|
-
/** Mixes `a` towards `b` like paint: `t = 0` is `a`, `t = 1` is `b`. */
|
|
82
|
-
declare function lerpPigment(a: PigmentRgb | Pigment, b: PigmentRgb | Pigment, t: number): [number, number, number];
|
|
83
|
-
/**
|
|
84
|
-
* The per-dab fast path: mixes two prepared pigments (`t` of `b` into `a`) and writes the sRGB
|
|
85
|
-
* result to `out[offset..offset + 2]`, without allocating. Pair it with `setPigmentColor` for the
|
|
86
|
-
* colour under the brush.
|
|
87
|
-
*/
|
|
88
|
-
declare function lerpPigmentInto(a: Pigment, b: Pigment, t: number, out: {
|
|
89
|
-
[i: number]: number;
|
|
90
|
-
}, offset?: number): void;
|
|
91
|
-
|
|
92
6
|
/**
|
|
93
7
|
* Agent tools for pigment mixing (`@pixerate/editor/paint`). `mix_colors` is read-only: it
|
|
94
8
|
* predicts what paints mixed in given amounts look like, for choosing a brush or fill colour.
|
|
95
9
|
*/
|
|
96
10
|
declare function createPigmentTools(): AgentTool[];
|
|
97
11
|
|
|
98
|
-
export {
|
|
12
|
+
export { createPigmentTools };
|
package/dist/paint/index.d.ts
CHANGED
|
@@ -1,98 +1,12 @@
|
|
|
1
|
-
export { B as BrushSettings, C as CoverageMap,
|
|
1
|
+
export { j as BlenderScratch, b as BlenderSettings, B as BrushSettings, C as CoverageMap, k as DEFAULT_BLENDER, l as DEFAULT_BRUSH, m as DEFAULT_MIXER, n as DEFAULT_SMUDGE, D as Dab, o as DabWalker, E as EMPTY_MIXER_LOAD, p as ExchangeRates, e as MAX_BRUSH_SIZE, q as MIXER_DRAIN, r as MIXER_PICKUP_RATE, s as MIXING_MODELS, d as MixerLoad, M as MixerSettings, h as MixerStroke, g as MixerTarget, a as MixingModel, t as PaintExchange, u as PaintMedium, v as PaintSample, P as PaintTileTarget, R as RgbTriple, w as SmudgeDab, S as SmudgeSettings, x as SmudgeTip, i as StrokeApply, f as StrokeCoverage, c as StrokePoint, T as TileMedium, y as TileMediumOptions, z as applyStrokeToTile, A as blendRadius, F as blenderDab, G as cleanMixer, H as coverageTileCoord, I as createBlenderScratch, J as dabCoverage, K as dabRect, L as exchangeRates, N as loadMixer, O as mixerRates, Q as normalizeBlender, U as normalizeBrush, V as normalizeMixer, W as normalizeSmudge, X as rasterizeDab, Y as smoothPoints, Z as tipFalloff, _ as tipReach, $ as tipShape, a0 as walkDabs } from '../blending-DXl06NSx.js';
|
|
2
|
+
export { h as PIGMENT_BANDS, j as PIGMENT_LAMBDA_MIN, k as PIGMENT_LAMBDA_STEP, l as PIGMENT_WAVELENGTHS, P as Pigment, m as PigmentOptions, n as PigmentRgb, D as createPigment, I as lerpPigment, J as lerpPigmentInto, N as mixPigments, X as reflectanceToRgb, Y as rgbToReflectance, _ as setPigmentColor } from '../surface-C8RRg_Bh.js';
|
|
2
3
|
import { A as AgentTool } from '../registry-D-4fit9C.js';
|
|
3
|
-
import '../surface-CkKOHGPm.js';
|
|
4
4
|
import '../schema-Di0CS6Pe.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Pigment-like colour mixing: blue and yellow make green, red and white make pink, as paint does.
|
|
8
|
-
*
|
|
9
|
-
* Each sRGB colour is lifted to a smooth reflectance spectrum, the spectra are mixed with the
|
|
10
|
-
* Kubelka-Munk two-flux model, and the mixed spectrum is turned back into sRGB. Written from the
|
|
11
|
-
* published literature; no third-party code or data:
|
|
12
|
-
*
|
|
13
|
-
* 1. **Spectral uplift.** A colour's reflectance is a sigmoid of a quadratic in wavelength,
|
|
14
|
-
* `R(λ) = s(c₀λ² + c₁λ + c₂)` with `s(z) = ½ + z / 2√(1 + z²)` (Jakob & Hanika, "A
|
|
15
|
-
* Low-Dimensional Function Space for Efficient Spectral Upsampling", Eurographics 2019). The
|
|
16
|
-
* three coefficients are solved per colour with Newton's method so the spectrum reproduces the
|
|
17
|
-
* colour. Spectra are precomputed lazily on a 17³ lattice over sRGB and interpolated
|
|
18
|
-
* trilinearly in *linear* RGB: colour is linear in reflectance, so an interpolated spectrum
|
|
19
|
-
* still reproduces its colour exactly while staying smooth and inside 0..1.
|
|
20
|
-
* 2. **Mixing.** Each spectrum becomes `K/S = (1 − R)² / 2R` per band. Colours mix with the
|
|
21
|
-
* two-constant form `K/S = Σ cᵢSᵢ(K/S)ᵢ / Σ cᵢSᵢ`, where `cᵢ` is the weight times the colour's
|
|
22
|
-
* tinting strength and `Sᵢ` its scattering, taken from its luminance (light paints such as
|
|
23
|
-
* titanium white scatter strongly, dark ones barely). Back to reflectance with
|
|
24
|
-
* `R = 1 + K/S − √((K/S)² + 2·K/S)`.
|
|
25
|
-
* 3. **Back to sRGB.** The spectrum is weighted by the CIE 1931 2° colour-matching functions
|
|
26
|
-
* (the analytic multi-lobe fit of Wyman, Sloan & Shirley, JCGT 2013) under a 6504 K Planckian
|
|
27
|
-
* illuminant, converted to linear sRGB and normalised so a perfect white reflector is exactly
|
|
28
|
-
* white. Analytic curves keep the CIE's own (CC BY-SA) tables out of the package.
|
|
29
|
-
*
|
|
30
|
-
* Everything is plain TypeScript on typed arrays with no DOM: it runs in Node and Workers and is
|
|
31
|
-
* deterministic. Colours are straight sRGB triples in 0..1, as in `@pixerate/editor/raster`.
|
|
32
|
-
*/
|
|
33
|
-
/** An sRGB colour, each channel 0..1 (gamma-encoded, as in CSS). */
|
|
34
|
-
type PigmentRgb = readonly [number, number, number];
|
|
35
|
-
/** Number of spectral bands. */
|
|
36
|
-
declare const PIGMENT_BANDS = 36;
|
|
37
|
-
/** First band's wavelength in nm; bands are 10 nm apart (380..730 nm). */
|
|
38
|
-
declare const PIGMENT_LAMBDA_MIN = 380;
|
|
39
|
-
declare const PIGMENT_LAMBDA_STEP = 10;
|
|
40
|
-
/** Band centre wavelengths in nm. */
|
|
41
|
-
declare const PIGMENT_WAVELENGTHS: Float32Array;
|
|
42
|
-
/**
|
|
43
|
-
* The smooth reflectance spectrum (0..1 per band, `PIGMENT_BANDS` bands from 380 nm in 10 nm
|
|
44
|
-
* steps) of an sRGB colour. `reflectanceToRgb` of the result gives the colour back.
|
|
45
|
-
*/
|
|
46
|
-
declare function rgbToReflectance(r: number, g: number, b: number, out?: Float32Array): Float32Array;
|
|
47
|
-
/** The sRGB colour (0..1, clipped to the gamut) of a reflectance spectrum. */
|
|
48
|
-
declare function reflectanceToRgb(reflectance: ArrayLike<number>, out?: number[]): number[];
|
|
49
|
-
/**
|
|
50
|
-
* A colour prepared for mixing: its K/S spectrum and its weight in a mix. Make one per brush or
|
|
51
|
-
* palette colour with `createPigment` and reuse it (`setPigmentColor`) on hot paths.
|
|
52
|
-
*/
|
|
53
|
-
interface Pigment {
|
|
54
|
-
/** The sRGB colour it was made from (0..1). */
|
|
55
|
-
readonly rgb: [number, number, number];
|
|
56
|
-
/** Tinting strength (default 1): how strongly it colours a mix, relative to its weight. */
|
|
57
|
-
strength: number;
|
|
58
|
-
/** K/S per band. */
|
|
59
|
-
readonly ks: Float32Array;
|
|
60
|
-
/** Scattering from the colour's luminance (floored), before strength. */
|
|
61
|
-
scatter: number;
|
|
62
|
-
}
|
|
63
|
-
interface PigmentOptions {
|
|
64
|
-
/**
|
|
65
|
-
* Tinting strength, > 0 (default 1). A strength of 4 counts each part as four, so a little of
|
|
66
|
-
* a strong dark pigment tints a lot of white. A colour mixed only with itself is unchanged
|
|
67
|
-
* whatever its strength.
|
|
68
|
-
*/
|
|
69
|
-
strength?: number;
|
|
70
|
-
}
|
|
71
|
-
/** Prepares a colour for mixing. */
|
|
72
|
-
declare function createPigment(color: PigmentRgb, options?: PigmentOptions): Pigment;
|
|
73
|
-
/** Re-targets a pigment to another colour without allocating (the per-pixel fast path). */
|
|
74
|
-
declare function setPigmentColor(pigment: Pigment, r: number, g: number, b: number, strength?: number): Pigment;
|
|
75
|
-
/**
|
|
76
|
-
* Mixes colours like paint. `weights` are parts by amount (any non-negative scale; at least one
|
|
77
|
-
* positive). Colours may be sRGB triples (0..1) or prepared pigments (which carry a tinting
|
|
78
|
-
* strength). Returns the mixed sRGB colour (0..1).
|
|
79
|
-
*/
|
|
80
|
-
declare function mixPigments(colors: readonly (PigmentRgb | Pigment)[], weights: readonly number[]): [number, number, number];
|
|
81
|
-
/** Mixes `a` towards `b` like paint: `t = 0` is `a`, `t = 1` is `b`. */
|
|
82
|
-
declare function lerpPigment(a: PigmentRgb | Pigment, b: PigmentRgb | Pigment, t: number): [number, number, number];
|
|
83
|
-
/**
|
|
84
|
-
* The per-dab fast path: mixes two prepared pigments (`t` of `b` into `a`) and writes the sRGB
|
|
85
|
-
* result to `out[offset..offset + 2]`, without allocating. Pair it with `setPigmentColor` for the
|
|
86
|
-
* colour under the brush.
|
|
87
|
-
*/
|
|
88
|
-
declare function lerpPigmentInto(a: Pigment, b: Pigment, t: number, out: {
|
|
89
|
-
[i: number]: number;
|
|
90
|
-
}, offset?: number): void;
|
|
91
|
-
|
|
92
6
|
/**
|
|
93
7
|
* Agent tools for pigment mixing (`@pixerate/editor/paint`). `mix_colors` is read-only: it
|
|
94
8
|
* predicts what paints mixed in given amounts look like, for choosing a brush or fill colour.
|
|
95
9
|
*/
|
|
96
10
|
declare function createPigmentTools(): AgentTool[];
|
|
97
11
|
|
|
98
|
-
export {
|
|
12
|
+
export { createPigmentTools };
|
package/dist/paint/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import "../chunk-
|
|
1
|
+
import "../chunk-VKK5VS2T.js";
|
|
2
2
|
import {
|
|
3
3
|
CoverageMap,
|
|
4
|
+
DEFAULT_BLENDER,
|
|
4
5
|
DEFAULT_BRUSH,
|
|
5
6
|
DEFAULT_MIXER,
|
|
7
|
+
DEFAULT_SMUDGE,
|
|
6
8
|
DabWalker,
|
|
7
9
|
EMPTY_MIXER_LOAD,
|
|
8
10
|
MAX_BRUSH_SIZE,
|
|
@@ -10,23 +12,33 @@ import {
|
|
|
10
12
|
MIXER_PICKUP_RATE,
|
|
11
13
|
MIXING_MODELS,
|
|
12
14
|
MixerStroke,
|
|
15
|
+
PaintExchange,
|
|
16
|
+
SmudgeTip,
|
|
13
17
|
StrokeCoverage,
|
|
18
|
+
TileMedium,
|
|
14
19
|
applyStrokeToTile,
|
|
20
|
+
blendRadius,
|
|
21
|
+
blenderDab,
|
|
15
22
|
cleanMixer,
|
|
16
23
|
coverageTileCoord,
|
|
24
|
+
createBlenderScratch,
|
|
17
25
|
createPigmentTools,
|
|
18
26
|
dabCoverage,
|
|
19
27
|
dabRect,
|
|
28
|
+
exchangeRates,
|
|
20
29
|
loadMixer,
|
|
30
|
+
mixerRates,
|
|
31
|
+
normalizeBlender,
|
|
21
32
|
normalizeBrush,
|
|
22
33
|
normalizeMixer,
|
|
34
|
+
normalizeSmudge,
|
|
23
35
|
rasterizeDab,
|
|
24
36
|
smoothPoints,
|
|
25
37
|
tipFalloff,
|
|
26
38
|
tipReach,
|
|
27
39
|
tipShape,
|
|
28
40
|
walkDabs
|
|
29
|
-
} from "../chunk-
|
|
41
|
+
} from "../chunk-Z4BC6M74.js";
|
|
30
42
|
import {
|
|
31
43
|
PIGMENT_BANDS,
|
|
32
44
|
PIGMENT_LAMBDA_MIN,
|
|
@@ -39,11 +51,13 @@ import {
|
|
|
39
51
|
reflectanceToRgb,
|
|
40
52
|
rgbToReflectance,
|
|
41
53
|
setPigmentColor
|
|
42
|
-
} from "../chunk-
|
|
54
|
+
} from "../chunk-HNS7UHCM.js";
|
|
43
55
|
export {
|
|
44
56
|
CoverageMap,
|
|
57
|
+
DEFAULT_BLENDER,
|
|
45
58
|
DEFAULT_BRUSH,
|
|
46
59
|
DEFAULT_MIXER,
|
|
60
|
+
DEFAULT_SMUDGE,
|
|
47
61
|
DabWalker,
|
|
48
62
|
EMPTY_MIXER_LOAD,
|
|
49
63
|
MAX_BRUSH_SIZE,
|
|
@@ -55,20 +69,30 @@ export {
|
|
|
55
69
|
PIGMENT_LAMBDA_MIN,
|
|
56
70
|
PIGMENT_LAMBDA_STEP,
|
|
57
71
|
PIGMENT_WAVELENGTHS,
|
|
72
|
+
PaintExchange,
|
|
73
|
+
SmudgeTip,
|
|
58
74
|
StrokeCoverage,
|
|
75
|
+
TileMedium,
|
|
59
76
|
applyStrokeToTile,
|
|
77
|
+
blendRadius,
|
|
78
|
+
blenderDab,
|
|
60
79
|
cleanMixer,
|
|
61
80
|
coverageTileCoord,
|
|
81
|
+
createBlenderScratch,
|
|
62
82
|
createPigment,
|
|
63
83
|
createPigmentTools,
|
|
64
84
|
dabCoverage,
|
|
65
85
|
dabRect,
|
|
86
|
+
exchangeRates,
|
|
66
87
|
lerpPigment,
|
|
67
88
|
lerpPigmentInto,
|
|
68
89
|
loadMixer,
|
|
69
90
|
mixPigments,
|
|
91
|
+
mixerRates,
|
|
92
|
+
normalizeBlender,
|
|
70
93
|
normalizeBrush,
|
|
71
94
|
normalizeMixer,
|
|
95
|
+
normalizeSmudge,
|
|
72
96
|
rasterizeDab,
|
|
73
97
|
reflectanceToRgb,
|
|
74
98
|
rgbToReflectance,
|