@nodetool-ai/image-editor 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +100 -0
  2. package/dist/.nodetool-build-stamp +1 -0
  3. package/dist/dependencyHash.d.ts +25 -0
  4. package/dist/dependencyHash.d.ts.map +1 -0
  5. package/dist/dependencyHash.js +56 -0
  6. package/dist/dependencyHash.js.map +1 -0
  7. package/dist/index.d.ts +5 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +8 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/painting/index.d.ts +11 -0
  12. package/dist/painting/index.d.ts.map +1 -0
  13. package/dist/painting/index.js +11 -0
  14. package/dist/painting/index.js.map +1 -0
  15. package/dist/painting/strokeRendering.d.ts +79 -0
  16. package/dist/painting/strokeRendering.d.ts.map +1 -0
  17. package/dist/painting/strokeRendering.js +431 -0
  18. package/dist/painting/strokeRendering.js.map +1 -0
  19. package/dist/painting/surface.d.ts +75 -0
  20. package/dist/painting/surface.d.ts.map +1 -0
  21. package/dist/painting/surface.js +48 -0
  22. package/dist/painting/surface.js.map +1 -0
  23. package/dist/painting/types.d.ts +135 -0
  24. package/dist/painting/types.d.ts.map +1 -0
  25. package/dist/painting/types.js +226 -0
  26. package/dist/painting/types.js.map +1 -0
  27. package/dist/raster/adjust.d.ts +22 -0
  28. package/dist/raster/adjust.d.ts.map +1 -0
  29. package/dist/raster/adjust.js +157 -0
  30. package/dist/raster/adjust.js.map +1 -0
  31. package/dist/raster/color.d.ts +20 -0
  32. package/dist/raster/color.d.ts.map +1 -0
  33. package/dist/raster/color.js +36 -0
  34. package/dist/raster/color.js.map +1 -0
  35. package/dist/raster/draw.d.ts +51 -0
  36. package/dist/raster/draw.d.ts.map +1 -0
  37. package/dist/raster/draw.js +243 -0
  38. package/dist/raster/draw.js.map +1 -0
  39. package/dist/raster/fill.d.ts +20 -0
  40. package/dist/raster/fill.d.ts.map +1 -0
  41. package/dist/raster/fill.js +129 -0
  42. package/dist/raster/fill.js.map +1 -0
  43. package/dist/raster/index.d.ts +12 -0
  44. package/dist/raster/index.d.ts.map +1 -0
  45. package/dist/raster/index.js +12 -0
  46. package/dist/raster/index.js.map +1 -0
  47. package/dist/raster/selection.d.ts +50 -0
  48. package/dist/raster/selection.d.ts.map +1 -0
  49. package/dist/raster/selection.js +338 -0
  50. package/dist/raster/selection.js.map +1 -0
  51. package/dist/raster/types.d.ts +35 -0
  52. package/dist/raster/types.d.ts.map +1 -0
  53. package/dist/raster/types.js +20 -0
  54. package/dist/raster/types.js.map +1 -0
  55. package/dist/types.d.ts +210 -0
  56. package/dist/types.d.ts.map +1 -0
  57. package/dist/types.js +9 -0
  58. package/dist/types.js.map +1 -0
  59. package/package.json +76 -0
package/README.md ADDED
@@ -0,0 +1,100 @@
1
+ # @nodetool-ai/image-editor
2
+
3
+ Shared image-editor types, dependency hashing, seeded layer templates, and the paint core for [NodeTool](https://nodetool.ai).
4
+
5
+ The pure layer behind NodeTool's layered sketch editor: the persisted document shape, per-layer generation bindings (workflow-bound and direct text-to-image / image-to-image / inpaint), version history, the content hash that detects when a layer is stale, and the brush/pencil/eraser stroke engine. Kept free of the web editor implementation so both the browser and server can depend on it.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @nodetool-ai/image-editor
11
+ ```
12
+
13
+ ## Exported symbols
14
+
15
+ | Symbol | Kind | Description |
16
+ | --- | --- | --- |
17
+ | `ImageDocument` | interface | Top-level persisted image document (sketch + layer bindings) |
18
+ | `SketchDocumentLike` | interface | Minimal sketch-compatible document payload |
19
+ | `SketchLayerLike` | interface | One layer (raster / mask / group) |
20
+ | `SketchViewportLike` | interface | Zoom + pan state |
21
+ | `LayerWorkflowBinding` | interface | How a layer's pixels are generated (unified binding) |
22
+ | `LayerBinding` | type | Clearer alias of `LayerWorkflowBinding` for new code |
23
+ | `LayerBindingKind` | type | `"workflow" \| "text-to-image" \| "image-to-image" \| "inpaint"` |
24
+ | `LayerStatus` | type | `draft`, `queued`, `generating`, `generated`, `stale`, `failed`, … |
25
+ | `LayerVersion` | interface | One recorded generation of a layer |
26
+ | `PersistedHistoryEntryLike` | interface | Undo/redo history entry shape |
27
+ | `LayerTemplateKind` | type | `"text-to-image" \| "inpaint" \| "background-remove"` |
28
+ | `LayerTemplateDefinition` | interface | Seeded workflow template for a new layer |
29
+
30
+ The Node-only `computeDependencyHash` (and its `DependencyHashInput`) is not re-exported from the root because it pulls in `node:crypto`. Import it from the subpath on the server:
31
+
32
+ ```ts
33
+ import { computeDependencyHash } from "@nodetool-ai/image-editor/dependencyHash";
34
+ ```
35
+
36
+ ## Paint core
37
+
38
+ `@nodetool-ai/image-editor/painting.js` is the brush/pencil/eraser stroke
39
+ engine — pressure dynamics, dab spacing, brush-stamp caching, supersampling,
40
+ dirty-rect tracking — plus the settings shapes it reads (`BrushSettings`,
41
+ `PencilSettings`, `EraserSettings`, `DEFAULT_BRUSH_SETTINGS`, …). The web
42
+ sketch editor re-exports it; there is no second copy.
43
+
44
+ It is plain Canvas2D with one seam. The engine allocates the off-screen bitmaps
45
+ for its stamp cache through `createPaintSurface`, which defaults to
46
+ `window.document.createElement("canvas")`. A headless host swaps that out:
47
+
48
+ ```ts
49
+ import { createCanvas } from "@napi-rs/canvas";
50
+ import {
51
+ setPaintSurfaceFactory,
52
+ drawBrushStroke,
53
+ DEFAULT_BRUSH_SETTINGS
54
+ } from "@nodetool-ai/image-editor/painting.js";
55
+
56
+ setPaintSurfaceFactory(createCanvas);
57
+
58
+ const canvas = createCanvas(256, 256);
59
+ drawBrushStroke(
60
+ { x: 32, y: 48 },
61
+ { x: 224, y: 176 },
62
+ { ...DEFAULT_BRUSH_SETTINGS, size: 24, color: "#ff2d55" },
63
+ canvas.getContext("2d"),
64
+ undefined,
65
+ { current: null },
66
+ new Map()
67
+ );
68
+ ```
69
+
70
+ `setPaintSurfaceFactory(null)` restores the browser default. `PaintContext2D`
71
+ and `PaintSurface` are structural types, so a DOM `CanvasRenderingContext2D`
72
+ and a skia canvas both satisfy them without a cast.
73
+
74
+ ## Raster ops
75
+
76
+ `@nodetool-ai/image-editor/raster.js` is the fill, gradient, shape, transform,
77
+ adjust, crop, and selection-mask engine the `ui_sketch_*` tools share. ImageData
78
+ ops (`fillRegion`, `adjustImage`, `pickPixel`, selection builders) need no
79
+ canvas. Drawing ops (`drawGradient`, `drawShape`, `transformRaster`, `cropRaster`)
80
+ take a `RasterContext2D` — a DOM or skia 2D context.
81
+
82
+ ## Usage
83
+
84
+ ```ts
85
+ import type { ImageDocument, LayerBinding } from "@nodetool-ai/image-editor";
86
+
87
+ const doc: ImageDocument = loadDocument(id);
88
+ const binding: LayerBinding | undefined = doc.layerBindings.find(
89
+ (b) => b.layerId === activeLayerId
90
+ );
91
+
92
+ if (binding?.status === "stale") {
93
+ regenerate(binding);
94
+ }
95
+ ```
96
+
97
+ ## Links
98
+
99
+ - [NodeTool](https://nodetool.ai)
100
+ - [GitHub](https://github.com/nodetool-ai/nodetool)
@@ -0,0 +1 @@
1
+ 2026-09-28T09:19:01.210Z
@@ -0,0 +1,25 @@
1
+ /**
2
+ * A value the digest can canonicalize: decoded JSON, plus `undefined`, which a
3
+ * param override may hold and which the digest keeps distinct from `null` and
4
+ * from an absent key.
5
+ */
6
+ export type HashableValue = string | number | boolean | null | undefined | HashableValue[] | {
7
+ [key: string]: HashableValue;
8
+ };
9
+ /** Workflow param overrides as the digest reads them. */
10
+ export type ParamOverrides = Record<string, HashableValue>;
11
+ export interface DependencyHashInput {
12
+ workflowId: string;
13
+ /** Timestamp from the bound workflow `updated_at` field. */
14
+ workflowUpdatedAt: string;
15
+ paramOverrides: ParamOverrides;
16
+ inputAssetHashes: string[];
17
+ /**
18
+ * Output node the binding reads from. Folded into the hash so re-pointing a
19
+ * binding at a different terminal output counts as a dependency change.
20
+ * Optional for callers that don't track an output selection.
21
+ */
22
+ selectedOutputNodeId?: string;
23
+ }
24
+ export declare function computeDependencyHash(input: DependencyHashInput): string;
25
+ //# sourceMappingURL=dependencyHash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencyHash.d.ts","sourceRoot":"","sources":["../src/dependencyHash.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,SAAS,GACT,aAAa,EAAE,GACf;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAAA;CAAE,CAAC;AAErC,yDAAyD;AACzD,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;AAE3D,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAgDD,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,mBAAmB,GAAG,MAAM,CAkBxE"}
@@ -0,0 +1,56 @@
1
+ import { createHash } from "node:crypto";
2
+ const HASH_INPUT_VERSION_PREFIX = "v1:";
3
+ /**
4
+ * Order strings by UTF-16 code unit. `localeCompare` is locale/ICU-dependent,
5
+ * which would make the digest differ across hosts for the same input — fatal
6
+ * for a content hash. Code-unit ordering is deterministic everywhere.
7
+ */
8
+ function byCodeUnit(left, right) {
9
+ return left < right ? -1 : left > right ? 1 : 0;
10
+ }
11
+ function isHashableRecord(value) {
12
+ return value !== null && typeof value === "object" && !Array.isArray(value);
13
+ }
14
+ function stableSerialize(value) {
15
+ if (value === undefined) {
16
+ return "undefined";
17
+ }
18
+ if (Array.isArray(value)) {
19
+ return `[${value.map((item) => stableSerialize(item)).join(",")}]`;
20
+ }
21
+ if (isHashableRecord(value)) {
22
+ const entries = Object.entries(value).sort(([leftKey], [rightKey]) => byCodeUnit(leftKey, rightKey));
23
+ return `{${entries
24
+ .map(([key, entryValue]) => `${JSON.stringify(key)}:${stableSerialize(entryValue)}`)
25
+ .join(",")}}`;
26
+ }
27
+ // JSON.stringify collapses NaN / ±Infinity to "null"; keep them distinct.
28
+ if (Number.isNaN(value)) {
29
+ return "NaN";
30
+ }
31
+ if (value === Number.POSITIVE_INFINITY) {
32
+ return "Infinity";
33
+ }
34
+ if (value === Number.NEGATIVE_INFINITY) {
35
+ return "-Infinity";
36
+ }
37
+ return JSON.stringify(value);
38
+ }
39
+ export function computeDependencyHash(input) {
40
+ // Object keys are sorted canonically by `stableSerialize`, so paramOverrides
41
+ // needs no pre-sort. Array order *is* significant, so asset hashes are sorted.
42
+ const base = {
43
+ workflowId: input.workflowId,
44
+ workflowUpdatedAt: input.workflowUpdatedAt,
45
+ paramOverrides: input.paramOverrides,
46
+ inputAssetHashes: [...input.inputAssetHashes].sort(byCodeUnit)
47
+ };
48
+ // Absent, not undefined: a caller that tracks no output selection must hash
49
+ // the same as one that never had the field.
50
+ const normalizedInput = input.selectedOutputNodeId === undefined
51
+ ? base
52
+ : { ...base, selectedOutputNodeId: input.selectedOutputNodeId };
53
+ const payload = `${HASH_INPUT_VERSION_PREFIX}${stableSerialize(normalizedInput)}`;
54
+ return createHash("sha256").update(payload, "utf8").digest("hex");
55
+ }
56
+ //# sourceMappingURL=dependencyHash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencyHash.js","sourceRoot":"","sources":["../src/dependencyHash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,yBAAyB,GAAG,KAAK,CAAC;AAiCxC;;;;GAIG;AACH,SAAS,UAAU,CAAC,IAAY,EAAE,KAAa;IAC7C,OAAO,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC,CA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AAK,KAAK,MAAM,CAAC,iBAAiB,EAAE,CAAC;QACvC,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAA0B;IAC9D,6EAA6E;IAC7E,+EAA+E;IAC/E,MAAM,IAAI,GAAG;QACX,UAAU,EAAE,KAAK,CAAC,UAAU;QAC5B,iBAAiB,EAAE,KAAK,CAAC,iBAAiB;QAC1C,cAAc,EAAE,KAAK,CAAC,cAAc;QACpC,gBAAgB,EAAE,CAAC,GAAG,KAAK,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC;KAC/D,CAAC;IACF,4EAA4E;IAC5E,4CAA4C;IAC5C,MAAM,eAAe,GACnB,KAAK,CAAC,oBAAoB,KAAK,SAAS;QACtC,CAAC,CAAC,IAAI;QACN,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,EAAE,CAAC;IAEpE,MAAM,OAAO,GAAG,GAAG,yBAAyB,GAAG,eAAe,CAAC,eAAe,CAAC,EAAE,CAAC;IAClF,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACpE,CAAC"}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @nodetool-ai/image-editor – Public API
3
+ */
4
+ export * from "./types.js";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @nodetool-ai/image-editor – Public API
3
+ */
4
+ export * from "./types.js";
5
+ // `dependencyHash` is intentionally NOT re-exported: it depends on
6
+ // `node:crypto`, which breaks browser bundles. Server consumers should
7
+ // import it directly from "@nodetool-ai/image-editor/dependencyHash".
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,YAAY,CAAC;AAC3B,mEAAmE;AACnE,uEAAuE;AACvE,sEAAsE"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @nodetool-ai/image-editor/painting — the paint core.
3
+ *
4
+ * The brush/pencil/eraser stroke engine plus the data shapes it reads. Pure
5
+ * Canvas2D with a single injectable surface factory, so it runs in the browser
6
+ * and headlessly in Node (see `setPaintSurfaceFactory`).
7
+ */
8
+ export * from "./types.js";
9
+ export * from "./surface.js";
10
+ export * from "./strokeRendering.js";
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/painting/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * @nodetool-ai/image-editor/painting — the paint core.
3
+ *
4
+ * The brush/pencil/eraser stroke engine plus the data shapes it reads. Pure
5
+ * Canvas2D with a single injectable surface factory, so it runs in the browser
6
+ * and headlessly in Node (see `setPaintSurfaceFactory`).
7
+ */
8
+ export * from "./types.js";
9
+ export * from "./surface.js";
10
+ export * from "./strokeRendering.js";
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/painting/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,sBAAsB,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * strokeRendering.ts
3
+ *
4
+ * Stroke rendering functions for brush, pencil, and eraser tools.
5
+ * Handles pressure sensitivity, dab spacing, stamp caching, supersampling,
6
+ * and dirty-rect tracking for efficient canvas updates.
7
+ *
8
+ * Host-neutral: the only canvas it allocates goes through `surface.ts`, so the
9
+ * same engine runs in the browser and headlessly in Node.
10
+ */
11
+ import type { Point, BrushSettings, PencilSettings, EraserSettings, DirtyRectTracker } from "./types.js";
12
+ import type { PaintContext2D, PaintSurface } from "./surface.js";
13
+ /** @deprecated Prefer {@link DEFAULT_PRESSURE_MIN_SCALE} / per-tool `pressureMinScale`. */
14
+ export declare const MIN_PRESSURE_FACTOR = 0.2;
15
+ /**
16
+ * Map hardware pressure in [0, 1] to a size/opacity multiplier in [minScale, 1].
17
+ * Used by brush and pencil when pressure sensitivity is on.
18
+ */
19
+ export declare function strokePressureMultiplier(pressure: number, minScale?: number, curve?: number): number;
20
+ /**
21
+ * Pointer pressure is meaningful for pen/touch. Mouse uses a nominal value
22
+ * (commonly 0.5) while the button is down per Pointer Events — ignore it for
23
+ * brush/pencil/eraser dynamics so mouse strokes stay full strength.
24
+ */
25
+ export declare function paintPressureForEngine(pressure: number | undefined, pointerType: string | undefined): number | undefined;
26
+ /** Tool opacity at or above this is treated as fully opaque (no pressure fade, crisp eraser stamp, etc.). */
27
+ export declare const SKETCH_FULL_OPACITY_THRESHOLD = 0.999;
28
+ /** Integer square a pixel-perfect dab covers: `n`×`n` with its top-left at `(ix, iy)`. */
29
+ export interface PencilDabFootprint {
30
+ ix: number;
31
+ iy: number;
32
+ n: number;
33
+ }
34
+ /**
35
+ * Pixel-perfect pencil dab footprint: integer N×N square centered on the
36
+ * pixel under the cursor. Centering rule: offset = floor((N − 1) / 2), so
37
+ * odd N is symmetric and even N puts the cursor in the top-left of the
38
+ * 2×2 (resp. 4×4 …) core — the most common pixel-art convention.
39
+ */
40
+ export declare function pixelPerfectPencilDabFootprint(x: number, y: number, effectiveSize: number): PencilDabFootprint;
41
+ /**
42
+ * Document-space dab center matching `drawPencilStroke` / pencil-mode eraser `dabAt`.
43
+ * Maps continuous pointer `(x, y)` to where ink is centered so brush/pencil previews
44
+ * match stamped pixels (integer arc centers or half-integer crisp-cell centers).
45
+ */
46
+ export declare function snapStrokeDabCenterDoc(x: number, y: number, effectiveSize: number, effectiveOpacity: number, pixelPerfect?: boolean): Point;
47
+ export interface StrokeStampState {
48
+ hasStamped: boolean;
49
+ distanceToNextDab: number;
50
+ }
51
+ /**
52
+ * Distribute stamps along a stroke segment with even spacing.
53
+ * Exported for use by blur and clone rendering modules.
54
+ */
55
+ export declare function stampAlongStroke(from: Point, to: Point, spacing: number, stampAtPoint: (x: number, y: number) => void, stampState?: StrokeStampState): void;
56
+ /**
57
+ * Expand a dirty-rect bounding box to include a point with padding.
58
+ * Exported for use by blur rendering.
59
+ */
60
+ export declare function expandDirtyRect(dirtyRect: DirtyRectTracker, x: number, y: number, pad: number): void;
61
+ /**
62
+ * Expand a dirty-rect bounding box to include two points with padding.
63
+ * Exported for use by blur rendering.
64
+ */
65
+ export declare function expandDirtyRectFromPoints(dirtyRect: DirtyRectTracker, start: Point, end: Point, pad: number): void;
66
+ export declare function drawBrushStroke(from: Point, to: Point, settings: BrushSettings, ctx: PaintContext2D, pressure: number | undefined, dirtyRect: DirtyRectTracker, brushStampCache: Map<string, PaintSurface>, stampState?: StrokeStampState): void;
67
+ /** Black stroke-buffer mask: same brush shape/behavior as `brush` (new brush types apply automatically). */
68
+ export declare function brushSettingsForEraserStroke(eraser: EraserSettings, brush: BrushSettings): BrushSettings;
69
+ /** Black stroke-buffer mask: same dab behavior as `pencil`. */
70
+ export declare function pencilSettingsForEraserStroke(eraser: EraserSettings, pencil: PencilSettings): PencilSettings;
71
+ /**
72
+ * Eraser draws a black mask into the stroke buffer; the session composites with
73
+ * `destination-out` at tool opacity. Delegates to `drawBrushStroke` or
74
+ * `drawPencilStroke` using current brush/pencil tool settings (size overridden by
75
+ * eraser).
76
+ */
77
+ export declare function drawEraserStroke(from: Point, to: Point, eraser: EraserSettings, brushTemplate: BrushSettings, pencilTemplate: PencilSettings, ctx: PaintContext2D, pressure: number | undefined, dirtyRect: DirtyRectTracker, brushStampCache: Map<string, PaintSurface>, stampState?: StrokeStampState): void;
78
+ export declare function drawPencilStroke(from: Point, to: Point, settings: PencilSettings, ctx: PaintContext2D, pressure: number | undefined, dirtyRect: DirtyRectTracker, stampState?: StrokeStampState): void;
79
+ //# sourceMappingURL=strokeRendering.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"strokeRendering.d.ts","sourceRoot":"","sources":["../../src/painting/strokeRendering.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,KAAK,EACL,aAAa,EAEb,cAAc,EAEd,cAAc,EAEd,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAMpB,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKjE,2FAA2F;AAC3F,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,MAAM,EAChB,QAAQ,GAAE,MAAmC,EAC7C,KAAK,GAAE,MAA+B,GACrC,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,GAC9B,MAAM,GAAG,SAAS,CAQpB;AAED,6GAA6G;AAC7G,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AAEnD,0FAA0F;AAC1F,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,CAAC,EAAE,MAAM,CAAC;CACX;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAC5C,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,aAAa,EAAE,MAAM,GACpB,kBAAkB,CAQpB;A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