@pixerate/editor 0.92.0 → 0.93.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/{chunk-PDCITYBT.cjs → chunk-4F3YDIWW.cjs} +367 -2
- package/dist/chunk-4F3YDIWW.cjs.map +1 -0
- package/dist/{chunk-YLB2WVNA.js → chunk-ISDCJHTO.js} +367 -2
- package/dist/chunk-ISDCJHTO.js.map +1 -0
- package/dist/image-editor/index.cjs +36 -11
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +1 -1
- package/dist/image-editor/index.d.ts +1 -1
- package/dist/image-editor/index.js +26 -1
- package/dist/image-editor/index.js.map +1 -1
- package/dist/paint/index.cjs +26 -2
- package/dist/paint/index.cjs.map +1 -1
- package/dist/paint/index.d.cts +95 -1
- package/dist/paint/index.d.ts +95 -1
- package/dist/paint/index.js +25 -1
- package/package.json +3 -3
- package/skills/pixerate-image-editor/SKILL.md +8 -0
- package/dist/chunk-PDCITYBT.cjs.map +0 -1
- package/dist/chunk-YLB2WVNA.js.map +0 -1
package/dist/paint/index.cjs
CHANGED
|
@@ -15,7 +15,19 @@
|
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
var _chunk4F3YDIWWcjs = require('../chunk-4F3YDIWW.cjs');
|
|
19
31
|
require('../chunk-ZOOEX3WT.cjs');
|
|
20
32
|
|
|
21
33
|
|
|
@@ -34,5 +46,17 @@ require('../chunk-ZOOEX3WT.cjs');
|
|
|
34
46
|
|
|
35
47
|
|
|
36
48
|
|
|
37
|
-
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
exports.CoverageMap = _chunk4F3YDIWWcjs.CoverageMap; exports.DEFAULT_BRUSH = _chunk4F3YDIWWcjs.DEFAULT_BRUSH; exports.DabWalker = _chunk4F3YDIWWcjs.DabWalker; exports.MAX_BRUSH_SIZE = _chunk4F3YDIWWcjs.MAX_BRUSH_SIZE; exports.PIGMENT_BANDS = _chunk4F3YDIWWcjs.PIGMENT_BANDS; exports.PIGMENT_LAMBDA_MIN = _chunk4F3YDIWWcjs.PIGMENT_LAMBDA_MIN; exports.PIGMENT_LAMBDA_STEP = _chunk4F3YDIWWcjs.PIGMENT_LAMBDA_STEP; exports.PIGMENT_WAVELENGTHS = _chunk4F3YDIWWcjs.PIGMENT_WAVELENGTHS; exports.StrokeCoverage = _chunk4F3YDIWWcjs.StrokeCoverage; exports.applyStrokeToTile = _chunk4F3YDIWWcjs.applyStrokeToTile; exports.coverageTileCoord = _chunk4F3YDIWWcjs.coverageTileCoord; exports.createPigment = _chunk4F3YDIWWcjs.createPigment; exports.createPigmentTools = _chunk4F3YDIWWcjs.createPigmentTools; exports.dabCoverage = _chunk4F3YDIWWcjs.dabCoverage; exports.dabRect = _chunk4F3YDIWWcjs.dabRect; exports.lerpPigment = _chunk4F3YDIWWcjs.lerpPigment; exports.lerpPigmentInto = _chunk4F3YDIWWcjs.lerpPigmentInto; exports.mixPigments = _chunk4F3YDIWWcjs.mixPigments; exports.normalizeBrush = _chunk4F3YDIWWcjs.normalizeBrush; exports.rasterizeDab = _chunk4F3YDIWWcjs.rasterizeDab; exports.reflectanceToRgb = _chunk4F3YDIWWcjs.reflectanceToRgb; exports.rgbToReflectance = _chunk4F3YDIWWcjs.rgbToReflectance; exports.setPigmentColor = _chunk4F3YDIWWcjs.setPigmentColor; exports.smoothPoints = _chunk4F3YDIWWcjs.smoothPoints; exports.tipFalloff = _chunk4F3YDIWWcjs.tipFalloff; exports.tipReach = _chunk4F3YDIWWcjs.tipReach; exports.tipShape = _chunk4F3YDIWWcjs.tipShape; exports.walkDabs = _chunk4F3YDIWWcjs.walkDabs;
|
|
38
62
|
//# 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;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,yDAA8B;AAC9B,iCAA8B;AAC9B;AACE;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;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;AACF,yDAA8B;AAC9B,iCAA8B;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;AACF,qkDAAC","file":"/home/runner/work/editor/editor/packages/core/dist/paint/index.cjs"}
|
package/dist/paint/index.d.cts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { B as BlendMode, R as RasterRect, h as TileKey } from '../surface-fJhkmNQn.cjs';
|
|
2
|
+
import { A as AgentTool } from '../registry-BqA1AZt0.cjs';
|
|
3
|
+
import '../schema-Di0CS6Pe.cjs';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* The brush engine (a subset of photocraft's `crates/paint`): a computed round tip with size,
|
|
@@ -164,4 +166,96 @@ declare function coverageTileCoord(key: TileKey): {
|
|
|
164
166
|
ty: number;
|
|
165
167
|
};
|
|
166
168
|
|
|
167
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Pigment-like colour mixing: blue and yellow make green, red and white make pink, as paint does.
|
|
171
|
+
*
|
|
172
|
+
* Each sRGB colour is lifted to a smooth reflectance spectrum, the spectra are mixed with the
|
|
173
|
+
* Kubelka-Munk two-flux model, and the mixed spectrum is turned back into sRGB. Written from the
|
|
174
|
+
* published literature; no third-party code or data:
|
|
175
|
+
*
|
|
176
|
+
* 1. **Spectral uplift.** A colour's reflectance is a sigmoid of a quadratic in wavelength,
|
|
177
|
+
* `R(λ) = s(c₀λ² + c₁λ + c₂)` with `s(z) = ½ + z / 2√(1 + z²)` (Jakob & Hanika, "A
|
|
178
|
+
* Low-Dimensional Function Space for Efficient Spectral Upsampling", Eurographics 2019). The
|
|
179
|
+
* three coefficients are solved per colour with Newton's method so the spectrum reproduces the
|
|
180
|
+
* colour. Spectra are precomputed lazily on a 17³ lattice over sRGB and interpolated
|
|
181
|
+
* trilinearly in *linear* RGB: colour is linear in reflectance, so an interpolated spectrum
|
|
182
|
+
* still reproduces its colour exactly while staying smooth and inside 0..1.
|
|
183
|
+
* 2. **Mixing.** Each spectrum becomes `K/S = (1 − R)² / 2R` per band. Colours mix with the
|
|
184
|
+
* two-constant form `K/S = Σ cᵢSᵢ(K/S)ᵢ / Σ cᵢSᵢ`, where `cᵢ` is the weight times the colour's
|
|
185
|
+
* tinting strength and `Sᵢ` its scattering, taken from its luminance (light paints such as
|
|
186
|
+
* titanium white scatter strongly, dark ones barely). Back to reflectance with
|
|
187
|
+
* `R = 1 + K/S − √((K/S)² + 2·K/S)`.
|
|
188
|
+
* 3. **Back to sRGB.** The spectrum is weighted by the CIE 1931 2° colour-matching functions
|
|
189
|
+
* (the analytic multi-lobe fit of Wyman, Sloan & Shirley, JCGT 2013) under a 6504 K Planckian
|
|
190
|
+
* illuminant, converted to linear sRGB and normalised so a perfect white reflector is exactly
|
|
191
|
+
* white. Analytic curves keep the CIE's own (CC BY-SA) tables out of the package.
|
|
192
|
+
*
|
|
193
|
+
* Everything is plain TypeScript on typed arrays with no DOM: it runs in Node and Workers and is
|
|
194
|
+
* deterministic. Colours are straight sRGB triples in 0..1, as in `@pixerate/editor/raster`.
|
|
195
|
+
*/
|
|
196
|
+
/** An sRGB colour, each channel 0..1 (gamma-encoded, as in CSS). */
|
|
197
|
+
type PigmentRgb = readonly [number, number, number];
|
|
198
|
+
/** Number of spectral bands. */
|
|
199
|
+
declare const PIGMENT_BANDS = 36;
|
|
200
|
+
/** First band's wavelength in nm; bands are 10 nm apart (380..730 nm). */
|
|
201
|
+
declare const PIGMENT_LAMBDA_MIN = 380;
|
|
202
|
+
declare const PIGMENT_LAMBDA_STEP = 10;
|
|
203
|
+
/** Band centre wavelengths in nm. */
|
|
204
|
+
declare const PIGMENT_WAVELENGTHS: Float32Array;
|
|
205
|
+
/**
|
|
206
|
+
* The smooth reflectance spectrum (0..1 per band, `PIGMENT_BANDS` bands from 380 nm in 10 nm
|
|
207
|
+
* steps) of an sRGB colour. `reflectanceToRgb` of the result gives the colour back.
|
|
208
|
+
*/
|
|
209
|
+
declare function rgbToReflectance(r: number, g: number, b: number, out?: Float32Array): Float32Array;
|
|
210
|
+
/** The sRGB colour (0..1, clipped to the gamut) of a reflectance spectrum. */
|
|
211
|
+
declare function reflectanceToRgb(reflectance: ArrayLike<number>, out?: number[]): number[];
|
|
212
|
+
/**
|
|
213
|
+
* A colour prepared for mixing: its K/S spectrum and its weight in a mix. Make one per brush or
|
|
214
|
+
* palette colour with `createPigment` and reuse it (`setPigmentColor`) on hot paths.
|
|
215
|
+
*/
|
|
216
|
+
interface Pigment {
|
|
217
|
+
/** The sRGB colour it was made from (0..1). */
|
|
218
|
+
readonly rgb: [number, number, number];
|
|
219
|
+
/** Tinting strength (default 1): how strongly it colours a mix, relative to its weight. */
|
|
220
|
+
strength: number;
|
|
221
|
+
/** K/S per band. */
|
|
222
|
+
readonly ks: Float32Array;
|
|
223
|
+
/** Scattering from the colour's luminance (floored), before strength. */
|
|
224
|
+
scatter: number;
|
|
225
|
+
}
|
|
226
|
+
interface PigmentOptions {
|
|
227
|
+
/**
|
|
228
|
+
* Tinting strength, > 0 (default 1). A strength of 4 counts each part as four, so a little of
|
|
229
|
+
* a strong dark pigment tints a lot of white. A colour mixed only with itself is unchanged
|
|
230
|
+
* whatever its strength.
|
|
231
|
+
*/
|
|
232
|
+
strength?: number;
|
|
233
|
+
}
|
|
234
|
+
/** Prepares a colour for mixing. */
|
|
235
|
+
declare function createPigment(color: PigmentRgb, options?: PigmentOptions): Pigment;
|
|
236
|
+
/** Re-targets a pigment to another colour without allocating (the per-pixel fast path). */
|
|
237
|
+
declare function setPigmentColor(pigment: Pigment, r: number, g: number, b: number, strength?: number): Pigment;
|
|
238
|
+
/**
|
|
239
|
+
* Mixes colours like paint. `weights` are parts by amount (any non-negative scale; at least one
|
|
240
|
+
* positive). Colours may be sRGB triples (0..1) or prepared pigments (which carry a tinting
|
|
241
|
+
* strength). Returns the mixed sRGB colour (0..1).
|
|
242
|
+
*/
|
|
243
|
+
declare function mixPigments(colors: readonly (PigmentRgb | Pigment)[], weights: readonly number[]): [number, number, number];
|
|
244
|
+
/** Mixes `a` towards `b` like paint: `t = 0` is `a`, `t = 1` is `b`. */
|
|
245
|
+
declare function lerpPigment(a: PigmentRgb | Pigment, b: PigmentRgb | Pigment, t: number): [number, number, number];
|
|
246
|
+
/**
|
|
247
|
+
* The per-dab fast path: mixes two prepared pigments (`t` of `b` into `a`) and writes the sRGB
|
|
248
|
+
* result to `out[offset..offset + 2]`, without allocating. Pair it with `setPigmentColor` for the
|
|
249
|
+
* colour under the brush.
|
|
250
|
+
*/
|
|
251
|
+
declare function lerpPigmentInto(a: Pigment, b: Pigment, t: number, out: {
|
|
252
|
+
[i: number]: number;
|
|
253
|
+
}, offset?: number): void;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Agent tools for pigment mixing (`@pixerate/editor/paint`). `mix_colors` is read-only: it
|
|
257
|
+
* predicts what paints mixed in given amounts look like, for choosing a brush or fill colour.
|
|
258
|
+
*/
|
|
259
|
+
declare function createPigmentTools(): AgentTool[];
|
|
260
|
+
|
|
261
|
+
export { type BrushSettings, CoverageMap, DEFAULT_BRUSH, type Dab, DabWalker, MAX_BRUSH_SIZE, PIGMENT_BANDS, PIGMENT_LAMBDA_MIN, PIGMENT_LAMBDA_STEP, PIGMENT_WAVELENGTHS, type Pigment, type PigmentOptions, type PigmentRgb, type StrokeApply, StrokeCoverage, type StrokePoint, applyStrokeToTile, coverageTileCoord, createPigment, createPigmentTools, dabCoverage, dabRect, lerpPigment, lerpPigmentInto, mixPigments, normalizeBrush, rasterizeDab, reflectanceToRgb, rgbToReflectance, setPigmentColor, smoothPoints, tipFalloff, tipReach, tipShape, walkDabs };
|
package/dist/paint/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { B as BlendMode, R as RasterRect, h as TileKey } from '../surface-fJhkmNQn.js';
|
|
2
|
+
import { A as AgentTool } from '../registry-D-4fit9C.js';
|
|
3
|
+
import '../schema-Di0CS6Pe.js';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
6
|
* The brush engine (a subset of photocraft's `crates/paint`): a computed round tip with size,
|
|
@@ -164,4 +166,96 @@ declare function coverageTileCoord(key: TileKey): {
|
|
|
164
166
|
ty: number;
|
|
165
167
|
};
|
|
166
168
|
|
|
167
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Pigment-like colour mixing: blue and yellow make green, red and white make pink, as paint does.
|
|
171
|
+
*
|
|
172
|
+
* Each sRGB colour is lifted to a smooth reflectance spectrum, the spectra are mixed with the
|
|
173
|
+
* Kubelka-Munk two-flux model, and the mixed spectrum is turned back into sRGB. Written from the
|
|
174
|
+
* published literature; no third-party code or data:
|
|
175
|
+
*
|
|
176
|
+
* 1. **Spectral uplift.** A colour's reflectance is a sigmoid of a quadratic in wavelength,
|
|
177
|
+
* `R(λ) = s(c₀λ² + c₁λ + c₂)` with `s(z) = ½ + z / 2√(1 + z²)` (Jakob & Hanika, "A
|
|
178
|
+
* Low-Dimensional Function Space for Efficient Spectral Upsampling", Eurographics 2019). The
|
|
179
|
+
* three coefficients are solved per colour with Newton's method so the spectrum reproduces the
|
|
180
|
+
* colour. Spectra are precomputed lazily on a 17³ lattice over sRGB and interpolated
|
|
181
|
+
* trilinearly in *linear* RGB: colour is linear in reflectance, so an interpolated spectrum
|
|
182
|
+
* still reproduces its colour exactly while staying smooth and inside 0..1.
|
|
183
|
+
* 2. **Mixing.** Each spectrum becomes `K/S = (1 − R)² / 2R` per band. Colours mix with the
|
|
184
|
+
* two-constant form `K/S = Σ cᵢSᵢ(K/S)ᵢ / Σ cᵢSᵢ`, where `cᵢ` is the weight times the colour's
|
|
185
|
+
* tinting strength and `Sᵢ` its scattering, taken from its luminance (light paints such as
|
|
186
|
+
* titanium white scatter strongly, dark ones barely). Back to reflectance with
|
|
187
|
+
* `R = 1 + K/S − √((K/S)² + 2·K/S)`.
|
|
188
|
+
* 3. **Back to sRGB.** The spectrum is weighted by the CIE 1931 2° colour-matching functions
|
|
189
|
+
* (the analytic multi-lobe fit of Wyman, Sloan & Shirley, JCGT 2013) under a 6504 K Planckian
|
|
190
|
+
* illuminant, converted to linear sRGB and normalised so a perfect white reflector is exactly
|
|
191
|
+
* white. Analytic curves keep the CIE's own (CC BY-SA) tables out of the package.
|
|
192
|
+
*
|
|
193
|
+
* Everything is plain TypeScript on typed arrays with no DOM: it runs in Node and Workers and is
|
|
194
|
+
* deterministic. Colours are straight sRGB triples in 0..1, as in `@pixerate/editor/raster`.
|
|
195
|
+
*/
|
|
196
|
+
/** An sRGB colour, each channel 0..1 (gamma-encoded, as in CSS). */
|
|
197
|
+
type PigmentRgb = readonly [number, number, number];
|
|
198
|
+
/** Number of spectral bands. */
|
|
199
|
+
declare const PIGMENT_BANDS = 36;
|
|
200
|
+
/** First band's wavelength in nm; bands are 10 nm apart (380..730 nm). */
|
|
201
|
+
declare const PIGMENT_LAMBDA_MIN = 380;
|
|
202
|
+
declare const PIGMENT_LAMBDA_STEP = 10;
|
|
203
|
+
/** Band centre wavelengths in nm. */
|
|
204
|
+
declare const PIGMENT_WAVELENGTHS: Float32Array;
|
|
205
|
+
/**
|
|
206
|
+
* The smooth reflectance spectrum (0..1 per band, `PIGMENT_BANDS` bands from 380 nm in 10 nm
|
|
207
|
+
* steps) of an sRGB colour. `reflectanceToRgb` of the result gives the colour back.
|
|
208
|
+
*/
|
|
209
|
+
declare function rgbToReflectance(r: number, g: number, b: number, out?: Float32Array): Float32Array;
|
|
210
|
+
/** The sRGB colour (0..1, clipped to the gamut) of a reflectance spectrum. */
|
|
211
|
+
declare function reflectanceToRgb(reflectance: ArrayLike<number>, out?: number[]): number[];
|
|
212
|
+
/**
|
|
213
|
+
* A colour prepared for mixing: its K/S spectrum and its weight in a mix. Make one per brush or
|
|
214
|
+
* palette colour with `createPigment` and reuse it (`setPigmentColor`) on hot paths.
|
|
215
|
+
*/
|
|
216
|
+
interface Pigment {
|
|
217
|
+
/** The sRGB colour it was made from (0..1). */
|
|
218
|
+
readonly rgb: [number, number, number];
|
|
219
|
+
/** Tinting strength (default 1): how strongly it colours a mix, relative to its weight. */
|
|
220
|
+
strength: number;
|
|
221
|
+
/** K/S per band. */
|
|
222
|
+
readonly ks: Float32Array;
|
|
223
|
+
/** Scattering from the colour's luminance (floored), before strength. */
|
|
224
|
+
scatter: number;
|
|
225
|
+
}
|
|
226
|
+
interface PigmentOptions {
|
|
227
|
+
/**
|
|
228
|
+
* Tinting strength, > 0 (default 1). A strength of 4 counts each part as four, so a little of
|
|
229
|
+
* a strong dark pigment tints a lot of white. A colour mixed only with itself is unchanged
|
|
230
|
+
* whatever its strength.
|
|
231
|
+
*/
|
|
232
|
+
strength?: number;
|
|
233
|
+
}
|
|
234
|
+
/** Prepares a colour for mixing. */
|
|
235
|
+
declare function createPigment(color: PigmentRgb, options?: PigmentOptions): Pigment;
|
|
236
|
+
/** Re-targets a pigment to another colour without allocating (the per-pixel fast path). */
|
|
237
|
+
declare function setPigmentColor(pigment: Pigment, r: number, g: number, b: number, strength?: number): Pigment;
|
|
238
|
+
/**
|
|
239
|
+
* Mixes colours like paint. `weights` are parts by amount (any non-negative scale; at least one
|
|
240
|
+
* positive). Colours may be sRGB triples (0..1) or prepared pigments (which carry a tinting
|
|
241
|
+
* strength). Returns the mixed sRGB colour (0..1).
|
|
242
|
+
*/
|
|
243
|
+
declare function mixPigments(colors: readonly (PigmentRgb | Pigment)[], weights: readonly number[]): [number, number, number];
|
|
244
|
+
/** Mixes `a` towards `b` like paint: `t = 0` is `a`, `t = 1` is `b`. */
|
|
245
|
+
declare function lerpPigment(a: PigmentRgb | Pigment, b: PigmentRgb | Pigment, t: number): [number, number, number];
|
|
246
|
+
/**
|
|
247
|
+
* The per-dab fast path: mixes two prepared pigments (`t` of `b` into `a`) and writes the sRGB
|
|
248
|
+
* result to `out[offset..offset + 2]`, without allocating. Pair it with `setPigmentColor` for the
|
|
249
|
+
* colour under the brush.
|
|
250
|
+
*/
|
|
251
|
+
declare function lerpPigmentInto(a: Pigment, b: Pigment, t: number, out: {
|
|
252
|
+
[i: number]: number;
|
|
253
|
+
}, offset?: number): void;
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Agent tools for pigment mixing (`@pixerate/editor/paint`). `mix_colors` is read-only: it
|
|
257
|
+
* predicts what paints mixed in given amounts look like, for choosing a brush or fill colour.
|
|
258
|
+
*/
|
|
259
|
+
declare function createPigmentTools(): AgentTool[];
|
|
260
|
+
|
|
261
|
+
export { type BrushSettings, CoverageMap, DEFAULT_BRUSH, type Dab, DabWalker, MAX_BRUSH_SIZE, PIGMENT_BANDS, PIGMENT_LAMBDA_MIN, PIGMENT_LAMBDA_STEP, PIGMENT_WAVELENGTHS, type Pigment, type PigmentOptions, type PigmentRgb, type StrokeApply, StrokeCoverage, type StrokePoint, applyStrokeToTile, coverageTileCoord, createPigment, createPigmentTools, dabCoverage, dabRect, lerpPigment, lerpPigmentInto, mixPigments, normalizeBrush, rasterizeDab, reflectanceToRgb, rgbToReflectance, setPigmentColor, smoothPoints, tipFalloff, tipReach, tipShape, walkDabs };
|
package/dist/paint/index.js
CHANGED
|
@@ -3,32 +3,56 @@ import {
|
|
|
3
3
|
DEFAULT_BRUSH,
|
|
4
4
|
DabWalker,
|
|
5
5
|
MAX_BRUSH_SIZE,
|
|
6
|
+
PIGMENT_BANDS,
|
|
7
|
+
PIGMENT_LAMBDA_MIN,
|
|
8
|
+
PIGMENT_LAMBDA_STEP,
|
|
9
|
+
PIGMENT_WAVELENGTHS,
|
|
6
10
|
StrokeCoverage,
|
|
7
11
|
applyStrokeToTile,
|
|
8
12
|
coverageTileCoord,
|
|
13
|
+
createPigment,
|
|
14
|
+
createPigmentTools,
|
|
9
15
|
dabCoverage,
|
|
10
16
|
dabRect,
|
|
17
|
+
lerpPigment,
|
|
18
|
+
lerpPigmentInto,
|
|
19
|
+
mixPigments,
|
|
11
20
|
normalizeBrush,
|
|
12
21
|
rasterizeDab,
|
|
22
|
+
reflectanceToRgb,
|
|
23
|
+
rgbToReflectance,
|
|
24
|
+
setPigmentColor,
|
|
13
25
|
smoothPoints,
|
|
14
26
|
tipFalloff,
|
|
15
27
|
tipReach,
|
|
16
28
|
tipShape,
|
|
17
29
|
walkDabs
|
|
18
|
-
} from "../chunk-
|
|
30
|
+
} from "../chunk-ISDCJHTO.js";
|
|
19
31
|
import "../chunk-D4ZCU72J.js";
|
|
20
32
|
export {
|
|
21
33
|
CoverageMap,
|
|
22
34
|
DEFAULT_BRUSH,
|
|
23
35
|
DabWalker,
|
|
24
36
|
MAX_BRUSH_SIZE,
|
|
37
|
+
PIGMENT_BANDS,
|
|
38
|
+
PIGMENT_LAMBDA_MIN,
|
|
39
|
+
PIGMENT_LAMBDA_STEP,
|
|
40
|
+
PIGMENT_WAVELENGTHS,
|
|
25
41
|
StrokeCoverage,
|
|
26
42
|
applyStrokeToTile,
|
|
27
43
|
coverageTileCoord,
|
|
44
|
+
createPigment,
|
|
45
|
+
createPigmentTools,
|
|
28
46
|
dabCoverage,
|
|
29
47
|
dabRect,
|
|
48
|
+
lerpPigment,
|
|
49
|
+
lerpPigmentInto,
|
|
50
|
+
mixPigments,
|
|
30
51
|
normalizeBrush,
|
|
31
52
|
rasterizeDab,
|
|
53
|
+
reflectanceToRgb,
|
|
54
|
+
rgbToReflectance,
|
|
55
|
+
setPigmentColor,
|
|
32
56
|
smoothPoints,
|
|
33
57
|
tipFalloff,
|
|
34
58
|
tipReach,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pixerate/editor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.93.0",
|
|
4
4
|
"description": "UI-agnostic rich text and media editing core library",
|
|
5
5
|
"author": "Pixerate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -186,13 +186,13 @@
|
|
|
186
186
|
"@tiptap/pm": "^2.11.5",
|
|
187
187
|
"@types/dagre": "^0.7.54",
|
|
188
188
|
"@types/markdown-it": "^14.2.0",
|
|
189
|
-
"@types/node": "^
|
|
189
|
+
"@types/node": "^26.6.5",
|
|
190
190
|
"fast-check": "^3.23.2",
|
|
191
191
|
"mermaid": "12.0.0",
|
|
192
192
|
"tiptap-markdown": "^0.8.10",
|
|
193
193
|
"tsup": "^8.4.0",
|
|
194
194
|
"typescript": "^5.7.3",
|
|
195
|
-
"vitest": "^
|
|
195
|
+
"vitest": "^5.0.5"
|
|
196
196
|
},
|
|
197
197
|
"peerDependencies": {
|
|
198
198
|
"@dagrejs/dagre": "^1.1.8",
|
|
@@ -79,6 +79,11 @@ batching.
|
|
|
79
79
|
4. **Limit paint with a selection** (select first, then `paint_stroke` / `fill_pixels`), or lock
|
|
80
80
|
transparency (`set_layer_properties` `locks.transparency`) to paint only where the layer
|
|
81
81
|
already has pixels.
|
|
82
|
+
5. **Mix paint colours with `mix_colors`** when the user names paints and amounts ("two parts
|
|
83
|
+
ultramarine to one part yellow", "a tint of red"). It mixes like pigment, so blue and yellow
|
|
84
|
+
make green and white makes a tint, where averaging RGB gives grey or a dull pastel. Pass its
|
|
85
|
+
`mixed` hex as the `color` of `paint_stroke` or `fill_pixels`. Give a strong dark paint a
|
|
86
|
+
`strength` above 1 when a little of it should tint a lot of white.
|
|
82
87
|
|
|
83
88
|
### Photoshop files
|
|
84
89
|
|
|
@@ -195,6 +200,7 @@ batching.
|
|
|
195
200
|
| `remove_layer_filter` | Remove a filter. Returns the remaining filters. |
|
|
196
201
|
| `paint_stroke` | Paint (`tool` brush) or erase (`tool` eraser) along `points` in document px (optional `pressure` 0..1) on a pixel layer or its mask (`channel`); `color` #rrggbb (on a mask: black hides, white reveals); `brush` `{size, hardness, spacing, angle, roundness, opacity, flow, smoothing, pressureSize, pressureOpacity, blend}`. The selection limits the paint. One undo step per call. Returns the layer, channel, changed `bounds` and dab count. |
|
|
197
202
|
| `fill_pixels` | Fill the selection (or the canvas without one / with `useSelection: false`) on pixels or a mask with `color`, `opacity`, `blend`. Returns the changed bounds. |
|
|
203
|
+
| `mix_colors` | Read-only. Mix 1 to 16 `colors` (`{color: #rrggbb, weight, strength?}`) like paint (Kubelka-Munk over reflectance spectra). Returns `mixed` (#rrggbb), `rgbLerp` (the plain RGB average, for comparison) and the normalised `weights`. Call it before `paint_stroke` / `fill_pixels` to pick a paint colour. |
|
|
198
204
|
| `clear_pixels` | Remove the selected pixels (alpha to 0; a transparency-locked layer or a mask gets the background colour). Returns the changed bounds. |
|
|
199
205
|
| `import_psd` | Open a PSD / PSB (`data` base64, a `data:` URL is fine) as the document, replacing the layers, crop and rotation (one undo step). Returns the new `layers` tree with ids, `layerIds`, size and `warnings` naming the affected layers. Call `inspect_psd` first when losses matter. |
|
|
200
206
|
| `apply_selection_as_mask` | Mask a layer with the current selection: pass `layerId` to mask an existing layer, or `kind` (plus optional `params`) to create a new masked layer in one step. `density` 0..1 and `feather` px soften the mask non-destructively. Returns `layerId`, kind, mask info and the selection summary. |
|
|
@@ -211,6 +217,8 @@ batching.
|
|
|
211
217
|
- `paint_stroke`, `fill_pixels` and `clear_pixels` need a visible pixel layer (or a layer with a
|
|
212
218
|
raster mask and `channel: "mask"`); adjustment, group and annotation layers can only be
|
|
213
219
|
painted through their masks. A layer with `locks.pixels` refuses paint.
|
|
220
|
+
- `mix_colors` predicts a mix; it does not paint, and strokes still lay paint down with normal
|
|
221
|
+
blending (there is no pigment blend mode or mixer brush yet).
|
|
214
222
|
- `export_psd` is in the source frame: a crop or rotation is not in the file (the warnings say
|
|
215
223
|
so). Crop with `set_crop` only for PNG / JPEG output, or flatten the look you need first.
|
|
216
224
|
- PSD opacity, fill and mask density come in as whole percents (Photoshop stores bytes), so a
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/chunk-PDCITYBT.cjs","../src/paint/brush.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;AC+CO,IAAM,cAAA,EAAyC;AAAA,EACpD,IAAA,EAAM,EAAA;AAAA,EACN,QAAA,EAAU,CAAA;AAAA,EACV,OAAA,EAAS,GAAA;AAAA,EACT,KAAA,EAAO,CAAA;AAAA,EACP,SAAA,EAAW,CAAA;AAAA,EACX,OAAA,EAAS,CAAA;AAAA,EACT,IAAA,EAAM,CAAA;AAAA,EACN,SAAA,EAAW,CAAA;AAAA,EACX,YAAA,EAAc,IAAA;AAAA,EACd,eAAA,EAAiB,KAAA;AAAA,EACjB,KAAA,EAAO;AACT,CAAA;AAEO,IAAM,eAAA,EAAiB,IAAA;AAGvB,SAAS,cAAA,CAAe,IAAA,EAA8B,CAAC,CAAA,EAAkB;AAC9E,EAAA,MAAM,IAAA,EAAM,CAAC,CAAA,EAAY,EAAA,EAAY,EAAA,EAAY,CAAA,EAAA,GAAe,OAAO,EAAA,IAAM,SAAA,GAA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or/packages/core/dist/chunk-PDCITYBT.cjs","sourcesContent":[null,"// Portions ported from photocraft/crates/paint/src/lib.rs, dynamics.rs and render.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\n\n/**\n * The brush engine (a subset of photocraft's `crates/paint`): a computed round tip with size,\n * hardness, angle, roundness and spacing; pressure to size and opacity; smoothing; and Photoshop's\n * opacity-versus-flow build-up. Strokes are data, so one replays the same way for undo, agents\n * and tests.\n *\n * - Points are walked into dabs at `spacing × diameter` (`walkDabs`).\n * - Each dab's coverage (`dabCoverage`, photocraft's measured Photoshop profile) builds up in a\n * stroke coverage map with flow towards the dab's opacity ceiling: `c ← c + v·(ceil − c)`.\n * - The stroke composites once at the stroke opacity over the layer as it was before the stroke,\n * so overlapping dabs never exceed the opacity.\n */\n\nimport { blendPixel, type BlendMode } from '../raster/blend';\nimport type { RasterRect as CropBox } from '../raster/surface';\nimport { TILE, tileKey, tileCoord, type TileKey } from '../raster/surface';\n\n/** One input sample. Missing pressure is a mouse (1). */\nexport interface StrokePoint {\n x: number;\n y: number;\n /** 0..1 (default 1). */\n pressure?: number;\n /** Milliseconds (optional; kept for replays). */\n t?: number;\n}\n\nexport interface BrushSettings {\n /** Diameter in pixels (1..2500, default 20). */\n size: number;\n /** 0 (soft) .. 1 (hard, default). */\n hardness: number;\n /** Dab spacing as a fraction of the diameter (0.01..10, default 0.1). */\n spacing: number;\n /** Tip angle in degrees (default 0). */\n angle: number;\n /** Tip roundness 0.01..1 (default 1). */\n roundness: number;\n /** Stroke opacity ceiling 0..1 (default 1). */\n opacity: number;\n /** Build-up per dab 0..1 (default 1). */\n flow: number;\n /** Input smoothing 0..0.95 (default 0). */\n smoothing: number;\n /** Pressure controls size (default true). */\n pressureSize: boolean;\n /** Pressure controls opacity (default false). */\n pressureOpacity: boolean;\n /** How the stroke paints onto the layer (default normal). */\n blend: BlendMode;\n}\n\nexport const DEFAULT_BRUSH: Readonly<BrushSettings> = {\n size: 20,\n hardness: 1,\n spacing: 0.1,\n angle: 0,\n roundness: 1,\n opacity: 1,\n flow: 1,\n smoothing: 0,\n pressureSize: true,\n pressureOpacity: false,\n blend: 'normal',\n};\n\nexport const MAX_BRUSH_SIZE = 2500;\n\n/** A brush with every field in range (missing fields from `DEFAULT_BRUSH`). */\nexport function normalizeBrush(raw: Partial<BrushSettings> = {}): BrushSettings {\n const num = (v: unknown, lo: number, hi: number, d: number) => (typeof v === 'number' && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : d);\n return {\n size: num(raw.size, 1, MAX_BRUSH_SIZE, DEFAULT_BRUSH.size),\n hardness: num(raw.hardness, 0, 1, DEFAULT_BRUSH.hardness),\n spacing: num(raw.spacing, 0.01, 10, DEFAULT_BRUSH.spacing),\n angle: num(raw.angle, -360, 360, DEFAULT_BRUSH.angle),\n roundness: num(raw.roundness, 0.01, 1, DEFAULT_BRUSH.roundness),\n opacity: num(raw.opacity, 0, 1, DEFAULT_BRUSH.opacity),\n flow: num(raw.flow, 0, 1, DEFAULT_BRUSH.flow),\n smoothing: num(raw.smoothing, 0, 0.95, DEFAULT_BRUSH.smoothing),\n pressureSize: typeof raw.pressureSize === 'boolean' ? raw.pressureSize : DEFAULT_BRUSH.pressureSize,\n pressureOpacity: typeof raw.pressureOpacity === 'boolean' ? raw.pressureOpacity : DEFAULT_BRUSH.pressureOpacity,\n blend: raw.blend ?? 'normal',\n };\n}\n\n// ---------------------------------------------------------------------------\n// The round tip (photocraft's measured Photoshop profile)\n// ---------------------------------------------------------------------------\n\n/**\n * Photoshop's round tip, measured by photocraft: a solid core of radius `r0 · R`, then a Gaussian\n * shoulder `exp(-((d − r0) / s)²)` of width `s · R`, both by hardness (0, 0.1, … 1).\n */\nconst TIP_SHAPE: ReadonlyArray<[number, number]> = [\n [0.0, 0.664], [0.14, 0.58], [0.28, 0.5], [0.4, 0.44], [0.52, 0.36], [0.63, 0.29],\n [0.7, 0.24], [0.78, 0.19], [0.84, 0.15], [0.89, 0.11], [1.0, 0.0],\n];\n/** The anti-aliased edge: the shoulder never narrows below this many pixels. */\nconst TIP_EDGE_PX = 1.2;\nconst SMALL_TIP_RADIUS = 3;\nconst SUBPIXEL = [-0.375, -0.125, 0.125, 0.375];\n\n/** The core radius and shoulder width (pixels) of a round tip of `radius` and `hardness`. */\nexport function tipShape(radius: number, hardness: number): [number, number] {\n const h = (Number.isNaN(hardness) ? 0 : Math.min(1, Math.max(0, hardness))) * 10;\n const i = Math.min(9, Math.floor(h));\n const t = h - i;\n const a = TIP_SHAPE[i];\n const b = TIP_SHAPE[i + 1];\n const r0 = a[0] + (b[0] - a[0]) * t;\n const s = a[1] + (b[1] - a[1]) * t;\n const r = Number.isFinite(radius) ? Math.max(0, radius) : 0;\n const edge = Math.max(0.25, Math.min(TIP_EDGE_PX, 0.3 * r));\n return [Math.max(0, Math.min(r0 * r, r - edge)), Math.max(1e-3, s * r, edge)];\n}\n\n/** `exp(-u)` as `(1 − u/64)^64` by six squarings: exactly 0 from u = 64. */\nfunction softExp(u: number): number {\n let g = Math.min(1, Math.max(0, 1 - u / 64));\n for (let k = 0; k < 6; k++) g *= g;\n return g;\n}\n\n/** Opacity of a round tip at distance `d` from its centre. */\nexport function tipFalloff(d: number, radius: number, hardness: number): number {\n const [r0, s] = tipShape(radius, hardness);\n if (d <= r0) return 1;\n const x = (d - r0) / s;\n return softExp(x * x);\n}\n\n/** How far from its centre a round tip still paints. */\nexport function tipReach(radius: number, hardness: number): number {\n const [r0, s] = tipShape(radius, hardness);\n return r0 + 2.6 * s;\n}\n\n/** Coverage of a round dab at distance `d` from its centre. */\nexport function dabCoverage(d: number, radius: number, hardness: number): number {\n if (Number.isNaN(d) || d >= tipReach(radius, hardness) + 0.5) return 0;\n return tipFalloff(d, radius, hardness);\n}\n\n// ---------------------------------------------------------------------------\n// Points → dabs\n// ---------------------------------------------------------------------------\n\nexport interface Dab {\n x: number;\n y: number;\n radius: number;\n /** Flow (per-dab build-up). */\n alpha: number;\n /** Opacity ceiling this dab builds up to. */\n opacity: number;\n /** Radians. */\n angle: number;\n roundness: number;\n}\n\n/** Exponential smoothing of input points; the first and last point are kept. */\nexport function smoothPoints(points: readonly StrokePoint[], amount: number): StrokePoint[] {\n const a = 1 - Math.min(0.95, Math.max(0, amount));\n if (a >= 1 || points.length < 3) return points.slice();\n const out: StrokePoint[] = [];\n let cur: StrokePoint | null = null;\n for (const p of points) {\n const n: StrokePoint = cur ? { ...p, x: cur.x + (p.x - cur.x) * a, y: cur.y + (p.y - cur.y) * a } : p;\n out.push(n);\n cur = n;\n }\n out[out.length - 1] = points[points.length - 1];\n return out;\n}\n\nconst pressureOf = (p: StrokePoint) => (typeof p.pressure === 'number' && Number.isFinite(p.pressure) ? Math.min(1, Math.max(0, p.pressure)) : 1);\n\n/**\n * Walks points into dabs (incrementally: feed points in any chunks and get the same dabs). The\n * first point is a dab; then one every `spacing × diameter` along the path.\n */\nexport class DabWalker {\n private last: StrokePoint | null = null;\n private nextAt = 0;\n private pendingFirst: StrokePoint | null = null;\n\n constructor(readonly brush: BrushSettings) {}\n\n private diameter(p: StrokePoint): number {\n return this.brush.pressureSize ? this.brush.size * pressureOf(p) : this.brush.size;\n }\n\n private stepLen(p: StrokePoint): number {\n return Math.max(0.5, Math.max(1, this.diameter(p)) * Math.max(0.01, this.brush.spacing));\n }\n\n private dab(p: StrokePoint): Dab {\n const b = this.brush;\n return {\n x: p.x,\n y: p.y,\n radius: Math.max(0.5, this.diameter(p) / 2),\n alpha: Math.min(1, Math.max(0, b.flow)),\n opacity: b.pressureOpacity ? pressureOf(p) : 1,\n angle: (b.angle * Math.PI) / 180,\n roundness: Math.min(1, Math.max(0.01, b.roundness)),\n };\n }\n\n push(p: StrokePoint, out: Dab[]): void {\n const a = this.last;\n if (!a) {\n this.last = p;\n this.pendingFirst = p;\n this.nextAt = this.stepLen(p);\n return;\n }\n if (this.pendingFirst) {\n out.push(this.dab(this.pendingFirst));\n this.pendingFirst = null;\n }\n const dx = p.x - a.x;\n const dy = p.y - a.y;\n const len = Math.hypot(dx, dy);\n if (len > 1e-9) {\n while (this.nextAt <= len + 1e-9) {\n const f = Math.min(1, this.nextAt / len);\n const q: StrokePoint = {\n x: a.x + dx * f,\n y: a.y + dy * f,\n pressure: pressureOf(a) + (pressureOf(p) - pressureOf(a)) * f,\n };\n out.push(this.dab(q));\n this.nextAt += this.stepLen(q);\n }\n this.nextAt -= len;\n }\n this.last = p;\n }\n\n finish(out: Dab[]): void {\n if (this.pendingFirst) {\n out.push(this.dab(this.pendingFirst));\n this.pendingFirst = null;\n }\n }\n}\n\n/** All dabs of a point list (smoothing applied). */\nexport function walkDabs(points: readonly StrokePoint[], brush: BrushSettings): Dab[] {\n const w = new DabWalker(brush);\n const out: Dab[] = [];\n for (const p of smoothPoints(points, brush.smoothing)) w.push(p, out);\n w.finish(out);\n return out;\n}\n\n/** The pixel rectangle a dab can touch. */\nexport function dabRect(d: Dab, hardness: number): CropBox {\n // As `rasterizeDab`: the tip reaches `reach` across its minor axis and `reach / roundness` along it.\n const ro = Math.min(1, Math.max(0.5 / d.radius, d.roundness));\n const rm = Math.max(0.5, d.radius * ro);\n const r = Math.max(rm, tipReach(rm, hardness)) / ro + 1.5;\n const x0 = Math.floor(d.x - r);\n const y0 = Math.floor(d.y - r);\n return { x: x0, y: y0, width: Math.ceil(d.x + r) - x0, height: Math.ceil(d.y + r) - y0 };\n}\n\n/**\n * Rasterizes one dab over `rect` into `out` (rect.width × rect.height values, coverage × flow).\n * Small tips (radius below 3 px) take each pixel's covered area from a 4×4 grid.\n */\nexport function rasterizeDab(d: Dab, hardness: number, rect: CropBox, out: Float32Array): void {\n const w = rect.width;\n const h = rect.height;\n out.fill(0, 0, w * h);\n const r = d.radius;\n const ro = Math.min(1, Math.max(0.5 / r, d.roundness));\n const rm = Math.max(0.5, r * ro);\n const reach = Math.max(rm, tipReach(rm, hardness));\n const sn = Math.sin(d.angle);\n const cs = Math.cos(d.angle);\n const toTip = (dx: number, dy: number): [number, number] => {\n const ux = dx;\n const uy = -dy;\n return [ux * cs + uy * sn, -ux * sn + uy * cs];\n };\n const small = rm < SMALL_TIP_RADIUS;\n const reach2 = (reach + (small ? 0.75 : 0.5)) ** 2;\n for (let yy = 0; yy < h; yy++) {\n const dy = rect.y + yy + 0.5 - d.y;\n for (let xx = 0; xx < w; xx++) {\n const dx = rect.x + xx + 0.5 - d.x;\n const [u, v] = toTip(dx, dy);\n const d2 = (u * ro) ** 2 + v * v;\n if (d2 >= reach2) continue;\n let val: number;\n if (small) {\n let sum = 0;\n for (const sy of SUBPIXEL) {\n for (const sx of SUBPIXEL) {\n const [su, sv] = toTip(dx + sx, dy + sy);\n sum += tipFalloff(Math.sqrt((su * ro) ** 2 + sv * sv), rm, hardness);\n }\n }\n val = sum / 16;\n } else {\n val = dabCoverage(Math.sqrt(d2), rm, hardness);\n }\n if (val > 0) out[yy * w + xx] = val * d.alpha;\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Stroke coverage\n// ---------------------------------------------------------------------------\n\nconst TILE_PIXELS = TILE * TILE;\n\n/** A stroke's accumulated coverage, in 256 px tiles over document space. */\nexport class CoverageMap {\n readonly tiles = new Map<TileKey, Float32Array>();\n bounds: CropBox | null = null;\n private dirty = new Set<TileKey>();\n\n get(x: number, y: number): number {\n const tx = Math.floor(x / TILE);\n const ty = Math.floor(y / TILE);\n const t = this.tiles.get(tileKey(tx, ty));\n return t ? t[(y - ty * TILE) * TILE + (x - tx * TILE)] : 0;\n }\n\n /** Builds up `vals` (over `rect`) with flow towards `ceil`: `c ← c + v·(ceil − c)`. */\n accumulate(rect: CropBox, vals: Float32Array, ceil: number): void {\n if (rect.width <= 0 || rect.height <= 0) return;\n const w = rect.width;\n const tx0 = Math.floor(rect.x / TILE);\n const ty0 = Math.floor(rect.y / TILE);\n const tx1 = Math.floor((rect.x + rect.width - 1) / TILE);\n const ty1 = Math.floor((rect.y + rect.height - 1) / TILE);\n let touched = false;\n for (let ty = ty0; ty <= ty1; ty++) {\n for (let tx = tx0; tx <= tx1; tx++) {\n const x0 = Math.max(rect.x, tx * TILE);\n const y0 = Math.max(rect.y, ty * TILE);\n const x1 = Math.min(rect.x + rect.width, tx * TILE + TILE);\n const y1 = Math.min(rect.y + rect.height, ty * TILE + TILE);\n let tile: Float32Array | undefined;\n for (let y = y0; y < y1; y++) {\n const row = (y - rect.y) * w;\n const trow = (y - ty * TILE) * TILE;\n for (let x = x0; x < x1; x++) {\n const v = vals[row + (x - rect.x)];\n if (v <= 0) continue;\n if (!tile) {\n const key = tileKey(tx, ty);\n tile = this.tiles.get(key);\n if (!tile) {\n tile = new Float32Array(TILE_PIXELS);\n this.tiles.set(key, tile);\n }\n this.dirty.add(key);\n touched = true;\n }\n const ti = trow + (x - tx * TILE);\n const c = tile[ti];\n if (ceil > c) tile[ti] = c + v * (ceil - c);\n }\n }\n }\n }\n if (touched) this.bounds = unionRect(this.bounds, rect);\n }\n\n /** Tiles changed since the last call. */\n takeDirty(): TileKey[] {\n const out = [...this.dirty];\n this.dirty.clear();\n return out;\n }\n}\n\nfunction unionRect(a: CropBox | null, b: CropBox): CropBox {\n if (!a) return { ...b };\n const x = Math.min(a.x, b.x);\n const y = Math.min(a.y, b.y);\n return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };\n}\n\n/** Paints a stroke's dabs into a coverage map, incrementally. */\nexport class StrokeCoverage {\n readonly coverage = new CoverageMap();\n private walker: DabWalker;\n private smoothing: number;\n private smoothPos: StrokePoint | null = null;\n private buf = new Float32Array(0);\n dabCount = 0;\n\n constructor(readonly brush: BrushSettings) {\n this.walker = new DabWalker(brush);\n this.smoothing = brush.smoothing;\n }\n\n /** Feeds input points; returns the document rectangles the new dabs touched. */\n push(points: readonly StrokePoint[]): CropBox[] {\n const dabs: Dab[] = [];\n for (const p of points) this.walker.push(this.smooth(p), dabs);\n return this.paint(dabs);\n }\n\n /** Ends the stroke (a single click still paints one dab). */\n finish(last?: StrokePoint): CropBox[] {\n const dabs: Dab[] = [];\n if (last && this.smoothPos && (this.smoothPos.x !== last.x || this.smoothPos.y !== last.y)) this.walker.push(last, dabs);\n this.walker.finish(dabs);\n return this.paint(dabs);\n }\n\n private smooth(p: StrokePoint): StrokePoint {\n const a = 1 - Math.min(0.95, Math.max(0, this.smoothing));\n const cur = this.smoothPos;\n const n = cur && a < 1 ? { ...p, x: cur.x + (p.x - cur.x) * a, y: cur.y + (p.y - cur.y) * a } : p;\n this.smoothPos = n;\n return n;\n }\n\n private paint(dabs: Dab[]): CropBox[] {\n const rects: CropBox[] = [];\n for (const d of dabs) {\n const rect = dabRect(d, this.brush.hardness);\n const n = rect.width * rect.height;\n if (this.buf.length < n) this.buf = new Float32Array(n);\n const vals = this.buf.subarray(0, n);\n rasterizeDab(d, this.brush.hardness, rect, vals);\n this.coverage.accumulate(rect, vals, d.opacity);\n rects.push(rect);\n this.dabCount++;\n }\n return rects;\n }\n}\n\n/** How a stroke changes pixels. */\nexport interface StrokeApply {\n /** `paint` puts colour down; `erase` removes alpha (or, with transparency locked, paints `background`). */\n mode: 'paint' | 'erase';\n /** RGBA 0..255 (paint colour, or the mask grey in `r`). */\n color: readonly [number, number, number, number];\n /** RGBA 0..255 the eraser paints on a transparency-locked layer (and on masks). */\n background: readonly [number, number, number, number];\n opacity: number;\n blend: BlendMode;\n lockTransparency: boolean;\n /** Selection coverage (document space, canvas-sized), or `null`. */\n selection: { width: number; height: number; data: ArrayLike<number> } | null;\n /** Layer offset (target pixels are in layer space). */\n offset: { x: number; y: number };\n}\n\n/**\n * Composites the stroke's coverage over `tileData` (the target's tile (tx, ty) as it was before\n * the stroke, in layer space; RGBA or one byte for masks) and returns the new tile data. With\n * `into` (the tile's previous result) and `region` (document space), only `region` is recomputed\n * and the rest of `into` is kept.\n */\nexport function applyStrokeToTile(\n coverage: CoverageMap,\n tileData: Uint8ClampedArray,\n channels: 1 | 4,\n tx: number,\n ty: number,\n s: StrokeApply,\n options: { into?: Uint8ClampedArray; region?: CropBox } = {}\n): Uint8ClampedArray {\n const out = options.into ? new Uint8ClampedArray(options.into) : new Uint8ClampedArray(tileData);\n const ox = tx * TILE + s.offset.x;\n const oy = ty * TILE + s.offset.y;\n let x0 = 0;\n let y0 = 0;\n let x1 = TILE;\n let y1 = TILE;\n if (options.region) {\n const r = options.region;\n x0 = Math.max(0, Math.floor(r.x) - ox);\n y0 = Math.max(0, Math.floor(r.y) - oy);\n x1 = Math.min(TILE, Math.ceil(r.x + r.width) - ox);\n y1 = Math.min(TILE, Math.ceil(r.y + r.height) - oy);\n if (x1 <= x0 || y1 <= y0) return out;\n // Start the region from the pre-stroke pixels: coverage is cumulative.\n if (options.into) {\n for (let y = y0; y < y1; y++) out.set(tileData.subarray((y * TILE + x0) * channels, (y * TILE + x1) * channels), (y * TILE + x0) * channels);\n }\n }\n const sel = s.selection;\n const cb = [0, 0, 0, 0];\n const cs = [s.color[0] / 255, s.color[1] / 255, s.color[2] / 255, s.color[3] / 255];\n const bg = [s.background[0] / 255, s.background[1] / 255, s.background[2] / 255, s.background[3] / 255];\n // With a tile-aligned offset the layer tile is one coverage tile: read it directly.\n const aligned = s.offset.x % TILE === 0 && s.offset.y % TILE === 0;\n const covTile = aligned ? coverage.tiles.get(tileKey(Math.floor(ox / TILE), Math.floor(oy / TILE))) : undefined;\n if (aligned && !covTile) return out;\n for (let y = y0; y < y1; y++) {\n const dy = oy + y;\n for (let x = x0; x < x1; x++) {\n const dx = ox + x;\n const c = covTile ? covTile[y * TILE + x] : coverage.get(dx, dy);\n if (c <= 0) continue;\n let k = c * s.opacity;\n if (sel) {\n if (dx < 0 || dy < 0 || dx >= sel.width || dy >= sel.height) continue;\n k *= sel.data[dy * sel.width + dx] / 255;\n }\n if (k > 1) k = 1;\n if (k <= 0) continue;\n const p = y * TILE + x;\n if (channels === 1) {\n const target = s.mode === 'erase' ? s.background[0] : s.color[0];\n out[p] = Math.round(out[p] + (target - out[p]) * k);\n continue;\n }\n const i = p * 4;\n if (s.mode === 'erase' && !s.lockTransparency) {\n out[i + 3] = Math.round(out[i + 3] * (1 - k));\n continue;\n }\n if (s.lockTransparency && out[i + 3] === 0) continue;\n const src = s.mode === 'erase' ? bg : cs;\n for (let ch = 0; ch < 4; ch++) cb[ch] = out[i + ch] / 255;\n const o = blendPixel(s.blend, cb, src, k);\n out[i] = Math.round(o[0] * 255);\n out[i + 1] = Math.round(o[1] * 255);\n out[i + 2] = Math.round(o[2] * 255);\n if (!s.lockTransparency) out[i + 3] = Math.round(o[3] * 255);\n }\n }\n return out;\n}\n\n/** Tile coordinates of coverage tile keys (for callers that track dirty tiles). */\nexport function coverageTileCoord(key: TileKey): { tx: number; ty: number } {\n return tileCoord(key);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/paint/brush.ts"],"sourcesContent":["// Portions ported from photocraft/crates/paint/src/lib.rs, dynamics.rs and render.rs (MIT OR Apache-2.0, © ArtCraft Team and contributors). See THIRD_PARTY_NOTICES.md.\n\n/**\n * The brush engine (a subset of photocraft's `crates/paint`): a computed round tip with size,\n * hardness, angle, roundness and spacing; pressure to size and opacity; smoothing; and Photoshop's\n * opacity-versus-flow build-up. Strokes are data, so one replays the same way for undo, agents\n * and tests.\n *\n * - Points are walked into dabs at `spacing × diameter` (`walkDabs`).\n * - Each dab's coverage (`dabCoverage`, photocraft's measured Photoshop profile) builds up in a\n * stroke coverage map with flow towards the dab's opacity ceiling: `c ← c + v·(ceil − c)`.\n * - The stroke composites once at the stroke opacity over the layer as it was before the stroke,\n * so overlapping dabs never exceed the opacity.\n */\n\nimport { blendPixel, type BlendMode } from '../raster/blend';\nimport type { RasterRect as CropBox } from '../raster/surface';\nimport { TILE, tileKey, tileCoord, type TileKey } from '../raster/surface';\n\n/** One input sample. Missing pressure is a mouse (1). */\nexport interface StrokePoint {\n x: number;\n y: number;\n /** 0..1 (default 1). */\n pressure?: number;\n /** Milliseconds (optional; kept for replays). */\n t?: number;\n}\n\nexport interface BrushSettings {\n /** Diameter in pixels (1..2500, default 20). */\n size: number;\n /** 0 (soft) .. 1 (hard, default). */\n hardness: number;\n /** Dab spacing as a fraction of the diameter (0.01..10, default 0.1). */\n spacing: number;\n /** Tip angle in degrees (default 0). */\n angle: number;\n /** Tip roundness 0.01..1 (default 1). */\n roundness: number;\n /** Stroke opacity ceiling 0..1 (default 1). */\n opacity: number;\n /** Build-up per dab 0..1 (default 1). */\n flow: number;\n /** Input smoothing 0..0.95 (default 0). */\n smoothing: number;\n /** Pressure controls size (default true). */\n pressureSize: boolean;\n /** Pressure controls opacity (default false). */\n pressureOpacity: boolean;\n /** How the stroke paints onto the layer (default normal). */\n blend: BlendMode;\n}\n\nexport const DEFAULT_BRUSH: Readonly<BrushSettings> = {\n size: 20,\n hardness: 1,\n spacing: 0.1,\n angle: 0,\n roundness: 1,\n opacity: 1,\n flow: 1,\n smoothing: 0,\n pressureSize: true,\n pressureOpacity: false,\n blend: 'normal',\n};\n\nexport const MAX_BRUSH_SIZE = 2500;\n\n/** A brush with every field in range (missing fields from `DEFAULT_BRUSH`). */\nexport function normalizeBrush(raw: Partial<BrushSettings> = {}): BrushSettings {\n const num = (v: unknown, lo: number, hi: number, d: number) => (typeof v === 'number' && Number.isFinite(v) ? Math.min(hi, Math.max(lo, v)) : d);\n return {\n size: num(raw.size, 1, MAX_BRUSH_SIZE, DEFAULT_BRUSH.size),\n hardness: num(raw.hardness, 0, 1, DEFAULT_BRUSH.hardness),\n spacing: num(raw.spacing, 0.01, 10, DEFAULT_BRUSH.spacing),\n angle: num(raw.angle, -360, 360, DEFAULT_BRUSH.angle),\n roundness: num(raw.roundness, 0.01, 1, DEFAULT_BRUSH.roundness),\n opacity: num(raw.opacity, 0, 1, DEFAULT_BRUSH.opacity),\n flow: num(raw.flow, 0, 1, DEFAULT_BRUSH.flow),\n smoothing: num(raw.smoothing, 0, 0.95, DEFAULT_BRUSH.smoothing),\n pressureSize: typeof raw.pressureSize === 'boolean' ? raw.pressureSize : DEFAULT_BRUSH.pressureSize,\n pressureOpacity: typeof raw.pressureOpacity === 'boolean' ? raw.pressureOpacity : DEFAULT_BRUSH.pressureOpacity,\n blend: raw.blend ?? 'normal',\n };\n}\n\n// ---------------------------------------------------------------------------\n// The round tip (photocraft's measured Photoshop profile)\n// ---------------------------------------------------------------------------\n\n/**\n * Photoshop's round tip, measured by photocraft: a solid core of radius `r0 · R`, then a Gaussian\n * shoulder `exp(-((d − r0) / s)²)` of width `s · R`, both by hardness (0, 0.1, … 1).\n */\nconst TIP_SHAPE: ReadonlyArray<[number, number]> = [\n [0.0, 0.664], [0.14, 0.58], [0.28, 0.5], [0.4, 0.44], [0.52, 0.36], [0.63, 0.29],\n [0.7, 0.24], [0.78, 0.19], [0.84, 0.15], [0.89, 0.11], [1.0, 0.0],\n];\n/** The anti-aliased edge: the shoulder never narrows below this many pixels. */\nconst TIP_EDGE_PX = 1.2;\nconst SMALL_TIP_RADIUS = 3;\nconst SUBPIXEL = [-0.375, -0.125, 0.125, 0.375];\n\n/** The core radius and shoulder width (pixels) of a round tip of `radius` and `hardness`. */\nexport function tipShape(radius: number, hardness: number): [number, number] {\n const h = (Number.isNaN(hardness) ? 0 : Math.min(1, Math.max(0, hardness))) * 10;\n const i = Math.min(9, Math.floor(h));\n const t = h - i;\n const a = TIP_SHAPE[i];\n const b = TIP_SHAPE[i + 1];\n const r0 = a[0] + (b[0] - a[0]) * t;\n const s = a[1] + (b[1] - a[1]) * t;\n const r = Number.isFinite(radius) ? Math.max(0, radius) : 0;\n const edge = Math.max(0.25, Math.min(TIP_EDGE_PX, 0.3 * r));\n return [Math.max(0, Math.min(r0 * r, r - edge)), Math.max(1e-3, s * r, edge)];\n}\n\n/** `exp(-u)` as `(1 − u/64)^64` by six squarings: exactly 0 from u = 64. */\nfunction softExp(u: number): number {\n let g = Math.min(1, Math.max(0, 1 - u / 64));\n for (let k = 0; k < 6; k++) g *= g;\n return g;\n}\n\n/** Opacity of a round tip at distance `d` from its centre. */\nexport function tipFalloff(d: number, radius: number, hardness: number): number {\n const [r0, s] = tipShape(radius, hardness);\n if (d <= r0) return 1;\n const x = (d - r0) / s;\n return softExp(x * x);\n}\n\n/** How far from its centre a round tip still paints. */\nexport function tipReach(radius: number, hardness: number): number {\n const [r0, s] = tipShape(radius, hardness);\n return r0 + 2.6 * s;\n}\n\n/** Coverage of a round dab at distance `d` from its centre. */\nexport function dabCoverage(d: number, radius: number, hardness: number): number {\n if (Number.isNaN(d) || d >= tipReach(radius, hardness) + 0.5) return 0;\n return tipFalloff(d, radius, hardness);\n}\n\n// ---------------------------------------------------------------------------\n// Points → dabs\n// ---------------------------------------------------------------------------\n\nexport interface Dab {\n x: number;\n y: number;\n radius: number;\n /** Flow (per-dab build-up). */\n alpha: number;\n /** Opacity ceiling this dab builds up to. */\n opacity: number;\n /** Radians. */\n angle: number;\n roundness: number;\n}\n\n/** Exponential smoothing of input points; the first and last point are kept. */\nexport function smoothPoints(points: readonly StrokePoint[], amount: number): StrokePoint[] {\n const a = 1 - Math.min(0.95, Math.max(0, amount));\n if (a >= 1 || points.length < 3) return points.slice();\n const out: StrokePoint[] = [];\n let cur: StrokePoint | null = null;\n for (const p of points) {\n const n: StrokePoint = cur ? { ...p, x: cur.x + (p.x - cur.x) * a, y: cur.y + (p.y - cur.y) * a } : p;\n out.push(n);\n cur = n;\n }\n out[out.length - 1] = points[points.length - 1];\n return out;\n}\n\nconst pressureOf = (p: StrokePoint) => (typeof p.pressure === 'number' && Number.isFinite(p.pressure) ? Math.min(1, Math.max(0, p.pressure)) : 1);\n\n/**\n * Walks points into dabs (incrementally: feed points in any chunks and get the same dabs). The\n * first point is a dab; then one every `spacing × diameter` along the path.\n */\nexport class DabWalker {\n private last: StrokePoint | null = null;\n private nextAt = 0;\n private pendingFirst: StrokePoint | null = null;\n\n constructor(readonly brush: BrushSettings) {}\n\n private diameter(p: StrokePoint): number {\n return this.brush.pressureSize ? this.brush.size * pressureOf(p) : this.brush.size;\n }\n\n private stepLen(p: StrokePoint): number {\n return Math.max(0.5, Math.max(1, this.diameter(p)) * Math.max(0.01, this.brush.spacing));\n }\n\n private dab(p: StrokePoint): Dab {\n const b = this.brush;\n return {\n x: p.x,\n y: p.y,\n radius: Math.max(0.5, this.diameter(p) / 2),\n alpha: Math.min(1, Math.max(0, b.flow)),\n opacity: b.pressureOpacity ? pressureOf(p) : 1,\n angle: (b.angle * Math.PI) / 180,\n roundness: Math.min(1, Math.max(0.01, b.roundness)),\n };\n }\n\n push(p: StrokePoint, out: Dab[]): void {\n const a = this.last;\n if (!a) {\n this.last = p;\n this.pendingFirst = p;\n this.nextAt = this.stepLen(p);\n return;\n }\n if (this.pendingFirst) {\n out.push(this.dab(this.pendingFirst));\n this.pendingFirst = null;\n }\n const dx = p.x - a.x;\n const dy = p.y - a.y;\n const len = Math.hypot(dx, dy);\n if (len > 1e-9) {\n while (this.nextAt <= len + 1e-9) {\n const f = Math.min(1, this.nextAt / len);\n const q: StrokePoint = {\n x: a.x + dx * f,\n y: a.y + dy * f,\n pressure: pressureOf(a) + (pressureOf(p) - pressureOf(a)) * f,\n };\n out.push(this.dab(q));\n this.nextAt += this.stepLen(q);\n }\n this.nextAt -= len;\n }\n this.last = p;\n }\n\n finish(out: Dab[]): void {\n if (this.pendingFirst) {\n out.push(this.dab(this.pendingFirst));\n this.pendingFirst = null;\n }\n }\n}\n\n/** All dabs of a point list (smoothing applied). */\nexport function walkDabs(points: readonly StrokePoint[], brush: BrushSettings): Dab[] {\n const w = new DabWalker(brush);\n const out: Dab[] = [];\n for (const p of smoothPoints(points, brush.smoothing)) w.push(p, out);\n w.finish(out);\n return out;\n}\n\n/** The pixel rectangle a dab can touch. */\nexport function dabRect(d: Dab, hardness: number): CropBox {\n // As `rasterizeDab`: the tip reaches `reach` across its minor axis and `reach / roundness` along it.\n const ro = Math.min(1, Math.max(0.5 / d.radius, d.roundness));\n const rm = Math.max(0.5, d.radius * ro);\n const r = Math.max(rm, tipReach(rm, hardness)) / ro + 1.5;\n const x0 = Math.floor(d.x - r);\n const y0 = Math.floor(d.y - r);\n return { x: x0, y: y0, width: Math.ceil(d.x + r) - x0, height: Math.ceil(d.y + r) - y0 };\n}\n\n/**\n * Rasterizes one dab over `rect` into `out` (rect.width × rect.height values, coverage × flow).\n * Small tips (radius below 3 px) take each pixel's covered area from a 4×4 grid.\n */\nexport function rasterizeDab(d: Dab, hardness: number, rect: CropBox, out: Float32Array): void {\n const w = rect.width;\n const h = rect.height;\n out.fill(0, 0, w * h);\n const r = d.radius;\n const ro = Math.min(1, Math.max(0.5 / r, d.roundness));\n const rm = Math.max(0.5, r * ro);\n const reach = Math.max(rm, tipReach(rm, hardness));\n const sn = Math.sin(d.angle);\n const cs = Math.cos(d.angle);\n const toTip = (dx: number, dy: number): [number, number] => {\n const ux = dx;\n const uy = -dy;\n return [ux * cs + uy * sn, -ux * sn + uy * cs];\n };\n const small = rm < SMALL_TIP_RADIUS;\n const reach2 = (reach + (small ? 0.75 : 0.5)) ** 2;\n for (let yy = 0; yy < h; yy++) {\n const dy = rect.y + yy + 0.5 - d.y;\n for (let xx = 0; xx < w; xx++) {\n const dx = rect.x + xx + 0.5 - d.x;\n const [u, v] = toTip(dx, dy);\n const d2 = (u * ro) ** 2 + v * v;\n if (d2 >= reach2) continue;\n let val: number;\n if (small) {\n let sum = 0;\n for (const sy of SUBPIXEL) {\n for (const sx of SUBPIXEL) {\n const [su, sv] = toTip(dx + sx, dy + sy);\n sum += tipFalloff(Math.sqrt((su * ro) ** 2 + sv * sv), rm, hardness);\n }\n }\n val = sum / 16;\n } else {\n val = dabCoverage(Math.sqrt(d2), rm, hardness);\n }\n if (val > 0) out[yy * w + xx] = val * d.alpha;\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// Stroke coverage\n// ---------------------------------------------------------------------------\n\nconst TILE_PIXELS = TILE * TILE;\n\n/** A stroke's accumulated coverage, in 256 px tiles over document space. */\nexport class CoverageMap {\n readonly tiles = new Map<TileKey, Float32Array>();\n bounds: CropBox | null = null;\n private dirty = new Set<TileKey>();\n\n get(x: number, y: number): number {\n const tx = Math.floor(x / TILE);\n const ty = Math.floor(y / TILE);\n const t = this.tiles.get(tileKey(tx, ty));\n return t ? t[(y - ty * TILE) * TILE + (x - tx * TILE)] : 0;\n }\n\n /** Builds up `vals` (over `rect`) with flow towards `ceil`: `c ← c + v·(ceil − c)`. */\n accumulate(rect: CropBox, vals: Float32Array, ceil: number): void {\n if (rect.width <= 0 || rect.height <= 0) return;\n const w = rect.width;\n const tx0 = Math.floor(rect.x / TILE);\n const ty0 = Math.floor(rect.y / TILE);\n const tx1 = Math.floor((rect.x + rect.width - 1) / TILE);\n const ty1 = Math.floor((rect.y + rect.height - 1) / TILE);\n let touched = false;\n for (let ty = ty0; ty <= ty1; ty++) {\n for (let tx = tx0; tx <= tx1; tx++) {\n const x0 = Math.max(rect.x, tx * TILE);\n const y0 = Math.max(rect.y, ty * TILE);\n const x1 = Math.min(rect.x + rect.width, tx * TILE + TILE);\n const y1 = Math.min(rect.y + rect.height, ty * TILE + TILE);\n let tile: Float32Array | undefined;\n for (let y = y0; y < y1; y++) {\n const row = (y - rect.y) * w;\n const trow = (y - ty * TILE) * TILE;\n for (let x = x0; x < x1; x++) {\n const v = vals[row + (x - rect.x)];\n if (v <= 0) continue;\n if (!tile) {\n const key = tileKey(tx, ty);\n tile = this.tiles.get(key);\n if (!tile) {\n tile = new Float32Array(TILE_PIXELS);\n this.tiles.set(key, tile);\n }\n this.dirty.add(key);\n touched = true;\n }\n const ti = trow + (x - tx * TILE);\n const c = tile[ti];\n if (ceil > c) tile[ti] = c + v * (ceil - c);\n }\n }\n }\n }\n if (touched) this.bounds = unionRect(this.bounds, rect);\n }\n\n /** Tiles changed since the last call. */\n takeDirty(): TileKey[] {\n const out = [...this.dirty];\n this.dirty.clear();\n return out;\n }\n}\n\nfunction unionRect(a: CropBox | null, b: CropBox): CropBox {\n if (!a) return { ...b };\n const x = Math.min(a.x, b.x);\n const y = Math.min(a.y, b.y);\n return { x, y, width: Math.max(a.x + a.width, b.x + b.width) - x, height: Math.max(a.y + a.height, b.y + b.height) - y };\n}\n\n/** Paints a stroke's dabs into a coverage map, incrementally. */\nexport class StrokeCoverage {\n readonly coverage = new CoverageMap();\n private walker: DabWalker;\n private smoothing: number;\n private smoothPos: StrokePoint | null = null;\n private buf = new Float32Array(0);\n dabCount = 0;\n\n constructor(readonly brush: BrushSettings) {\n this.walker = new DabWalker(brush);\n this.smoothing = brush.smoothing;\n }\n\n /** Feeds input points; returns the document rectangles the new dabs touched. */\n push(points: readonly StrokePoint[]): CropBox[] {\n const dabs: Dab[] = [];\n for (const p of points) this.walker.push(this.smooth(p), dabs);\n return this.paint(dabs);\n }\n\n /** Ends the stroke (a single click still paints one dab). */\n finish(last?: StrokePoint): CropBox[] {\n const dabs: Dab[] = [];\n if (last && this.smoothPos && (this.smoothPos.x !== last.x || this.smoothPos.y !== last.y)) this.walker.push(last, dabs);\n this.walker.finish(dabs);\n return this.paint(dabs);\n }\n\n private smooth(p: StrokePoint): StrokePoint {\n const a = 1 - Math.min(0.95, Math.max(0, this.smoothing));\n const cur = this.smoothPos;\n const n = cur && a < 1 ? { ...p, x: cur.x + (p.x - cur.x) * a, y: cur.y + (p.y - cur.y) * a } : p;\n this.smoothPos = n;\n return n;\n }\n\n private paint(dabs: Dab[]): CropBox[] {\n const rects: CropBox[] = [];\n for (const d of dabs) {\n const rect = dabRect(d, this.brush.hardness);\n const n = rect.width * rect.height;\n if (this.buf.length < n) this.buf = new Float32Array(n);\n const vals = this.buf.subarray(0, n);\n rasterizeDab(d, this.brush.hardness, rect, vals);\n this.coverage.accumulate(rect, vals, d.opacity);\n rects.push(rect);\n this.dabCount++;\n }\n return rects;\n }\n}\n\n/** How a stroke changes pixels. */\nexport interface StrokeApply {\n /** `paint` puts colour down; `erase` removes alpha (or, with transparency locked, paints `background`). */\n mode: 'paint' | 'erase';\n /** RGBA 0..255 (paint colour, or the mask grey in `r`). */\n color: readonly [number, number, number, number];\n /** RGBA 0..255 the eraser paints on a transparency-locked layer (and on masks). */\n background: readonly [number, number, number, number];\n opacity: number;\n blend: BlendMode;\n lockTransparency: boolean;\n /** Selection coverage (document space, canvas-sized), or `null`. */\n selection: { width: number; height: number; data: ArrayLike<number> } | null;\n /** Layer offset (target pixels are in layer space). */\n offset: { x: number; y: number };\n}\n\n/**\n * Composites the stroke's coverage over `tileData` (the target's tile (tx, ty) as it was before\n * the stroke, in layer space; RGBA or one byte for masks) and returns the new tile data. With\n * `into` (the tile's previous result) and `region` (document space), only `region` is recomputed\n * and the rest of `into` is kept.\n */\nexport function applyStrokeToTile(\n coverage: CoverageMap,\n tileData: Uint8ClampedArray,\n channels: 1 | 4,\n tx: number,\n ty: number,\n s: StrokeApply,\n options: { into?: Uint8ClampedArray; region?: CropBox } = {}\n): Uint8ClampedArray {\n const out = options.into ? new Uint8ClampedArray(options.into) : new Uint8ClampedArray(tileData);\n const ox = tx * TILE + s.offset.x;\n const oy = ty * TILE + s.offset.y;\n let x0 = 0;\n let y0 = 0;\n let x1 = TILE;\n let y1 = TILE;\n if (options.region) {\n const r = options.region;\n x0 = Math.max(0, Math.floor(r.x) - ox);\n y0 = Math.max(0, Math.floor(r.y) - oy);\n x1 = Math.min(TILE, Math.ceil(r.x + r.width) - ox);\n y1 = Math.min(TILE, Math.ceil(r.y + r.height) - oy);\n if (x1 <= x0 || y1 <= y0) return out;\n // Start the region from the pre-stroke pixels: coverage is cumulative.\n if (options.into) {\n for (let y = y0; y < y1; y++) out.set(tileData.subarray((y * TILE + x0) * channels, (y * TILE + x1) * channels), (y * TILE + x0) * channels);\n }\n }\n const sel = s.selection;\n const cb = [0, 0, 0, 0];\n const cs = [s.color[0] / 255, s.color[1] / 255, s.color[2] / 255, s.color[3] / 255];\n const bg = [s.background[0] / 255, s.background[1] / 255, s.background[2] / 255, s.background[3] / 255];\n // With a tile-aligned offset the layer tile is one coverage tile: read it directly.\n const aligned = s.offset.x % TILE === 0 && s.offset.y % TILE === 0;\n const covTile = aligned ? coverage.tiles.get(tileKey(Math.floor(ox / TILE), Math.floor(oy / TILE))) : undefined;\n if (aligned && !covTile) return out;\n for (let y = y0; y < y1; y++) {\n const dy = oy + y;\n for (let x = x0; x < x1; x++) {\n const dx = ox + x;\n const c = covTile ? covTile[y * TILE + x] : coverage.get(dx, dy);\n if (c <= 0) continue;\n let k = c * s.opacity;\n if (sel) {\n if (dx < 0 || dy < 0 || dx >= sel.width || dy >= sel.height) continue;\n k *= sel.data[dy * sel.width + dx] / 255;\n }\n if (k > 1) k = 1;\n if (k <= 0) continue;\n const p = y * TILE + x;\n if (channels === 1) {\n const target = s.mode === 'erase' ? s.background[0] : s.color[0];\n out[p] = Math.round(out[p] + (target - out[p]) * k);\n continue;\n }\n const i = p * 4;\n if (s.mode === 'erase' && !s.lockTransparency) {\n out[i + 3] = Math.round(out[i + 3] * (1 - k));\n continue;\n }\n if (s.lockTransparency && out[i + 3] === 0) continue;\n const src = s.mode === 'erase' ? bg : cs;\n for (let ch = 0; ch < 4; ch++) cb[ch] = out[i + ch] / 255;\n const o = blendPixel(s.blend, cb, src, k);\n out[i] = Math.round(o[0] * 255);\n out[i + 1] = Math.round(o[1] * 255);\n out[i + 2] = Math.round(o[2] * 255);\n if (!s.lockTransparency) out[i + 3] = Math.round(o[3] * 255);\n }\n }\n return out;\n}\n\n/** Tile coordinates of coverage tile keys (for callers that track dirty tiles). */\nexport function coverageTileCoord(key: TileKey): { tx: number; ty: number } {\n return tileCoord(key);\n}\n"],"mappings":";;;;;;;;AAsDO,IAAM,gBAAyC;AAAA,EACpD,MAAM;AAAA,EACN,UAAU;AAAA,EACV,SAAS;AAAA,EACT,OAAO;AAAA,EACP,WAAW;AAAA,EACX,SAAS;AAAA,EACT,MAAM;AAAA,EACN,WAAW;AAAA,EACX,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,OAAO;AACT;AAEO,IAAM,iBAAiB;AAGvB,SAAS,eAAe,MAA8B,CAAC,GAAkB;AAC9E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