@pixerate/editor 0.93.0 → 0.94.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/THIRD_PARTY_NOTICES.md +2 -0
- package/dist/chunk-73L6TROJ.cjs +3685 -0
- package/dist/chunk-73L6TROJ.cjs.map +1 -0
- package/dist/chunk-747CGOT2.js +3685 -0
- package/dist/chunk-747CGOT2.js.map +1 -0
- package/dist/image-editor/index.cjs +752 -292
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +83 -17
- package/dist/image-editor/index.d.ts +83 -17
- package/dist/image-editor/index.js +534 -74
- package/dist/image-editor/index.js.map +1 -1
- package/dist/paint/index.d.cts +1 -1
- package/dist/paint/index.d.ts +1 -1
- package/dist/raster/index.cjs +78 -2
- package/dist/raster/index.cjs.map +1 -1
- package/dist/raster/index.d.cts +99 -348
- package/dist/raster/index.d.ts +99 -348
- package/dist/raster/index.js +78 -2
- package/dist/{surface-fJhkmNQn.d.cts → surface-CuBg2c6k.d.cts} +1 -1
- package/dist/{surface-fJhkmNQn.d.ts → surface-CuBg2c6k.d.ts} +1 -1
- package/dist/zlib-BJ6U7LuB.d.cts +795 -0
- package/dist/zlib-BjQkpMFi.d.ts +795 -0
- package/package.json +1 -1
- package/skills/pixerate-image-editor/SKILL.md +57 -6
- package/dist/chunk-H543GD6T.cjs +0 -1696
- package/dist/chunk-H543GD6T.cjs.map +0 -1
- package/dist/chunk-P5TPUNBZ.js +0 -1696
- package/dist/chunk-P5TPUNBZ.js.map +0 -1
package/dist/raster/index.d.ts
CHANGED
|
@@ -1,365 +1,116 @@
|
|
|
1
|
-
import { B as BlendMode
|
|
2
|
-
export { a as BLEND_MODES, b as BlendModeInfo, c as Rgb, d as Rgba, S as SurfaceDraft,
|
|
1
|
+
import { B as BlendMode } from '../surface-CuBg2c6k.js';
|
|
2
|
+
export { a as BLEND_MODES, b as BlendModeInfo, M as MaskSurface, P as PixelSurface, R as RasterRect, c as Rgb, d as Rgba, S as SurfaceDraft, T as TILE, e as TILE_SHIFT, f as Tile, g as TileKey, h as TiledSurface, i as blendChannel, j as blendImageData, k as blendLum, l as blendPixel, m as blendRgb, n as canvasCompositeOperation, o as collectTiles, p as contentBounds, q as emptySurface, r as fillRect, s as finishTile, t as isBlendMode, u as isSeparableBlendMode, v as normalizeBlendMode, w as packRgba, x as readPixel, y as readRegion, z as setLum, A as solidSurface, C as surfaceBytes, D as surfaceFromPixels, E as surfacesEqual, F as tileCoord, G as tileKey, H as tileRect, I as tilesInRect, J as translateSurface, K as uniformTile, L as writeRegion } from '../surface-CuBg2c6k.js';
|
|
3
|
+
import { L as LayerEffect, G as GlobalLight, P as PatternTile, a as LayerEffects, E as EffectContour, b as GradientStyle } from '../zlib-BjQkpMFi.js';
|
|
4
|
+
export { B as BevelContour, c as BevelEmbossEffect, d as BevelStyle, e as BevelTechnique, f as BevelTexture, g as BlurEdge, C as CURVE_LUT_SIZE, h as ColorOverlayEffect, i as CompositeCallOptions, j as CompositeStats, k as CompositorLayer, l as CompositorOptions, m as CompositorProfile, n as ContourPoint, D as DEFAULT_GLOBAL_LIGHT, o as DIRECT_GAUSSIAN_MAX_SIGMA, p as DecodedPng, q as DropShadowEffect, r as EffectFill, s as EffectGradient, t as EffectPattern, u as EffectPatternRef, v as GlowTechnique, w as GradientColorStop, x as GradientOpacityStop, y as GradientOverlayEffect, z as GroupBlendMode, A as GroupIn, I as InnerGlowEffect, F as InnerShadowEffect, H as LAYER_EFFECT_KINDS, J as LayerEffectError, K as LayerEffectKind, M as LayerLocation, N as LayerLocks, O as MAX_EFFECT_REACH, Q as OuterGlowEffect, R as PatternOverlayEffect, S as PatternPlacement, T as PixelFilterSpec, U as RasterCompositor, V as RasterGroupLayer, W as RasterLayer, X as RasterLayerBase, Y as RasterMask, Z as RasterNode, _ as RasterPixelLayer, $ as RasterSources, a0 as SatinEffect, a1 as StrokeEffect, a2 as StrokePosition, a3 as ZlibError, a4 as adler32, a5 as base64ToBytes, a6 as blendTile, a7 as builtinPattern, a8 as builtinPatternIds, a9 as bytesToBase64, aa as changedTiles, ab as curveLut, ac as decodePng, ad as defaultEffectGradient, ae as defaultLayerEffect, af as deflate, ag as deflateRaw, ah as effectColorHex, ai as effectReach, aj as effectsFingerprint, ak as effectsMargin, al as effectsScale, am as encodePng, an as findLayer, ao as flattenLayers, ap as gaussianBlur, aq as hasActiveEffects, ar as hashNoise, as as inflate, at as inflateRaw, au as insertLayer, av as isLayerEffectKind, aw as isLayerLocked, ax as isPng, ay as layerEffectFields, az as layerEffectLabel, aA as mapLayer, aB as mergeLayerEffect, aC as newEffectId, aD as normalizeLayerEffects, aE as parseDataUrl, aF as parseEffectColor, aG as pngDataUrl, aH as scaleLayerEffect, aI as validateEffectGradient, aJ as validateLayerEffect, aK as validateLayerEffects } from '../zlib-BjQkpMFi.js';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
*
|
|
6
|
-
* pass-through), raster masks with density and feather, clipping, locks, opacity, fill and blend
|
|
7
|
-
* modes, plus pure tree helpers. Editors extend these types with their own layer kinds (the image
|
|
8
|
-
* editor adds adjustment and annotation layers, filters and parametric masks).
|
|
7
|
+
* CPU renderer for layer effects.
|
|
9
8
|
*
|
|
10
|
-
*
|
|
11
|
-
* the
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
/** Painting keeps each pixel's alpha. */
|
|
20
|
-
transparency?: boolean;
|
|
21
|
-
/** Moving (offset) is refused. */
|
|
22
|
-
position?: boolean;
|
|
23
|
-
/** Everything above, plus property changes and deletion. */
|
|
24
|
-
all?: boolean;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* A layer mask: 8-bit coverage (255 reveals, 0 hides) on a tiled surface, plus non-destructive
|
|
28
|
-
* density and feather. `source` is an editor-defined parametric mask (generated instead of
|
|
29
|
-
* painted; the compositor asks its profile for the coverage, and the surface is unused).
|
|
30
|
-
*/
|
|
31
|
-
interface RasterMask<Source = unknown> {
|
|
32
|
-
surface: MaskSurface;
|
|
33
|
-
/** Value outside the painted tiles (PSD's default colour); equals `surface.defaultValue`. */
|
|
34
|
-
defaultValue: 0 | 255;
|
|
35
|
-
/** 0..1 (missing = 1): at 0.5 hidden areas still show half. */
|
|
36
|
-
density?: number;
|
|
37
|
-
/** Gaussian σ in pixels (missing = 0). */
|
|
38
|
-
feather?: number;
|
|
39
|
-
/** `false` keeps the mask but ignores it. */
|
|
40
|
-
enabled?: boolean;
|
|
41
|
-
source?: Source;
|
|
42
|
-
}
|
|
43
|
-
interface RasterLayerBase {
|
|
44
|
-
id: string;
|
|
45
|
-
name: string;
|
|
46
|
-
visible: boolean;
|
|
47
|
-
/** 0..1 */
|
|
48
|
-
opacity: number;
|
|
49
|
-
blend: BlendMode;
|
|
50
|
-
/** Clip to the nearest unclipped layer below (Photoshop's clipping mask). */
|
|
51
|
-
clipped?: boolean;
|
|
52
|
-
mask?: RasterMask;
|
|
53
|
-
locks?: LayerLocks;
|
|
54
|
-
}
|
|
55
|
-
interface RasterPixelLayer extends RasterLayerBase {
|
|
56
|
-
type: 'pixel';
|
|
57
|
-
/** Pixels in layer space; document position = layer position + `offset`. A mask moves with it. */
|
|
58
|
-
surface: PixelSurface;
|
|
59
|
-
/** Integer move without re-tiling. */
|
|
60
|
-
offset: {
|
|
61
|
-
x: number;
|
|
62
|
-
y: number;
|
|
63
|
-
};
|
|
64
|
-
/** 0..1, PSD "Fill" (missing = 1). */
|
|
65
|
-
fillOpacity?: number;
|
|
66
|
-
}
|
|
67
|
-
interface RasterGroupLayer<L = RasterLayer> extends Omit<RasterLayerBase, 'blend'> {
|
|
68
|
-
type: 'group';
|
|
69
|
-
blend: GroupBlendMode;
|
|
70
|
-
/** Bottom to top. */
|
|
71
|
-
children: L[];
|
|
72
|
-
/** UI only. */
|
|
73
|
-
collapsed?: boolean;
|
|
74
|
-
}
|
|
75
|
-
/** The plain stack: pixel layers and groups. */
|
|
76
|
-
type RasterLayer = RasterPixelLayer | RasterGroupLayer<RasterLayer>;
|
|
77
|
-
/** What the tree helpers need of a layer: an id, a type, and `children` on groups. */
|
|
78
|
-
interface RasterNode {
|
|
79
|
-
id: string;
|
|
80
|
-
type: string;
|
|
81
|
-
}
|
|
82
|
-
/** The group members of a layer union. */
|
|
83
|
-
type GroupIn<T> = Extract<T, {
|
|
84
|
-
type: 'group';
|
|
85
|
-
}>;
|
|
86
|
-
interface LayerLocation<T extends RasterNode = RasterLayer> {
|
|
87
|
-
layer: T;
|
|
88
|
-
/** The containing group, or `null` at the top level. */
|
|
89
|
-
parent: GroupIn<T> | null;
|
|
90
|
-
/** Index within the parent's children (or the top-level list). */
|
|
91
|
-
index: number;
|
|
92
|
-
/** Ancestors from the top level down to the parent. */
|
|
93
|
-
path: GroupIn<T>[];
|
|
94
|
-
}
|
|
95
|
-
/** Every layer, depth first, bottom to top (a group comes before its children). */
|
|
96
|
-
declare function flattenLayers<T extends RasterNode>(layers: readonly T[]): T[];
|
|
97
|
-
declare function findLayer<T extends RasterNode>(layers: readonly T[], id: string): LayerLocation<T> | null;
|
|
98
|
-
/** Replaces the layer with `id` by `fn(layer)` (or removes it when `fn` returns `null`). */
|
|
99
|
-
declare function mapLayer<T extends RasterNode>(layers: readonly T[], id: string, fn: (layer: T) => T | null): T[];
|
|
100
|
-
/** Inserts `layer` into `parentId`'s children (or the top level) at `index` (default: top). */
|
|
101
|
-
declare function insertLayer<T extends RasterNode>(layers: readonly T[], layer: T, parentId: string | null, index?: number): T[];
|
|
102
|
-
declare function isLayerLocked(layer: {
|
|
103
|
-
locks?: LayerLocks;
|
|
104
|
-
}, what: keyof LayerLocks): boolean;
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* The per-tile layer compositor engine. Composites a layer stack (pixel layers and groups with
|
|
108
|
-
* masks, clipping, blend modes, opacity, fill and pass-through) tile by tile in document space,
|
|
109
|
-
* in pure TypeScript, so results are deterministic and testable in Node and Workers.
|
|
9
|
+
* Render order, bottom to top (Photoshop's layer-style stack read upwards): drop shadows, outer
|
|
10
|
+
* glows, then the layer itself (content at fill opacity) with pattern, gradient and colour
|
|
11
|
+
* overlays, satin, inner glows, inner shadows, the inside part of strokes and inner bevels on
|
|
12
|
+
* top. The outside part of strokes and outer bevels go beneath the layer, onto the backdrop.
|
|
13
|
+
* Exterior effects blend straight into the backdrop with their own modes; the layer blends with
|
|
14
|
+
* its mode and, in a mode other than Normal, is merged into the backdrop before the interior
|
|
15
|
+
* effects paint over it (Photoshop's "Blend Interior Effects as Group" off). Emboss and pillow
|
|
16
|
+
* emboss then shade the composited result. Layer opacity applies to the whole stack; fill
|
|
17
|
+
* opacity only to the layer's own pixels.
|
|
110
18
|
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
19
|
+
* Every map depends only on the layer's shape (its alpha after the mask), the effect settings
|
|
20
|
+
* and the global light, never on the backdrop. {@link buildEffectMaps} computes them once over the
|
|
21
|
+
* layer's whole region; {@link compositeLayerEffects} paints any part of that region (a tile) from
|
|
22
|
+
* them, pixel by pixel, so a tiled render equals a whole-image render.
|
|
114
23
|
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
* object, so callers can skip uploading it).
|
|
120
|
-
* - A prefix cache keeps the accumulator *before* the step that changed last time (and, when the
|
|
121
|
-
* caller names it, before the active layer). Dragging a slider on layer k, or a stroke on layer
|
|
122
|
-
* k, recomposites from step k upwards only; `dirty` rectangles limit that to where it changed.
|
|
123
|
-
* - Spatial filters and feathered or parametric masks are computed once over the canvas and
|
|
124
|
-
* cached by the identity of their inputs.
|
|
24
|
+
* Distances: a stroke's outer edge uses the 5 × 5 chamfer below 20 px and an exact Euclidean
|
|
25
|
+
* transform from there (the chamfer's octagonal level sets facet wide strokes); inside strokes and
|
|
26
|
+
* spread / choke keep the chamfer; precise glows and chiselled bevels use the exact transform.
|
|
27
|
+
* Soft falloffs are two box blurs (a tent).
|
|
125
28
|
*/
|
|
126
29
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
30
|
+
interface EffectRect {
|
|
31
|
+
x: number;
|
|
32
|
+
y: number;
|
|
130
33
|
width: number;
|
|
131
34
|
height: number;
|
|
132
|
-
/** The pixels of a pixel layer (lets a host resolve layers whose pixels live elsewhere). */
|
|
133
|
-
surfaceOf?(layer: CompositorLayer): PixelSurface;
|
|
134
|
-
/** Changes whenever one of the host's callbacks would return something new for the same layers. */
|
|
135
|
-
version?: number | string;
|
|
136
|
-
}
|
|
137
|
-
/** The fields the engine reads; editor layer types are wider. */
|
|
138
|
-
interface CompositorLayer extends RasterNode {
|
|
139
|
-
visible: boolean;
|
|
140
|
-
opacity: number;
|
|
141
|
-
blend: string;
|
|
142
|
-
clipped?: boolean;
|
|
143
|
-
mask?: RasterMask;
|
|
144
|
-
/** Pixel layers. */
|
|
145
|
-
surface?: PixelSurface;
|
|
146
|
-
offset?: {
|
|
147
|
-
x: number;
|
|
148
|
-
y: number;
|
|
149
|
-
};
|
|
150
|
-
fillOpacity?: number;
|
|
151
|
-
/** Groups. */
|
|
152
|
-
children?: readonly CompositorLayer[];
|
|
153
|
-
}
|
|
154
|
-
/** A pixel layer's filters as the engine runs them. */
|
|
155
|
-
interface PixelFilterSpec {
|
|
156
|
-
/** Identifies the settings (part of the cache key). */
|
|
157
|
-
key: string;
|
|
158
|
-
/** Needs neighbouring pixels: runs once over the canvas instead of per tile. */
|
|
159
|
-
spatial: boolean;
|
|
160
|
-
/** Filters RGBA `data` (`width × height`) in place. */
|
|
161
|
-
apply(data: Uint8ClampedArray, width: number, height: number): void;
|
|
162
|
-
}
|
|
163
|
-
/** How an editor's own layer kinds composite. Every hook is optional. */
|
|
164
|
-
interface CompositorProfile<L extends CompositorLayer, S extends RasterSources> {
|
|
165
|
-
/** Layers that change what is below them; adjacent ones run as one step. */
|
|
166
|
-
isFilterLayer?(layer: L): boolean;
|
|
167
|
-
/** Applies a run of visible filter layers to `acc` (RGBA over `r`); `coverage` holds masked ones by id. */
|
|
168
|
-
applyFilterRun?(layers: L[], acc: Uint8ClampedArray, r: RasterRect, coverage: Map<string, Float32Array> | undefined, sources: S): void;
|
|
169
|
-
/** RGBA of a content layer that is neither a pixel layer nor a group, over `r`, or `null`. */
|
|
170
|
-
contentTile?(layer: L, r: RasterRect, sources: S): Uint8ClampedArray | null;
|
|
171
|
-
/** The blend mode a content layer draws with (default `layer.blend`). */
|
|
172
|
-
contentBlend?(layer: L): BlendMode;
|
|
173
|
-
/** Properties of a layer beyond the generic ones that change its pixels (part of its signature). */
|
|
174
|
-
layerKey?(layer: L): unknown;
|
|
175
|
-
/** Active filters of a pixel layer, or `null`. */
|
|
176
|
-
pixelFilters?(layer: L): PixelFilterSpec | null;
|
|
177
|
-
/** Canvas coverage (0..1, `width × height`) of a parametric mask source, or `null` to reveal all. */
|
|
178
|
-
maskSourcePlane?(source: unknown, width: number, height: number, sources: S): Float32Array | null;
|
|
179
|
-
}
|
|
180
|
-
interface CompositorOptions {
|
|
181
|
-
/** Upper bound for cached tile buffers (default 256 MiB). */
|
|
182
|
-
maxCacheBytes?: number;
|
|
183
|
-
}
|
|
184
|
-
interface CompositeCallOptions {
|
|
185
|
-
/**
|
|
186
|
-
* The layer about to be edited (the active layer): every tile composited in this call keeps a
|
|
187
|
-
* checkpoint below its step, so strokes and slider drags on it start there.
|
|
188
|
-
*/
|
|
189
|
-
checkpointLayerId?: string | null;
|
|
190
|
-
/**
|
|
191
|
-
* Where the layers changed since the previous call, when the caller knows (a stroke's dabs).
|
|
192
|
-
* Changed tiles are then recomposited only inside these rectangles. Changes outside them would
|
|
193
|
-
* be missed, so pass nothing when unsure.
|
|
194
|
-
*/
|
|
195
|
-
dirty?: RasterRect[];
|
|
196
35
|
}
|
|
36
|
+
/** Outside stroke width from which the outer edge uses the exact Euclidean transform. */
|
|
37
|
+
declare const STROKE_CHAMFER_MAX = 20;
|
|
38
|
+
/** A contour as a 0..1 LUT (corner points split the spline), or `null` for linear. */
|
|
39
|
+
declare function contourLut(c: EffectContour | undefined): Float32Array | null;
|
|
40
|
+
/** Where a bevel paints: inside the shape, outside it, or both (emboss styles). */
|
|
41
|
+
type BevelPaint = 'inner' | 'outer' | 'both';
|
|
42
|
+
interface EffectContext {
|
|
43
|
+
light: GlobalLight;
|
|
44
|
+
/** A pattern tile by id, or `null` when missing (pattern effects then paint nothing). */
|
|
45
|
+
pattern(id: string): PatternTile | null;
|
|
46
|
+
}
|
|
47
|
+
/** Effect maps of one layer over its region: see {@link buildEffectMaps}. */
|
|
48
|
+
interface EffectMaps {
|
|
49
|
+
/** The region the maps cover (document space). */
|
|
50
|
+
rect: EffectRect;
|
|
51
|
+
/** The enabled effects, Scale Effects applied, in list order. */
|
|
52
|
+
items: LayerEffect[];
|
|
53
|
+
/** Pixel bounds of the shape (alpha above half a step), or `null` when the shape is empty. */
|
|
54
|
+
bounds: EffectRect | null;
|
|
55
|
+
shape: Float32Array;
|
|
56
|
+
/** Per item: the maps it paints through. */
|
|
57
|
+
per: Float32Array[][];
|
|
58
|
+
bevelPaint: (BevelPaint | null)[];
|
|
59
|
+
din: Float32Array | null;
|
|
60
|
+
dout: Float32Array | null;
|
|
61
|
+
doutExact: Float32Array | null;
|
|
62
|
+
/** Frames of gradient strokes by item index. */
|
|
63
|
+
frames: Map<number, EffectRect>;
|
|
64
|
+
/** Approximate size in bytes (cache budgeting). */
|
|
65
|
+
bytes: number;
|
|
66
|
+
}
|
|
67
|
+
/** The enabled effects of `effects` with Scale Effects applied (empty when the master switch is off). */
|
|
68
|
+
declare function activeEffectItems(effects: LayerEffects | undefined | null): LayerEffect[];
|
|
197
69
|
/**
|
|
198
|
-
*
|
|
199
|
-
*
|
|
70
|
+
* Whether every map pixel of `items` depends only on the shape within the effects' margin, so a
|
|
71
|
+
* tile is unchanged while the layer is unchanged within its margin. Not local: anything laid out
|
|
72
|
+
* over the layer's bounds (aligned gradient overlays, gradient strokes, linked patterns) and noise
|
|
73
|
+
* (it speckles any coverage above zero, which picks up the blur's float noise from far away).
|
|
200
74
|
*/
|
|
201
|
-
declare function
|
|
202
|
-
/** Statistics of the last `composite` call (for benchmarks and tests). */
|
|
203
|
-
interface CompositeStats {
|
|
204
|
-
tiles: number;
|
|
205
|
-
/** Tiles returned straight from the cache. */
|
|
206
|
-
cached: number;
|
|
207
|
-
/** Steps actually run, summed over tiles. */
|
|
208
|
-
stepsRun: number;
|
|
209
|
-
}
|
|
210
|
-
declare class RasterCompositor<L extends CompositorLayer = CompositorLayer, S extends RasterSources = RasterSources> {
|
|
211
|
-
private readonly profile;
|
|
212
|
-
private readonly tiles;
|
|
213
|
-
private readonly maxCacheBytes;
|
|
214
|
-
private cacheBytes;
|
|
215
|
-
private stamp;
|
|
216
|
-
private sources;
|
|
217
|
-
private sourcesVersion;
|
|
218
|
-
private filteredCache;
|
|
219
|
-
private planeCache;
|
|
220
|
-
private planeIds;
|
|
221
|
-
private nextPlaneId;
|
|
222
|
-
private contentCache;
|
|
223
|
-
private readonly stepsCache;
|
|
224
|
-
private readonly propsKeyCache;
|
|
225
|
-
lastStats: CompositeStats;
|
|
226
|
-
private hint;
|
|
227
|
-
constructor(profile?: CompositorProfile<L, S>, options?: CompositorOptions);
|
|
228
|
-
/** Drops every cached tile and plane. */
|
|
229
|
-
clear(): void;
|
|
230
|
-
private setSources;
|
|
231
|
-
/** The composite of `layers` over `rect` as `rect.width × rect.height` RGBA (straight alpha). */
|
|
232
|
-
composite(layers: readonly L[], rect: RasterRect, sources: S, options?: CompositeCallOptions): Uint8ClampedArray;
|
|
233
|
-
/**
|
|
234
|
-
* Composites every tile intersecting `rect` and calls `onTile` with each tile's RGBA buffer
|
|
235
|
-
* (TILE × TILE). A tile whose inputs did not change since the last call returns the same buffer
|
|
236
|
-
* object; never mutate it.
|
|
237
|
-
*/
|
|
238
|
-
compositeTiles(layers: readonly L[], rect: RasterRect, sources: S, onTile: (tx: number, ty: number, data: Uint8ClampedArray, changed: boolean) => void, options?: CompositeCallOptions): void;
|
|
239
|
-
/** The composite of one tile (cached; do not mutate the result). */
|
|
240
|
-
tile(layers: readonly L[], tx: number, ty: number, sources: S): Uint8ClampedArray;
|
|
241
|
-
/**
|
|
242
|
-
* A layer's effective mask coverage (0..1, after density, feather or parametric evaluation)
|
|
243
|
-
* over `r` in document space, or `null` when it reveals all of `r`.
|
|
244
|
-
*/
|
|
245
|
-
maskCoverage(layer: L, r: RasterRect, sources: S): Float32Array | null;
|
|
246
|
-
private isFilter;
|
|
247
|
-
/**
|
|
248
|
-
* Groups a layer list into compositing steps: clipped layers join the nearest unclipped
|
|
249
|
-
* content or group layer below; consecutive unclipped filter layers form one run.
|
|
250
|
-
*/
|
|
251
|
-
private buildSteps;
|
|
252
|
-
/** The index of the top-level step that holds layer `id` (searching groups and clipped layers), or -1. */
|
|
253
|
-
private stepIndexOf;
|
|
254
|
-
/** Properties of a layer that change pixels, minus its surfaces (memoised per object). */
|
|
255
|
-
private propsKey;
|
|
256
|
-
private compositeTile;
|
|
257
|
-
private entryBytes;
|
|
258
|
-
private evict;
|
|
259
|
-
private stepSig;
|
|
260
|
-
private layerSig;
|
|
261
|
-
private groupSig;
|
|
262
|
-
private contentSig;
|
|
263
|
-
private maskRefs;
|
|
264
|
-
/**
|
|
265
|
-
* A pixel layer's pixels after spatial filters: the surface and the offset to apply. Layers
|
|
266
|
-
* with a spatial filter are filtered once over the canvas (in document space, offset 0).
|
|
267
|
-
*/
|
|
268
|
-
private layerPixels;
|
|
269
|
-
/** RGBA of a content layer over `r` (document space, inside one tile), or `null` when it has nothing there. */
|
|
270
|
-
private contentTile;
|
|
271
|
-
private planeKey;
|
|
272
|
-
/** Canvas-sized coverage of a feathered or parametric mask (cached). */
|
|
273
|
-
private planeFor;
|
|
274
|
-
private maskTile;
|
|
275
|
-
/** Runs one step onto `acc`; returns whether `acc` is still empty. */
|
|
276
|
-
private runStep;
|
|
277
|
-
private runSteps;
|
|
278
|
-
private contentBlend;
|
|
279
|
-
private blendOnto;
|
|
280
|
-
private applyClipped;
|
|
281
|
-
private applyFilterRun;
|
|
282
|
-
}
|
|
283
|
-
/** Tiles that differ between two surfaces (by tile identity), as tile keys. */
|
|
284
|
-
declare function changedTiles(a: TiledSurface, b: TiledSurface): TileKey[];
|
|
285
|
-
|
|
286
|
-
/** Above this σ a Gaussian is approximated by three box passes (cost independent of σ). */
|
|
287
|
-
declare const DIRECT_GAUSSIAN_MAX_SIGMA = 8;
|
|
288
|
-
/** How a blur treats pixels beyond the image: `zero`, or `clamp` (replicate the border). */
|
|
289
|
-
type BlurEdge = 'zero' | 'clamp';
|
|
290
|
-
type Edge = BlurEdge;
|
|
75
|
+
declare function effectsAreLocal(items: readonly LayerEffect[]): boolean;
|
|
291
76
|
/**
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
* {@link DIRECT_GAUSSIAN_MAX_SIGMA} is convolved directly; wider blurs use three box passes, so
|
|
295
|
-
* the cost per pixel never grows with σ.
|
|
77
|
+
* Builds every map `items` paints through from the layer's alpha `shape` (0..1) over `rect`.
|
|
78
|
+
* `rect` should cover the layer's shape plus the effects' margin.
|
|
296
79
|
*/
|
|
297
|
-
declare function
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
*/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
declare function decodePng(bytes: Uint8Array, options?: {
|
|
322
|
-
keepGray?: boolean;
|
|
323
|
-
maxPixels?: number;
|
|
324
|
-
}): DecodedPng;
|
|
325
|
-
declare function bytesToBase64(bytes: Uint8Array): string;
|
|
326
|
-
declare function base64ToBytes(text: string): Uint8Array;
|
|
327
|
-
/** The bytes and MIME type of a `data:` URL (base64 or percent-encoded). */
|
|
328
|
-
declare function parseDataUrl(url: string): {
|
|
329
|
-
mime: string;
|
|
330
|
-
bytes: Uint8Array;
|
|
331
|
-
} | null;
|
|
332
|
-
declare function pngDataUrl(width: number, height: number, data: ArrayLike<number>, channels?: 1 | 4): string;
|
|
333
|
-
|
|
80
|
+
declare function buildEffectMaps(items: LayerEffect[], shape: Float32Array, rect: EffectRect, ctx: EffectContext): EffectMaps;
|
|
81
|
+
/** Gradient parameter `t` (0..1) at pixel centre `(x, y)` of a gradient laid out in `frame`. */
|
|
82
|
+
declare function gradientT(style: GradientStyle, angle: number, scale: number, reverse: boolean, offset: {
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
}, frame: EffectRect, x: number, y: number): number;
|
|
86
|
+
interface EffectCompositeInput {
|
|
87
|
+
/** The accumulator (straight RGBA over `rect`); receives the layer and its effects. */
|
|
88
|
+
backdrop: Uint8ClampedArray;
|
|
89
|
+
/** The layer's pixels over `rect` (straight RGBA, mask applied to alpha, clipped layers applied). */
|
|
90
|
+
content: Uint8ClampedArray;
|
|
91
|
+
rect: EffectRect;
|
|
92
|
+
maps: EffectMaps;
|
|
93
|
+
blend: BlendMode;
|
|
94
|
+
/** Layer opacity: the whole stack. */
|
|
95
|
+
opacity: number;
|
|
96
|
+
/** Fill opacity: the layer's own pixels only. */
|
|
97
|
+
fillOpacity: number;
|
|
98
|
+
/** The canvas (unaligned gradients span it). */
|
|
99
|
+
canvas: EffectRect;
|
|
100
|
+
ctx: EffectContext;
|
|
101
|
+
}
|
|
102
|
+
/** Composites a layer's content and its effects onto `backdrop` in place (see the module comment for the order). */
|
|
103
|
+
declare function compositeLayerEffects(input: EffectCompositeInput): void;
|
|
334
104
|
/**
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
* layer pixels must serialize inside the synchronous `toJSON()`.
|
|
338
|
-
*
|
|
339
|
-
* - `inflate` handles stored, fixed and dynamic blocks and refuses to produce more than
|
|
340
|
-
* `maxOutput` bytes (a decompression bomb guard).
|
|
341
|
-
* - `deflate` is a greedy LZ77 (hash chains, 32 KiB window) with one dynamic Huffman block per
|
|
342
|
-
* 64 Ki symbols. It favours simplicity over the last few percent of ratio.
|
|
105
|
+
* Renders one layer with its effects over a whole region in one pass (no tiles): the reference
|
|
106
|
+
* the per-tile compositor is checked against, and a convenience for one-off renders.
|
|
343
107
|
*/
|
|
344
|
-
declare
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}): Uint8Array;
|
|
352
|
-
/** Adler-32 checksum (zlib trailer). */
|
|
353
|
-
declare function adler32(data: Uint8Array): number;
|
|
354
|
-
/** Inflates zlib data (header, deflate stream, Adler-32 trailer). */
|
|
355
|
-
declare function inflate(data: Uint8Array, options?: {
|
|
356
|
-
maxOutput?: number;
|
|
357
|
-
sizeHint?: number;
|
|
358
|
-
verify?: boolean;
|
|
359
|
-
}): Uint8Array;
|
|
360
|
-
/** Raw deflate (no zlib header). `level` 0 stores the data uncompressed. */
|
|
361
|
-
declare function deflateRaw(data: Uint8Array, level?: 0 | 1): Uint8Array;
|
|
362
|
-
/** zlib stream: header, raw deflate, Adler-32. */
|
|
363
|
-
declare function deflate(data: Uint8Array, level?: 0 | 1): Uint8Array;
|
|
108
|
+
declare function renderLayerEffects(effects: LayerEffects, layer: {
|
|
109
|
+
content: Uint8ClampedArray;
|
|
110
|
+
rect: EffectRect;
|
|
111
|
+
blend: BlendMode;
|
|
112
|
+
opacity: number;
|
|
113
|
+
fillOpacity?: number;
|
|
114
|
+
}, backdrop: Uint8ClampedArray, canvas: EffectRect, ctx: EffectContext): void;
|
|
364
115
|
|
|
365
|
-
export { BlendMode, type
|
|
116
|
+
export { BlendMode, type EffectCompositeInput, type EffectContext, EffectContour, type EffectMaps, type EffectRect, GlobalLight, GradientStyle, LayerEffect, LayerEffects, PatternTile, STROKE_CHAMFER_MAX, activeEffectItems, buildEffectMaps, compositeLayerEffects, contourLut, effectsAreLocal, gradientT, renderLayerEffects };
|
package/dist/raster/index.js
CHANGED
|
@@ -1,28 +1,66 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CURVE_LUT_SIZE,
|
|
3
|
+
DEFAULT_GLOBAL_LIGHT,
|
|
2
4
|
DIRECT_GAUSSIAN_MAX_SIGMA,
|
|
5
|
+
LAYER_EFFECT_KINDS,
|
|
6
|
+
LayerEffectError,
|
|
7
|
+
MAX_EFFECT_REACH,
|
|
8
|
+
PatternPlacement,
|
|
9
|
+
PatternTile,
|
|
3
10
|
RasterCompositor,
|
|
11
|
+
STROKE_CHAMFER_MAX,
|
|
4
12
|
ZlibError,
|
|
13
|
+
activeEffectItems,
|
|
5
14
|
adler32,
|
|
6
15
|
base64ToBytes,
|
|
7
16
|
blendTile,
|
|
17
|
+
buildEffectMaps,
|
|
18
|
+
builtinPattern,
|
|
19
|
+
builtinPatternIds,
|
|
8
20
|
bytesToBase64,
|
|
9
21
|
changedTiles,
|
|
22
|
+
compositeLayerEffects,
|
|
23
|
+
contourLut,
|
|
24
|
+
curveLut,
|
|
10
25
|
decodePng,
|
|
26
|
+
defaultEffectGradient,
|
|
27
|
+
defaultLayerEffect,
|
|
11
28
|
deflate,
|
|
12
29
|
deflateRaw,
|
|
30
|
+
effectColorHex,
|
|
31
|
+
effectReach,
|
|
32
|
+
effectsAreLocal,
|
|
33
|
+
effectsFingerprint,
|
|
34
|
+
effectsMargin,
|
|
35
|
+
effectsScale,
|
|
13
36
|
encodePng,
|
|
14
37
|
findLayer,
|
|
15
38
|
flattenLayers,
|
|
16
39
|
gaussianBlur,
|
|
40
|
+
gradientT,
|
|
41
|
+
hasActiveEffects,
|
|
42
|
+
hashNoise,
|
|
17
43
|
inflate,
|
|
18
44
|
inflateRaw,
|
|
19
45
|
insertLayer,
|
|
46
|
+
isLayerEffectKind,
|
|
20
47
|
isLayerLocked,
|
|
21
48
|
isPng,
|
|
49
|
+
layerEffectFields,
|
|
50
|
+
layerEffectLabel,
|
|
22
51
|
mapLayer,
|
|
52
|
+
mergeLayerEffect,
|
|
53
|
+
newEffectId,
|
|
54
|
+
normalizeLayerEffects,
|
|
23
55
|
parseDataUrl,
|
|
24
|
-
|
|
25
|
-
|
|
56
|
+
parseEffectColor,
|
|
57
|
+
pngDataUrl,
|
|
58
|
+
renderLayerEffects,
|
|
59
|
+
scaleLayerEffect,
|
|
60
|
+
validateEffectGradient,
|
|
61
|
+
validateLayerEffect,
|
|
62
|
+
validateLayerEffects
|
|
63
|
+
} from "../chunk-747CGOT2.js";
|
|
26
64
|
import {
|
|
27
65
|
BLEND_MODES,
|
|
28
66
|
SurfaceDraft,
|
|
@@ -61,13 +99,22 @@ import {
|
|
|
61
99
|
} from "../chunk-D4ZCU72J.js";
|
|
62
100
|
export {
|
|
63
101
|
BLEND_MODES,
|
|
102
|
+
CURVE_LUT_SIZE,
|
|
103
|
+
DEFAULT_GLOBAL_LIGHT,
|
|
64
104
|
DIRECT_GAUSSIAN_MAX_SIGMA,
|
|
105
|
+
LAYER_EFFECT_KINDS,
|
|
106
|
+
LayerEffectError,
|
|
107
|
+
MAX_EFFECT_REACH,
|
|
108
|
+
PatternPlacement,
|
|
109
|
+
PatternTile,
|
|
65
110
|
RasterCompositor,
|
|
111
|
+
STROKE_CHAMFER_MAX,
|
|
66
112
|
SurfaceDraft,
|
|
67
113
|
TILE,
|
|
68
114
|
TILE_SHIFT,
|
|
69
115
|
TiledSurface,
|
|
70
116
|
ZlibError,
|
|
117
|
+
activeEffectItems,
|
|
71
118
|
adler32,
|
|
72
119
|
base64ToBytes,
|
|
73
120
|
blendChannel,
|
|
@@ -76,14 +123,28 @@ export {
|
|
|
76
123
|
blendPixel,
|
|
77
124
|
blendRgb,
|
|
78
125
|
blendTile,
|
|
126
|
+
buildEffectMaps,
|
|
127
|
+
builtinPattern,
|
|
128
|
+
builtinPatternIds,
|
|
79
129
|
bytesToBase64,
|
|
80
130
|
canvasCompositeOperation,
|
|
81
131
|
changedTiles,
|
|
82
132
|
collectTiles,
|
|
133
|
+
compositeLayerEffects,
|
|
83
134
|
contentBounds,
|
|
135
|
+
contourLut,
|
|
136
|
+
curveLut,
|
|
84
137
|
decodePng,
|
|
138
|
+
defaultEffectGradient,
|
|
139
|
+
defaultLayerEffect,
|
|
85
140
|
deflate,
|
|
86
141
|
deflateRaw,
|
|
142
|
+
effectColorHex,
|
|
143
|
+
effectReach,
|
|
144
|
+
effectsAreLocal,
|
|
145
|
+
effectsFingerprint,
|
|
146
|
+
effectsMargin,
|
|
147
|
+
effectsScale,
|
|
87
148
|
emptySurface,
|
|
88
149
|
encodePng,
|
|
89
150
|
fillRect,
|
|
@@ -91,20 +152,32 @@ export {
|
|
|
91
152
|
finishTile,
|
|
92
153
|
flattenLayers,
|
|
93
154
|
gaussianBlur,
|
|
155
|
+
gradientT,
|
|
156
|
+
hasActiveEffects,
|
|
157
|
+
hashNoise,
|
|
94
158
|
inflate,
|
|
95
159
|
inflateRaw,
|
|
96
160
|
insertLayer,
|
|
97
161
|
isBlendMode,
|
|
162
|
+
isLayerEffectKind,
|
|
98
163
|
isLayerLocked,
|
|
99
164
|
isPng,
|
|
100
165
|
isSeparableBlendMode,
|
|
166
|
+
layerEffectFields,
|
|
167
|
+
layerEffectLabel,
|
|
101
168
|
mapLayer,
|
|
169
|
+
mergeLayerEffect,
|
|
170
|
+
newEffectId,
|
|
102
171
|
normalizeBlendMode,
|
|
172
|
+
normalizeLayerEffects,
|
|
103
173
|
packRgba,
|
|
104
174
|
parseDataUrl,
|
|
175
|
+
parseEffectColor,
|
|
105
176
|
pngDataUrl,
|
|
106
177
|
readPixel,
|
|
107
178
|
readRegion,
|
|
179
|
+
renderLayerEffects,
|
|
180
|
+
scaleLayerEffect,
|
|
108
181
|
setLum,
|
|
109
182
|
solidSurface,
|
|
110
183
|
surfaceBytes,
|
|
@@ -116,6 +189,9 @@ export {
|
|
|
116
189
|
tilesInRect,
|
|
117
190
|
translateSurface,
|
|
118
191
|
uniformTile,
|
|
192
|
+
validateEffectGradient,
|
|
193
|
+
validateLayerEffect,
|
|
194
|
+
validateLayerEffects,
|
|
119
195
|
writeRegion
|
|
120
196
|
};
|
|
121
197
|
//# sourceMappingURL=index.js.map
|
|
@@ -178,4 +178,4 @@ declare function collectTiles(surface: TiledSurface, into: Set<Tile>): void;
|
|
|
178
178
|
/** True when two surfaces hold the same pixels (cheap when they share tiles). */
|
|
179
179
|
declare function surfacesEqual(a: TiledSurface, b: TiledSurface): boolean;
|
|
180
180
|
|
|
181
|
-
export { solidSurface as A, type BlendMode as B, surfaceBytes as C, surfaceFromPixels as D, surfacesEqual as E, tileCoord as F, tileKey as G, tileRect as H, tilesInRect as I, translateSurface as J, uniformTile as K, writeRegion as L, type MaskSurface as M, type PixelSurface as P, type RasterRect as R, SurfaceDraft as S,
|
|
181
|
+
export { solidSurface as A, type BlendMode as B, surfaceBytes as C, surfaceFromPixels as D, surfacesEqual as E, tileCoord as F, tileKey as G, tileRect as H, tilesInRect as I, translateSurface as J, uniformTile as K, writeRegion as L, type MaskSurface as M, type PixelSurface as P, type RasterRect as R, SurfaceDraft as S, TILE as T, BLEND_MODES as a, type BlendModeInfo as b, type Rgb as c, type Rgba as d, TILE_SHIFT as e, type Tile as f, type TileKey as g, TiledSurface as h, blendChannel as i, blendImageData as j, blendLum as k, blendPixel as l, blendRgb as m, canvasCompositeOperation as n, collectTiles as o, contentBounds as p, emptySurface as q, fillRect as r, finishTile as s, isBlendMode as t, isSeparableBlendMode as u, normalizeBlendMode as v, packRgba as w, readPixel as x, readRegion as y, setLum as z };
|
|
@@ -178,4 +178,4 @@ declare function collectTiles(surface: TiledSurface, into: Set<Tile>): void;
|
|
|
178
178
|
/** True when two surfaces hold the same pixels (cheap when they share tiles). */
|
|
179
179
|
declare function surfacesEqual(a: TiledSurface, b: TiledSurface): boolean;
|
|
180
180
|
|
|
181
|
-
export { solidSurface as A, type BlendMode as B, surfaceBytes as C, surfaceFromPixels as D, surfacesEqual as E, tileCoord as F, tileKey as G, tileRect as H, tilesInRect as I, translateSurface as J, uniformTile as K, writeRegion as L, type MaskSurface as M, type PixelSurface as P, type RasterRect as R, SurfaceDraft as S,
|
|
181
|
+
export { solidSurface as A, type BlendMode as B, surfaceBytes as C, surfaceFromPixels as D, surfacesEqual as E, tileCoord as F, tileKey as G, tileRect as H, tilesInRect as I, translateSurface as J, uniformTile as K, writeRegion as L, type MaskSurface as M, type PixelSurface as P, type RasterRect as R, SurfaceDraft as S, TILE as T, BLEND_MODES as a, type BlendModeInfo as b, type Rgb as c, type Rgba as d, TILE_SHIFT as e, type Tile as f, type TileKey as g, TiledSurface as h, blendChannel as i, blendImageData as j, blendLum as k, blendPixel as l, blendRgb as m, canvasCompositeOperation as n, collectTiles as o, contentBounds as p, emptySurface as q, fillRect as r, finishTile as s, isBlendMode as t, isSeparableBlendMode as u, normalizeBlendMode as v, packRgba as w, readPixel as x, readRegion as y, setLum as z };
|