@pixerate/editor 0.126.0 → 0.128.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/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +3 -3
- package/dist/agent/index.d.ts +3 -3
- package/dist/agent/index.js +1 -1
- package/dist/animation/index.d.cts +2 -3
- package/dist/animation/index.d.ts +2 -3
- package/dist/animation-editor/index.cjs +63 -63
- package/dist/animation-editor/index.cjs.map +1 -1
- package/dist/animation-editor/index.d.cts +7 -9
- package/dist/animation-editor/index.d.ts +7 -9
- package/dist/animation-editor/index.js +10 -10
- package/dist/{arrange-BlfgJ_wt.d.ts → arrange-BUREmgD9.d.ts} +1 -1
- package/dist/{arrange-CD6Gh-pd.d.cts → arrange-CKXK_hf7.d.cts} +1 -1
- package/dist/{bezier-CWv6LQal.d.ts → bezier-CvgQiYRg.d.cts} +23 -3
- package/dist/{bezier-CBzKKDjl.d.cts → bezier-DP4NnJp3.d.ts} +23 -3
- package/dist/{brushTypes-IG7ZZjIN.d.cts → brushTypes-C7N3EBK7.d.cts} +56 -1
- package/dist/{brushTypes-IG7ZZjIN.d.ts → brushTypes-C7N3EBK7.d.ts} +56 -1
- package/dist/{brushstrokeRender-EELTV7U4.cjs → brushstrokeRender-JNHVEUFG.cjs} +29 -10
- package/dist/brushstrokeRender-JNHVEUFG.cjs.map +1 -0
- package/dist/{brushstrokeRender-LRV7GXGD.js → brushstrokeRender-SII6MG4R.js} +25 -6
- package/dist/brushstrokeRender-SII6MG4R.js.map +1 -0
- package/dist/{builtins-DMIsnNst.d.cts → builtins-Cc-bH-3U.d.cts} +3 -2
- package/dist/{builtins-B5-ipm5u.d.ts → builtins-ZU1GJnUA.d.ts} +3 -2
- package/dist/canvas/index.cjs +435 -38
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +206 -16
- package/dist/canvas/index.d.ts +206 -16
- package/dist/canvas/index.js +408 -11
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-MPQAO33O.js → chunk-A6KHMKI4.js} +3 -3
- package/dist/{chunk-V5YGPRCZ.cjs → chunk-BEGEWQHD.cjs} +41 -41
- package/dist/{chunk-V5YGPRCZ.cjs.map → chunk-BEGEWQHD.cjs.map} +1 -1
- package/dist/{chunk-N3FVUOZD.cjs → chunk-BJTCSLF6.cjs} +7 -7
- package/dist/{chunk-N3FVUOZD.cjs.map → chunk-BJTCSLF6.cjs.map} +1 -1
- package/dist/{chunk-7LQO6OHH.cjs → chunk-DDSO4HS7.cjs} +9 -5
- package/dist/chunk-DDSO4HS7.cjs.map +1 -0
- package/dist/{chunk-AKU2KQ47.cjs → chunk-DFSZO2B5.cjs} +70 -3
- package/dist/chunk-DFSZO2B5.cjs.map +1 -0
- package/dist/{chunk-WUDPFWAN.js → chunk-F7Q2NE2Y.js} +3 -3
- package/dist/{chunk-GUZ47CJM.cjs → chunk-IZ4WRXZA.cjs} +1 -1
- package/dist/{chunk-GUZ47CJM.cjs.map → chunk-IZ4WRXZA.cjs.map} +1 -1
- package/dist/{chunk-GLWZXQ4Q.js → chunk-KHNZ6MOU.js} +1 -1
- package/dist/chunk-KHNZ6MOU.js.map +1 -0
- package/dist/{chunk-GCJWMEYW.cjs → chunk-KSJLDRHK.cjs} +46 -46
- package/dist/{chunk-GCJWMEYW.cjs.map → chunk-KSJLDRHK.cjs.map} +1 -1
- package/dist/{chunk-2SDGZAJR.js → chunk-LSXXAJG3.js} +70 -3
- package/dist/chunk-LSXXAJG3.js.map +1 -0
- package/dist/{chunk-QQKTOA4U.cjs → chunk-ORE334I6.cjs} +132 -132
- package/dist/{chunk-QQKTOA4U.cjs.map → chunk-ORE334I6.cjs.map} +1 -1
- package/dist/{chunk-X6KTSFAE.js → chunk-Q4NBEVV5.js} +2 -2
- package/dist/{chunk-FPRIUR4T.js → chunk-ROZFX4QI.js} +3 -3
- package/dist/{chunk-J67OLQUQ.js → chunk-SVYE5HIM.js} +7 -3
- package/dist/chunk-SVYE5HIM.js.map +1 -0
- package/dist/{chunk-O5RVCDEC.cjs → chunk-XLUYXUBD.cjs} +88 -88
- package/dist/{chunk-O5RVCDEC.cjs.map → chunk-XLUYXUBD.cjs.map} +1 -1
- package/dist/{chunk-FG274FYT.js → chunk-YGJIER2R.js} +2 -2
- package/dist/commands/index.cjs +2 -2
- package/dist/commands/index.d.cts +3 -3
- package/dist/commands/index.d.ts +3 -3
- package/dist/commands/index.js +1 -1
- package/dist/effects/index.d.cts +6 -38
- package/dist/effects/index.d.ts +6 -38
- package/dist/evaluate-BbCeF6pt.d.ts +114 -0
- package/dist/evaluate-BsxYieLN.d.cts +114 -0
- package/dist/{export-Bp7ji2r4.d.cts → export-BkYQvV56.d.cts} +4 -4
- package/dist/{export-DVl4fWy5.d.cts → export-Cbr9IqpJ.d.cts} +1 -1
- package/dist/{export-C1s4eolZ.d.ts → export-ClPKUB-v.d.ts} +1 -1
- package/dist/{export-DAyPY94f.d.ts → export-DHrFJ8r_.d.ts} +4 -4
- package/dist/{helpers-i95Ob6Vi.d.cts → helpers-C5aAd44p.d.cts} +67 -4
- package/dist/{helpers-BBLlekuM.d.ts → helpers-CPWcK504.d.ts} +67 -4
- package/dist/image-editor/index.cjs +606 -606
- package/dist/image-editor/index.cjs.map +1 -1
- package/dist/image-editor/index.d.cts +12 -14
- package/dist/image-editor/index.d.ts +12 -14
- package/dist/image-editor/index.js +4 -4
- package/dist/{opentype-D80AVmMu.d.cts → opentype-BOewaGQx.d.cts} +1 -1
- package/dist/{opentype-14PDI5D2.d.ts → opentype-sQrF3Ry1.d.ts} +1 -1
- package/dist/paint/index.d.cts +2 -2
- package/dist/paint/index.d.ts +2 -2
- package/dist/paint-editor/index.cjs +9 -9
- package/dist/paint-editor/index.cjs.map +1 -1
- package/dist/paint-editor/index.d.cts +9 -11
- package/dist/paint-editor/index.d.ts +9 -11
- package/dist/paint-editor/index.js +4 -4
- package/dist/{pathfinder-DjISxkUv.d.ts → pathfinder-BwJx0_zM.d.ts} +2 -2
- package/dist/{pathfinder-C0UoFypx.d.cts → pathfinder-CnkW7zLI.d.cts} +2 -2
- package/dist/{player-cGLrngL_.d.ts → player-BK2kKbfd.d.ts} +1 -1
- package/dist/{player-CBtEoU2x.d.cts → player-CmbY3218.d.cts} +1 -1
- package/dist/pool-C7GtrL34.d.cts +34 -0
- package/dist/pool-CTrtciaN.d.ts +34 -0
- package/dist/{rand-CfinE-1c.d.cts → rand-DTXAssW1.d.cts} +4 -4
- package/dist/{rand-DtazXGOB.d.ts → rand-pQQ2sJTk.d.ts} +4 -4
- package/dist/{svg-DJKriJ4A.d.ts → svg-C4LlFnEw.d.cts} +2 -3
- package/dist/{svg-BkRL-fZJ.d.cts → svg-CUzZa0EO.d.ts} +2 -3
- package/dist/{tools-CM8Oe8F3.d.ts → tools-AugT22z3.d.ts} +1 -1
- package/dist/{tools-DZCv2kX1.d.cts → tools-BpCmUNxb.d.cts} +1 -1
- package/dist/vector/index.cjs +918 -918
- package/dist/vector/index.cjs.map +1 -1
- package/dist/vector/index.d.cts +11 -13
- package/dist/vector/index.d.ts +11 -13
- package/dist/vector/index.js +11 -11
- package/dist/video-editor/index.d.cts +6 -8
- package/dist/video-editor/index.d.ts +6 -8
- package/dist/{warp-k_PdtXOG.d.ts → warp-CIsO617e.d.ts} +1 -1
- package/dist/{warp-CH9MM435.d.cts → warp-D62N_5VK.d.cts} +1 -1
- package/package.json +1 -1
- package/skills/pixerate-canvas/SKILL.md +30 -2
- package/dist/behavior-Ymbld6jL.d.cts +0 -60
- package/dist/behavior-Ymbld6jL.d.ts +0 -60
- package/dist/brushstrokeRender-EELTV7U4.cjs.map +0 -1
- package/dist/brushstrokeRender-LRV7GXGD.js.map +0 -1
- package/dist/chunk-2SDGZAJR.js.map +0 -1
- package/dist/chunk-7LQO6OHH.cjs.map +0 -1
- package/dist/chunk-AKU2KQ47.cjs.map +0 -1
- package/dist/chunk-GLWZXQ4Q.js.map +0 -1
- package/dist/chunk-J67OLQUQ.js.map +0 -1
- package/dist/evaluate-2S3vSPLy.d.cts +0 -55
- package/dist/evaluate-CfmT6xA3.d.ts +0 -55
- package/dist/gradient-KDfCvhuj.d.cts +0 -66
- package/dist/gradient-KDfCvhuj.d.ts +0 -66
- /package/dist/{chunk-MPQAO33O.js.map → chunk-A6KHMKI4.js.map} +0 -0
- /package/dist/{chunk-WUDPFWAN.js.map → chunk-F7Q2NE2Y.js.map} +0 -0
- /package/dist/{chunk-X6KTSFAE.js.map → chunk-Q4NBEVV5.js.map} +0 -0
- /package/dist/{chunk-FPRIUR4T.js.map → chunk-ROZFX4QI.js.map} +0 -0
- /package/dist/{chunk-FG274FYT.js.map → chunk-YGJIER2R.js.map} +0 -0
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
1
|
+
import { a6 as MotionCommand, a7 as MotionShot, a8 as MotionScene, L as VectorNode, O as VectorBounds, a9 as MotionDirection, aa as MotionIrisShape, ab as MotionSplitOrientation, ac as MotionDriver, ad as MotionDrivenProperty, ae as MotionRect, af as MotionBeatGrid, ag as MotionCue, ah as MotionCamera, ai as MotionTextUnit, aj as MotionCascade, a4 as VectorDocument, ak as MotionBlur, al as MotionControl, am as MotionPreset, an as MotionClip, ao as FlairSvgMotion, ap as FlairVectorEffect, e as EffectValue, t as EffectVectorMotion, aq as MotionEffectSource, N as VectorGroupNode, v as EffectsSlot, E as EffectProvider, ar as FlairExportOptions, as as FlairMotionExport, at as FlairEffectOptions, au as FlairEffectDocument, av as MotionEnterStyle, aw as MotionExitStyle, ax as MotionCommandType, ay as MotionNarration } from '../helpers-C5aAd44p.cjs';
|
|
2
|
+
export { az as FLAIR_EASES, aA as FLAIR_EXPORT_VERSION, aB as FlairEase, aC as FlairEaseName, aD as FlairSpringEase, aE as FlairSvgAnimation, aF as MOTION_BLENDS, aG as MOTION_CAMERA_MS, aH as MOTION_CASCADES, aI as MOTION_CLIP_TARGET, aJ as MOTION_COMMAND_TYPES, aK as MOTION_DEFAULT_DURATIONS, aL as MOTION_DEFAULT_HOLD, aM as MOTION_DIRECTIONS, aN as MOTION_DRAW_MS_PER_UNIT, aO as MOTION_DRAW_RANGE, aP as MOTION_DRIVEN_PROPERTIES, aQ as MOTION_ENTER_STYLES, aR as MOTION_EXIT_STYLES, aS as MOTION_IRIS_SHAPES, aT as MOTION_REPEAT_MODES, aU as MOTION_SPLIT_ORIENTATIONS, aV as MOTION_TEXT_UNITS, aW as MOTION_TRIGGERS, aX as MotionColorPulseCommand, aY as MotionCommandBase, aZ as MotionDrawCommand, a_ as MotionDrawOrder, a$ as MotionEffectCommand, b0 as MotionEnterCommand, b1 as MotionExitCommand, b2 as MotionFadeCommand, b3 as MotionFollowCommand, b4 as MotionMatchCommand, b5 as MotionMorphCommand, b6 as MotionMoveCommand, b7 as MotionPlayCommand, b8 as MotionPulseCommand, b9 as MotionRotateCommand, ba as MotionScaleCommand, bb as MotionShakeCommand, bc as MotionStyleCommand, bd as MotionTeeterCommand, be as MotionTrigger, bf as MotionWaitCommand, bg as MotionWaveCommand, bh as MotionWiggleCommand, bi as flairAtLeast, bj as flairCurveFor, bk as flairEaseFor, bl as motionFlairPrimitive, bm as toFlairEffectDocument, bn as toFlairSvgMotion, bo as toFlairVectorEffect } from '../helpers-C5aAd44p.cjs';
|
|
3
|
+
import { f as MotionBehavior, b as AnimationLoopMode } from '../evaluate-BsxYieLN.cjs';
|
|
4
4
|
import { b as AnimationEasing } from '../easing-lM0Xo9Ni.cjs';
|
|
5
|
-
import { A as AffineMatrix, B as BezierPath } from '../bezier-
|
|
6
|
-
import { V as VectorSvgExportOptions } from '../svg-
|
|
5
|
+
import { A as AffineMatrix, B as BezierPath } from '../bezier-CvgQiYRg.cjs';
|
|
6
|
+
import { V as VectorSvgExportOptions } from '../svg-C4LlFnEw.cjs';
|
|
7
7
|
import { Z as ZipReadOptions } from '../zip-4nG0YAH7.cjs';
|
|
8
|
-
import { A as AnimationPlayer, C as Clock } from '../player-
|
|
9
|
-
import { b as AnimationLoopMode } from '../evaluate-2S3vSPLy.cjs';
|
|
8
|
+
import { A as AnimationPlayer, C as Clock } from '../player-CmbY3218.cjs';
|
|
10
9
|
import { H as HistoryManager } from '../HistoryManager-DeQQMBCj.cjs';
|
|
11
10
|
import { a as AgentToolProvider } from '../registry-BqA1AZt0.cjs';
|
|
12
11
|
import { J as JsonSchema } from '../schema-Di0CS6Pe.cjs';
|
|
13
|
-
import '../gradient-KDfCvhuj.cjs';
|
|
14
12
|
import '../types-CwMPoRMU.cjs';
|
|
15
|
-
import '../brushTypes-
|
|
13
|
+
import '../brushTypes-C7N3EBK7.cjs';
|
|
16
14
|
import '../types-DsiXGmjo.cjs';
|
|
17
15
|
|
|
18
16
|
/**
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
1
|
+
import { a6 as MotionCommand, a7 as MotionShot, a8 as MotionScene, L as VectorNode, O as VectorBounds, a9 as MotionDirection, aa as MotionIrisShape, ab as MotionSplitOrientation, ac as MotionDriver, ad as MotionDrivenProperty, ae as MotionRect, af as MotionBeatGrid, ag as MotionCue, ah as MotionCamera, ai as MotionTextUnit, aj as MotionCascade, a4 as VectorDocument, ak as MotionBlur, al as MotionControl, am as MotionPreset, an as MotionClip, ao as FlairSvgMotion, ap as FlairVectorEffect, e as EffectValue, t as EffectVectorMotion, aq as MotionEffectSource, N as VectorGroupNode, v as EffectsSlot, E as EffectProvider, ar as FlairExportOptions, as as FlairMotionExport, at as FlairEffectOptions, au as FlairEffectDocument, av as MotionEnterStyle, aw as MotionExitStyle, ax as MotionCommandType, ay as MotionNarration } from '../helpers-CPWcK504.js';
|
|
2
|
+
export { az as FLAIR_EASES, aA as FLAIR_EXPORT_VERSION, aB as FlairEase, aC as FlairEaseName, aD as FlairSpringEase, aE as FlairSvgAnimation, aF as MOTION_BLENDS, aG as MOTION_CAMERA_MS, aH as MOTION_CASCADES, aI as MOTION_CLIP_TARGET, aJ as MOTION_COMMAND_TYPES, aK as MOTION_DEFAULT_DURATIONS, aL as MOTION_DEFAULT_HOLD, aM as MOTION_DIRECTIONS, aN as MOTION_DRAW_MS_PER_UNIT, aO as MOTION_DRAW_RANGE, aP as MOTION_DRIVEN_PROPERTIES, aQ as MOTION_ENTER_STYLES, aR as MOTION_EXIT_STYLES, aS as MOTION_IRIS_SHAPES, aT as MOTION_REPEAT_MODES, aU as MOTION_SPLIT_ORIENTATIONS, aV as MOTION_TEXT_UNITS, aW as MOTION_TRIGGERS, aX as MotionColorPulseCommand, aY as MotionCommandBase, aZ as MotionDrawCommand, a_ as MotionDrawOrder, a$ as MotionEffectCommand, b0 as MotionEnterCommand, b1 as MotionExitCommand, b2 as MotionFadeCommand, b3 as MotionFollowCommand, b4 as MotionMatchCommand, b5 as MotionMorphCommand, b6 as MotionMoveCommand, b7 as MotionPlayCommand, b8 as MotionPulseCommand, b9 as MotionRotateCommand, ba as MotionScaleCommand, bb as MotionShakeCommand, bc as MotionStyleCommand, bd as MotionTeeterCommand, be as MotionTrigger, bf as MotionWaitCommand, bg as MotionWaveCommand, bh as MotionWiggleCommand, bi as flairAtLeast, bj as flairCurveFor, bk as flairEaseFor, bl as motionFlairPrimitive, bm as toFlairEffectDocument, bn as toFlairSvgMotion, bo as toFlairVectorEffect } from '../helpers-CPWcK504.js';
|
|
3
|
+
import { f as MotionBehavior, b as AnimationLoopMode } from '../evaluate-BbCeF6pt.js';
|
|
4
4
|
import { b as AnimationEasing } from '../easing-lM0Xo9Ni.js';
|
|
5
|
-
import { A as AffineMatrix, B as BezierPath } from '../bezier-
|
|
6
|
-
import { V as VectorSvgExportOptions } from '../svg-
|
|
5
|
+
import { A as AffineMatrix, B as BezierPath } from '../bezier-DP4NnJp3.js';
|
|
6
|
+
import { V as VectorSvgExportOptions } from '../svg-CUzZa0EO.js';
|
|
7
7
|
import { Z as ZipReadOptions } from '../zip-4nG0YAH7.js';
|
|
8
|
-
import { A as AnimationPlayer, C as Clock } from '../player-
|
|
9
|
-
import { b as AnimationLoopMode } from '../evaluate-CfmT6xA3.js';
|
|
8
|
+
import { A as AnimationPlayer, C as Clock } from '../player-BK2kKbfd.js';
|
|
10
9
|
import { H as HistoryManager } from '../HistoryManager-DWSLd6Tf.js';
|
|
11
10
|
import { a as AgentToolProvider } from '../registry-D-4fit9C.js';
|
|
12
11
|
import { J as JsonSchema } from '../schema-Di0CS6Pe.js';
|
|
13
|
-
import '../gradient-KDfCvhuj.js';
|
|
14
12
|
import '../types-CwMPoRMU.js';
|
|
15
|
-
import '../brushTypes-
|
|
13
|
+
import '../brushTypes-C7N3EBK7.js';
|
|
16
14
|
import '../types-DsiXGmjo.js';
|
|
17
15
|
|
|
18
16
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createVectorMorph
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-A6KHMKI4.js";
|
|
4
4
|
import {
|
|
5
5
|
MOTION_ISSUE_CODES,
|
|
6
6
|
motionIssue,
|
|
@@ -31,7 +31,15 @@ import {
|
|
|
31
31
|
vectorNodeBounds,
|
|
32
32
|
vectorPathWorldBezier,
|
|
33
33
|
vectorTextHasOutlines
|
|
34
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-ROZFX4QI.js";
|
|
35
|
+
import {
|
|
36
|
+
bezierPathLength,
|
|
37
|
+
bezierPathPointAtLength,
|
|
38
|
+
bezierPathToSvg,
|
|
39
|
+
toBezierPath,
|
|
40
|
+
transformBezierPath
|
|
41
|
+
} from "../chunk-YGJIER2R.js";
|
|
42
|
+
import "../chunk-KHNZ6MOU.js";
|
|
35
43
|
import {
|
|
36
44
|
EffectUnsupportedError,
|
|
37
45
|
EffectsSlot,
|
|
@@ -39,14 +47,6 @@ import {
|
|
|
39
47
|
isEffectError,
|
|
40
48
|
resolveEffectValues
|
|
41
49
|
} from "../chunk-QFSTQHZY.js";
|
|
42
|
-
import {
|
|
43
|
-
bezierPathLength,
|
|
44
|
-
bezierPathPointAtLength,
|
|
45
|
-
bezierPathToSvg,
|
|
46
|
-
toBezierPath,
|
|
47
|
-
transformBezierPath
|
|
48
|
-
} from "../chunk-FG274FYT.js";
|
|
49
|
-
import "../chunk-GLWZXQ4Q.js";
|
|
50
50
|
import "../chunk-4FX5ACVG.js";
|
|
51
51
|
import {
|
|
52
52
|
readZip
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Rect, X as XYPosition,
|
|
1
|
+
import { R as Rect, X as XYPosition, c as CanvasNode, d as CanvasNodeStyle } from './brushTypes-C7N3EBK7.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Canvas arrangement actions that have keyboard shortcuts.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { R as Rect, X as XYPosition,
|
|
1
|
+
import { R as Rect, X as XYPosition, c as CanvasNode, d as CanvasNodeStyle } from './brushTypes-C7N3EBK7.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Canvas arrangement actions that have keyboard shortcuts.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Point,
|
|
2
|
-
import { C as CanvasGradientDef, S as SvgGradientDef } from './
|
|
1
|
+
import { P as Point, e as CanvasBrushstroke } from './brushTypes-C7N3EBK7.cjs';
|
|
2
|
+
import { C as CanvasGradientDef, S as SvgGradientDef } from './helpers-C5aAd44p.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Polygon boolean operations (union, intersection, difference, xor and divide) on
|
|
@@ -110,7 +110,27 @@ declare function dividePolygons(operands: PolygonInput[], options?: PolygonBoole
|
|
|
110
110
|
*/
|
|
111
111
|
|
|
112
112
|
/** Paint shared by every shape kind. Colours are any CSS colour, preset name, or gradient definition. */
|
|
113
|
+
/**
|
|
114
|
+
* A provider effect (see `@pixerate/editor/effects`) drawn on a shape: `fill` paints the shape's
|
|
115
|
+
* inside with the effect (clipped to its outline), `overlay` draws it over the node's box. Kept,
|
|
116
|
+
* and not drawn, without an effects provider.
|
|
117
|
+
*/
|
|
118
|
+
interface CanvasShapeEffect {
|
|
119
|
+
/** The provider's effect id. */
|
|
120
|
+
effect: string;
|
|
121
|
+
provider?: string;
|
|
122
|
+
name?: string;
|
|
123
|
+
/** Control values (over the effect's defaults). */
|
|
124
|
+
values: Record<string, number | string | boolean | readonly number[]>;
|
|
125
|
+
mode: 'fill' | 'overlay';
|
|
126
|
+
/** 0–1 (default 1). */
|
|
127
|
+
opacity?: number;
|
|
128
|
+
/** Animated effects play while true (default true); false holds the first frame. */
|
|
129
|
+
playing?: boolean;
|
|
130
|
+
}
|
|
113
131
|
interface ShapePaint {
|
|
132
|
+
/** A provider effect drawn on the shape (see `CanvasShapeEffect`). */
|
|
133
|
+
effect?: CanvasShapeEffect;
|
|
114
134
|
fill?: string | CanvasGradientDef;
|
|
115
135
|
stroke?: string | CanvasGradientDef;
|
|
116
136
|
strokeWidth?: number;
|
|
@@ -486,4 +506,4 @@ declare function pointInBezierPath(input: BezierPathInput, point: Point, fillRul
|
|
|
486
506
|
/** Distance from `point` to the path outline (closing lines of closed subpaths included). */
|
|
487
507
|
declare function distanceToBezierPath(input: BezierPathInput | readonly BezierContour[], point: Point): number;
|
|
488
508
|
|
|
489
|
-
export {
|
|
509
|
+
export { parseSvgPath as $, type AffineMatrix as A, type BezierPath as B, type CanvasShapeEffect as C, bezierPathPointAtLength as D, type EllipseShape as E, type FlattenOptions as F, type GetShapeRenderDataOptions as G, bezierPathSignedArea as H, bezierPathToSvg as I, closeContour as J, contourSignedArea as K, contoursToPath as L, type MultiPolygon as M, countPathSegments as N, distanceToBezierPath as O, type PolygonBooleanOperation as P, dividePolygons as Q, type RectShape as R, type ShapeDescription as S, flattenSvgPath as T, formatNumber as U, getShapeRenderData as V, getShapeSvg as W, intersectPolygons as X, isShapeDescription as Y, multiPolygonArea as Z, multiPolygonBounds as _, type BezierPathInput as a, pathToContours as a0, pointInBezierPath as a1, pointInMultiPolygon as a2, pointInRings as a3, polygonArea as a4, polygonBoolean as a5, polygonToSvgPath as a6, ringSignedArea as a7, segmentBounds as a8, segmentCurvature as a9, segmentDerivative as aa, segmentExtrema as ab, segmentLength as ac, segmentNearest as ad, segmentParamAtLength as ae, segmentPoint as af, segmentTangent as ag, shapeToPolygon as ah, simplifyRing as ai, splitSegment as aj, subSegment as ak, subtractPolygons as al, toBezierPath as am, transformBezierPath as an, trimSegments as ao, unionPolygons as ap, windingNumber as aq, xorPolygons as ar, type PolygonFillRule as b, type BezierSegment as c, type BezierContour as d, type PolygonRing as e, type ShapeSize as f, type PathShape as g, type BezierCommand as h, type BezierPathToSvgOptions as i, type PathCommand as j, type PathPointAtLength as k, type PolygonBooleanOptions as l, type PolygonInput as m, type PolygonOperand as n, type PolygonPiece as o, type PolygonToPathOptions as p, type PolygonWithHoles as q, type RegularPolygonShape as r, SHAPE_KINDS as s, type ShapeKind as t, type ShapePaint as u, type ShapeRenderData as v, type StarShape as w, arcToCubics as x, bezierPathBounds as y, bezierPathLength as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as Point,
|
|
2
|
-
import { C as CanvasGradientDef, S as SvgGradientDef } from './
|
|
1
|
+
import { P as Point, e as CanvasBrushstroke } from './brushTypes-C7N3EBK7.js';
|
|
2
|
+
import { C as CanvasGradientDef, S as SvgGradientDef } from './helpers-CPWcK504.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Polygon boolean operations (union, intersection, difference, xor and divide) on
|
|
@@ -110,7 +110,27 @@ declare function dividePolygons(operands: PolygonInput[], options?: PolygonBoole
|
|
|
110
110
|
*/
|
|
111
111
|
|
|
112
112
|
/** Paint shared by every shape kind. Colours are any CSS colour, preset name, or gradient definition. */
|
|
113
|
+
/**
|
|
114
|
+
* A provider effect (see `@pixerate/editor/effects`) drawn on a shape: `fill` paints the shape's
|
|
115
|
+
* inside with the effect (clipped to its outline), `overlay` draws it over the node's box. Kept,
|
|
116
|
+
* and not drawn, without an effects provider.
|
|
117
|
+
*/
|
|
118
|
+
interface CanvasShapeEffect {
|
|
119
|
+
/** The provider's effect id. */
|
|
120
|
+
effect: string;
|
|
121
|
+
provider?: string;
|
|
122
|
+
name?: string;
|
|
123
|
+
/** Control values (over the effect's defaults). */
|
|
124
|
+
values: Record<string, number | string | boolean | readonly number[]>;
|
|
125
|
+
mode: 'fill' | 'overlay';
|
|
126
|
+
/** 0–1 (default 1). */
|
|
127
|
+
opacity?: number;
|
|
128
|
+
/** Animated effects play while true (default true); false holds the first frame. */
|
|
129
|
+
playing?: boolean;
|
|
130
|
+
}
|
|
113
131
|
interface ShapePaint {
|
|
132
|
+
/** A provider effect drawn on the shape (see `CanvasShapeEffect`). */
|
|
133
|
+
effect?: CanvasShapeEffect;
|
|
114
134
|
fill?: string | CanvasGradientDef;
|
|
115
135
|
stroke?: string | CanvasGradientDef;
|
|
116
136
|
strokeWidth?: number;
|
|
@@ -486,4 +506,4 @@ declare function pointInBezierPath(input: BezierPathInput, point: Point, fillRul
|
|
|
486
506
|
/** Distance from `point` to the path outline (closing lines of closed subpaths included). */
|
|
487
507
|
declare function distanceToBezierPath(input: BezierPathInput | readonly BezierContour[], point: Point): number;
|
|
488
508
|
|
|
489
|
-
export {
|
|
509
|
+
export { parseSvgPath as $, type AffineMatrix as A, type BezierPath as B, type CanvasShapeEffect as C, bezierPathPointAtLength as D, type EllipseShape as E, type FlattenOptions as F, type GetShapeRenderDataOptions as G, bezierPathSignedArea as H, bezierPathToSvg as I, closeContour as J, contourSignedArea as K, contoursToPath as L, type MultiPolygon as M, countPathSegments as N, distanceToBezierPath as O, type PolygonBooleanOperation as P, dividePolygons as Q, type RectShape as R, type ShapeDescription as S, flattenSvgPath as T, formatNumber as U, getShapeRenderData as V, getShapeSvg as W, intersectPolygons as X, isShapeDescription as Y, multiPolygonArea as Z, multiPolygonBounds as _, type BezierPathInput as a, pathToContours as a0, pointInBezierPath as a1, pointInMultiPolygon as a2, pointInRings as a3, polygonArea as a4, polygonBoolean as a5, polygonToSvgPath as a6, ringSignedArea as a7, segmentBounds as a8, segmentCurvature as a9, segmentDerivative as aa, segmentExtrema as ab, segmentLength as ac, segmentNearest as ad, segmentParamAtLength as ae, segmentPoint as af, segmentTangent as ag, shapeToPolygon as ah, simplifyRing as ai, splitSegment as aj, subSegment as ak, subtractPolygons as al, toBezierPath as am, transformBezierPath as an, trimSegments as ao, unionPolygons as ap, windingNumber as aq, xorPolygons as ar, type PolygonFillRule as b, type BezierSegment as c, type BezierContour as d, type PolygonRing as e, type ShapeSize as f, type PathShape as g, type BezierCommand as h, type BezierPathToSvgOptions as i, type PathCommand as j, type PathPointAtLength as k, type PolygonBooleanOptions as l, type PolygonInput as m, type PolygonOperand as n, type PolygonPiece as o, type PolygonToPathOptions as p, type PolygonWithHoles as q, type RegularPolygonShape as r, SHAPE_KINDS as s, type ShapeKind as t, type ShapePaint as u, type ShapeRenderData as v, type StarShape as w, arcToCubics as x, bezierPathBounds as y, bezierPathLength as z };
|
|
@@ -245,12 +245,67 @@ interface CanvasBrushSettings {
|
|
|
245
245
|
* tip settings give one.
|
|
246
246
|
*/
|
|
247
247
|
type CanvasBrush = string | CanvasBrushSettings;
|
|
248
|
+
/** A gradient stop of brushed stroke paint (the paint engine's `PaintGradientStop`). */
|
|
249
|
+
interface CanvasBrushPaintStop {
|
|
250
|
+
/** 0..1 along the gradient. */
|
|
251
|
+
offset: number;
|
|
252
|
+
/** `#rrggbb`, or `paint` (the stroke colour) / `secondary` (white). */
|
|
253
|
+
color: string;
|
|
254
|
+
/** 0..1 (default 1): multiplies the brush's flow where this colour is laid. */
|
|
255
|
+
opacity?: number;
|
|
256
|
+
/** Where between this stop and the next (0.05..0.95) the colours are half mixed (default 0.5). */
|
|
257
|
+
midpoint?: number;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* What moves a brushed stroke along its gradient. `distance` is in canvas units of the path
|
|
261
|
+
* (default 300, mirrored), so the colours keep their place at every zoom. Canvas strokes carry no
|
|
262
|
+
* timing, so the paint engine's `velocity` and `time` mappings are refused.
|
|
263
|
+
*/
|
|
264
|
+
type CanvasBrushPaintMapping = {
|
|
265
|
+
by: 'distance';
|
|
266
|
+
length?: number;
|
|
267
|
+
repeat?: 'clamp' | 'repeat' | 'mirror';
|
|
268
|
+
unit?: 'px' | 'dabs';
|
|
269
|
+
} | {
|
|
270
|
+
by: 'pressure';
|
|
271
|
+
} | {
|
|
272
|
+
by: 'tilt';
|
|
273
|
+
} | {
|
|
274
|
+
by: 'direction';
|
|
275
|
+
} | {
|
|
276
|
+
by: 'across-tip';
|
|
277
|
+
} | {
|
|
278
|
+
by: 'random';
|
|
279
|
+
every?: number;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* What a brushed stroke paints with, instead of its stroke colour (the paint engine's
|
|
283
|
+
* `PaintSource`, described structurally so the canvas types never import the paint engine): one
|
|
284
|
+
* colour, or gradient paint sampled dab by dab. The stroke colour still gives the alpha and fills
|
|
285
|
+
* `paint` stops.
|
|
286
|
+
*/
|
|
287
|
+
type CanvasBrushPaint = {
|
|
288
|
+
type: 'color';
|
|
289
|
+
color: string;
|
|
290
|
+
} | {
|
|
291
|
+
type: 'gradient';
|
|
292
|
+
/** 2..16 stops sorted by offset. */
|
|
293
|
+
stops: CanvasBrushPaintStop[];
|
|
294
|
+
/** How neighbouring stops mix (default `pigment`). */
|
|
295
|
+
space?: 'pigment' | 'oklab' | 'srgb';
|
|
296
|
+
/** Default: distance, 300 canvas units, mirror. */
|
|
297
|
+
map?: CanvasBrushPaintMapping;
|
|
298
|
+
/** 0 (hard steps) .. 1 (smooth, default). */
|
|
299
|
+
softness?: number;
|
|
300
|
+
};
|
|
248
301
|
/**
|
|
249
302
|
* What makes a path shape a brushed stroke: the brush, plus pen profiles spread evenly along the
|
|
250
303
|
* path's length (first value at the start, last at the end).
|
|
251
304
|
*/
|
|
252
305
|
interface CanvasBrushstroke {
|
|
253
306
|
brush: CanvasBrush;
|
|
307
|
+
/** Gradient paint (or one colour) instead of the stroke colour. */
|
|
308
|
+
paint?: CanvasBrushPaint;
|
|
254
309
|
/** Pressure 0..1 along the length (default full pressure). */
|
|
255
310
|
pressure?: number[];
|
|
256
311
|
/** Pointer Events pen tilt in degrees (−90..90) along the length. */
|
|
@@ -266,4 +321,4 @@ interface CanvasBrushPreset {
|
|
|
266
321
|
size: number;
|
|
267
322
|
}
|
|
268
323
|
|
|
269
|
-
export type { CanvasBrush as C, DirectionalDisplacementOptions as D, ExplodeNodeOptions as E, FanOutTrajectoryOptions as F, GraphDifferences as G, IncrementalLayoutOptions as I, NodeTransition as N, Point as P, Rect as R, Side as S, TrajectoryFunction as T, XYPosition as X,
|
|
324
|
+
export type { CanvasBrush as C, DirectionalDisplacementOptions as D, ExplodeNodeOptions as E, FanOutTrajectoryOptions as F, GraphDifferences as G, IncrementalLayoutOptions as I, NodeTransition as N, Point as P, Rect as R, Side as S, TrajectoryFunction as T, XYPosition as X, CanvasBrushPaint as a, CanvasBrushPreset as b, CanvasNode as c, CanvasNodeStyle as d, CanvasBrushstroke as e, CanvasEdge as f, CanvasLayoutOptions as g, PlaceBesideOptions as h, ReflowDisplacementOptions as i, CanvasClipboardPayload as j, Position as k, CanvasBrushPaintMapping as l, CanvasBrushPaintStop as m, CanvasBrushSettings as n, CanvasDockingCallbacks as o, CollapseNodeOptions as p, DisplacementDirection as q, DockStrategy as r, ExplosionSnapshot as s, TrajectoryPoint as t };
|
|
@@ -245,12 +245,67 @@ interface CanvasBrushSettings {
|
|
|
245
245
|
* tip settings give one.
|
|
246
246
|
*/
|
|
247
247
|
type CanvasBrush = string | CanvasBrushSettings;
|
|
248
|
+
/** A gradient stop of brushed stroke paint (the paint engine's `PaintGradientStop`). */
|
|
249
|
+
interface CanvasBrushPaintStop {
|
|
250
|
+
/** 0..1 along the gradient. */
|
|
251
|
+
offset: number;
|
|
252
|
+
/** `#rrggbb`, or `paint` (the stroke colour) / `secondary` (white). */
|
|
253
|
+
color: string;
|
|
254
|
+
/** 0..1 (default 1): multiplies the brush's flow where this colour is laid. */
|
|
255
|
+
opacity?: number;
|
|
256
|
+
/** Where between this stop and the next (0.05..0.95) the colours are half mixed (default 0.5). */
|
|
257
|
+
midpoint?: number;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* What moves a brushed stroke along its gradient. `distance` is in canvas units of the path
|
|
261
|
+
* (default 300, mirrored), so the colours keep their place at every zoom. Canvas strokes carry no
|
|
262
|
+
* timing, so the paint engine's `velocity` and `time` mappings are refused.
|
|
263
|
+
*/
|
|
264
|
+
type CanvasBrushPaintMapping = {
|
|
265
|
+
by: 'distance';
|
|
266
|
+
length?: number;
|
|
267
|
+
repeat?: 'clamp' | 'repeat' | 'mirror';
|
|
268
|
+
unit?: 'px' | 'dabs';
|
|
269
|
+
} | {
|
|
270
|
+
by: 'pressure';
|
|
271
|
+
} | {
|
|
272
|
+
by: 'tilt';
|
|
273
|
+
} | {
|
|
274
|
+
by: 'direction';
|
|
275
|
+
} | {
|
|
276
|
+
by: 'across-tip';
|
|
277
|
+
} | {
|
|
278
|
+
by: 'random';
|
|
279
|
+
every?: number;
|
|
280
|
+
};
|
|
281
|
+
/**
|
|
282
|
+
* What a brushed stroke paints with, instead of its stroke colour (the paint engine's
|
|
283
|
+
* `PaintSource`, described structurally so the canvas types never import the paint engine): one
|
|
284
|
+
* colour, or gradient paint sampled dab by dab. The stroke colour still gives the alpha and fills
|
|
285
|
+
* `paint` stops.
|
|
286
|
+
*/
|
|
287
|
+
type CanvasBrushPaint = {
|
|
288
|
+
type: 'color';
|
|
289
|
+
color: string;
|
|
290
|
+
} | {
|
|
291
|
+
type: 'gradient';
|
|
292
|
+
/** 2..16 stops sorted by offset. */
|
|
293
|
+
stops: CanvasBrushPaintStop[];
|
|
294
|
+
/** How neighbouring stops mix (default `pigment`). */
|
|
295
|
+
space?: 'pigment' | 'oklab' | 'srgb';
|
|
296
|
+
/** Default: distance, 300 canvas units, mirror. */
|
|
297
|
+
map?: CanvasBrushPaintMapping;
|
|
298
|
+
/** 0 (hard steps) .. 1 (smooth, default). */
|
|
299
|
+
softness?: number;
|
|
300
|
+
};
|
|
248
301
|
/**
|
|
249
302
|
* What makes a path shape a brushed stroke: the brush, plus pen profiles spread evenly along the
|
|
250
303
|
* path's length (first value at the start, last at the end).
|
|
251
304
|
*/
|
|
252
305
|
interface CanvasBrushstroke {
|
|
253
306
|
brush: CanvasBrush;
|
|
307
|
+
/** Gradient paint (or one colour) instead of the stroke colour. */
|
|
308
|
+
paint?: CanvasBrushPaint;
|
|
254
309
|
/** Pressure 0..1 along the length (default full pressure). */
|
|
255
310
|
pressure?: number[];
|
|
256
311
|
/** Pointer Events pen tilt in degrees (−90..90) along the length. */
|
|
@@ -266,4 +321,4 @@ interface CanvasBrushPreset {
|
|
|
266
321
|
size: number;
|
|
267
322
|
}
|
|
268
323
|
|
|
269
|
-
export type { CanvasBrush as C, DirectionalDisplacementOptions as D, ExplodeNodeOptions as E, FanOutTrajectoryOptions as F, GraphDifferences as G, IncrementalLayoutOptions as I, NodeTransition as N, Point as P, Rect as R, Side as S, TrajectoryFunction as T, XYPosition as X,
|
|
324
|
+
export type { CanvasBrush as C, DirectionalDisplacementOptions as D, ExplodeNodeOptions as E, FanOutTrajectoryOptions as F, GraphDifferences as G, IncrementalLayoutOptions as I, NodeTransition as N, Point as P, Rect as R, Side as S, TrajectoryFunction as T, XYPosition as X, CanvasBrushPaint as a, CanvasBrushPreset as b, CanvasNode as c, CanvasNodeStyle as d, CanvasBrushstroke as e, CanvasEdge as f, CanvasLayoutOptions as g, PlaceBesideOptions as h, ReflowDisplacementOptions as i, CanvasClipboardPayload as j, Position as k, CanvasBrushPaintMapping as l, CanvasBrushPaintStop as m, CanvasBrushSettings as n, CanvasDockingCallbacks as o, CollapseNodeOptions as p, DisplacementDirection as q, DockStrategy as r, ExplosionSnapshot as s, TrajectoryPoint as t };
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _chunkW4LNKTHTcjs = require('./chunk-W4LNKTHT.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkDDSO4HS7cjs = require('./chunk-DDSO4HS7.cjs');
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
var _chunk2YQONY6Gcjs = require('./chunk-2YQONY6G.cjs');
|
|
@@ -12,7 +12,9 @@ var _chunk2YQONY6Gcjs = require('./chunk-2YQONY6G.cjs');
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
var _chunkZ6OUCS2Kcjs = require('./chunk-Z6OUCS2K.cjs');
|
|
15
|
-
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
var _chunk6GFRKLLScjs = require('./chunk-6GFRKLLS.cjs');
|
|
16
18
|
require('./chunk-SYPFUL5B.cjs');
|
|
17
19
|
require('./chunk-J5BA3BQ6.cjs');
|
|
18
20
|
require('./chunk-DCLJNVZS.cjs');
|
|
@@ -21,7 +23,7 @@ require('./chunk-643B2HKC.cjs');
|
|
|
21
23
|
|
|
22
24
|
|
|
23
25
|
|
|
24
|
-
var
|
|
26
|
+
var _chunkIZ4WRXZAcjs = require('./chunk-IZ4WRXZA.cjs');
|
|
25
27
|
|
|
26
28
|
// src/canvas/brushstrokeRender.ts
|
|
27
29
|
var DRY = _chunkW4LNKTHTcjs.BUILTIN_BRUSHES.filter((b) => _chunkZ6OUCS2Kcjs.isBrushstrokeBrush.call(void 0, b));
|
|
@@ -44,8 +46,23 @@ function resolveCanvasBrush(brush, width) {
|
|
|
44
46
|
}
|
|
45
47
|
return { size, ...brush };
|
|
46
48
|
}
|
|
49
|
+
function resolveCanvasPaint(paint) {
|
|
50
|
+
const source = _chunk6GFRKLLScjs.parsePaintSource.call(void 0, paint, "paint");
|
|
51
|
+
if (source.type === "gradient" && (source.map.by === "velocity" || source.map.by === "time")) {
|
|
52
|
+
throw new Error(`paint.map.by "${source.map.by}" needs timed samples, which canvas strokes do not record; use distance, pressure, tilt, direction, across-tip or random.`);
|
|
53
|
+
}
|
|
54
|
+
return source;
|
|
55
|
+
}
|
|
56
|
+
function shapePaint(shape) {
|
|
57
|
+
if (shape.brush.paint === void 0 || shape.brush.paint === null) return null;
|
|
58
|
+
try {
|
|
59
|
+
return resolveCanvasPaint(shape.brush.paint);
|
|
60
|
+
} catch (e) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
47
64
|
function strokeColor(shape) {
|
|
48
|
-
const gradient =
|
|
65
|
+
const gradient = _chunkIZ4WRXZAcjs.resolveCanvasGradient.call(void 0, _nullishCoalesce(shape.strokeGradient, () => ( shape.stroke)));
|
|
49
66
|
const css = gradient ? _nullishCoalesce(_optionalChain([gradient, 'access', _ => _.stops, 'access', _2 => _2[0], 'optionalAccess', _3 => _3.color]), () => ( "#000")) : typeof shape.stroke === "string" && shape.stroke !== "none" ? shape.stroke : "#000";
|
|
50
67
|
const parsed = _nullishCoalesce(_chunk2YQONY6Gcjs.parseCssColor.call(void 0, css), () => ( { hex: "#000000", alpha: 1 }));
|
|
51
68
|
const n = parseInt(parsed.hex.slice(1), 16);
|
|
@@ -55,7 +72,7 @@ var cache = new (0, _chunkZ6OUCS2Kcjs.BrushstrokeCache)(128);
|
|
|
55
72
|
var urls = /* @__PURE__ */ new WeakMap();
|
|
56
73
|
function renderShapeBrushstrokeNow(shape, scale) {
|
|
57
74
|
const brush = resolveCanvasBrush(shape.brush.brush, _nullishCoalesce(shape.strokeWidth, () => ( 3)));
|
|
58
|
-
const points =
|
|
75
|
+
const points = _chunkDDSO4HS7cjs.pathDataToPolyline.call(void 0, shape.d);
|
|
59
76
|
if (!points.length) return null;
|
|
60
77
|
const { pressure, tiltX, tiltY } = shape.brush;
|
|
61
78
|
const input = {
|
|
@@ -64,7 +81,8 @@ function renderShapeBrushstrokeNow(shape, scale) {
|
|
|
64
81
|
..._optionalChain([tiltX, 'optionalAccess', _5 => _5.length]) ? { tiltX } : {},
|
|
65
82
|
..._optionalChain([tiltY, 'optionalAccess', _6 => _6.length]) ? { tiltY } : {}
|
|
66
83
|
};
|
|
67
|
-
const
|
|
84
|
+
const paint = shapePaint(shape);
|
|
85
|
+
const stroke = cache.render(input, brush, { scale, color: strokeColor(shape), ...paint ? { paint } : {} });
|
|
68
86
|
if (!stroke.bounds) return null;
|
|
69
87
|
let href = urls.get(stroke);
|
|
70
88
|
if (href === void 0) {
|
|
@@ -75,9 +93,9 @@ function renderShapeBrushstrokeNow(shape, scale) {
|
|
|
75
93
|
}
|
|
76
94
|
var escapeAttr = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
77
95
|
function brushedShapeSvgNow(shape, size, scale) {
|
|
78
|
-
const f = (n) =>
|
|
96
|
+
const f = (n) => _chunkIZ4WRXZAcjs.formatNumber.call(void 0, n, 3);
|
|
79
97
|
const image = renderShapeBrushstrokeNow(shape, scale);
|
|
80
|
-
const svg =
|
|
98
|
+
const svg = _chunkIZ4WRXZAcjs.getShapeSvg.call(void 0, shape, size);
|
|
81
99
|
const body = image ? `<image href="${escapeAttr(image.href)}" x="${f(image.x)}" y="${f(image.y)}" width="${f(image.width)}" height="${f(image.height)}" preserveAspectRatio="none"${shape.opacity !== void 0 ? ` opacity="${f(shape.opacity)}"` : ""}/>` : "";
|
|
82
100
|
const content = svg.transform && body ? `<g transform="${svg.transform}">${body}</g>` : body;
|
|
83
101
|
return `<svg xmlns="http://www.w3.org/2000/svg" width="${f(size.width)}" height="${f(size.height)}" viewBox="0 0 ${f(size.width)} ${f(size.height)}">${content}</svg>`;
|
|
@@ -87,5 +105,6 @@ function brushedShapeSvgNow(shape, size, scale) {
|
|
|
87
105
|
|
|
88
106
|
|
|
89
107
|
|
|
90
|
-
|
|
91
|
-
|
|
108
|
+
|
|
109
|
+
exports.brushedShapeSvgNow = brushedShapeSvgNow; exports.listCanvasBrushes = listCanvasBrushes; exports.renderShapeBrushstrokeNow = renderShapeBrushstrokeNow; exports.resolveCanvasBrush = resolveCanvasBrush; exports.resolveCanvasPaint = resolveCanvasPaint;
|
|
110
|
+
//# sourceMappingURL=brushstrokeRender-JNHVEUFG.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/brushstrokeRender-JNHVEUFG.cjs","../src/canvas/brushstrokeRender.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACdA,IAAM,IAAA,EAAM,iCAAA,CAAgB,MAAA,CAAO,CAAC,CAAA,EAAA,GAAM,kDAAA,CAAoB,CAAC,CAAA;AAExD,SAAS,iBAAA,CAAA,EAAyC;AACxD,EAAA,OAAO,GAAA,CAAI,GAAA,CAAI,CAAC,CAAA,EAAA,GAAA,CAAO,EAAE,EAAA,EAAI,CAAA,CAAE,EAAA,EAAI,IAAA,EAAM,CAAA,CAAE,IAAA,EAAM,QAAA,EAAU,CAAA,CAAE,QAAA,EAAU,IAAA,EAAM,CAAA,CAAE,GAAA,CAAI,KAAK,CAAA,CAAE,CAAA;AAC3F;AAGO,SAAS,kBAAA,CAAmB,KAAA,EAAoB,KAAA,EAAiC;AACvF,EAAA,MAAM,KAAA,EAAO,IAAA,CAAK,GAAA,CAAI,CAAA,EAAG,MAAA,CAAO,QAAA,CAAS,KAAK,EAAA,EAAI,MAAA,EAAQ,CAAC,CAAA;AAC3D,EAAA,GAAA,CAAI,OAAO,MAAA,IAAU,QAAA,EAAU;AAC9B,IAAA,MAAM,OAAA,EAAS,iCAAA,CAAgB,IAAA,CAAK,CAAC,CAAA,EAAA,GAAM,CAAA,CAAE,GAAA,IAAO,KAAK,CAAA;AACzD,IAAA,MAAM,IAAA,EAA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AA,MAAM,QAAA,EAAU,GAAA,CAAI,UAAA,GAAa,KAAA,EAAO,CAAA,cAAA,EAAiB,GAAA,CAAI,SAAS,CAAA,EAAA,EAAK,IAAI,CAAA,IAAA,EAAA,EAAS,IAAA;AACxF,EAAA,OAAO,CAAA,+CAAA,EAAkD,CAAA,CAAE,IAAA,CAAK,KAAK,CAAC,CAAA,UAAA,EAAa,CAAA,CAAE,IAAA,CAAK,MAAM,CAAC,CAAA,eAAA,EAAkB,CAAA,CAAE,IAAA,CAAK,KAAK,CAAC,CAAA,CAAA,EAAI,CAAA,CAAE,IAAA,CAAK,MAAM,CAAC,CAAA,EAAA,EAAK,OAAO,CAAA,MAAA,CAAA;AAC/J;ADLA;AACE;AACA;AACA;AACA;AACA;AACF,gQAAC","file":"/home/runner/work/editor/editor/packages/core/dist/brushstrokeRender-JNHVEUFG.cjs","sourcesContent":[null,"/**\n * The lazily loaded half of brushed freehand strokes (`./brushstroke.ts` imports it on first use):\n * the paint engine's dry brushstroke renderer, the paint presets and a CSS colour parser. Keep\n * every import of the paint engine in this file, so the canvas entry never reaches it statically.\n */\nimport { BrushstrokeCache, brushstrokeDataUrl, isBrushstrokeBrush, type BrushstrokeBrush, type BrushstrokeImage } from '../paint/brushstroke.js';\nimport { parsePaintSource, type PaintSource } from '../paint/gradient-paint.js';\nimport { BUILTIN_BRUSHES } from '../paint-editor/brushes.js';\nimport { parseCssColor } from '../image-editor/layers/css-color.js';\nimport { resolveCanvasGradient } from './gradient.js';\nimport { formatNumber, getShapeSvg, type ShapeSize } from './shapeGeometry.js';\nimport { pathDataToPolyline, type BrushedPathShape, type CanvasBrush, type CanvasBrushPaint, type CanvasBrushPreset, type CanvasBrushstrokeImage } from './brushstroke.js';\n\nconst DRY = BUILTIN_BRUSHES.filter((b) => isBrushstrokeBrush(b));\n\nexport function listCanvasBrushes(): CanvasBrushPreset[] {\n\treturn DRY.map((b) => ({ id: b.id, name: b.name, category: b.category, size: b.tip.size }));\n}\n\n/** The paint engine brush for a canvas brush at stroke width `width`; throws with the usable ids. */\nexport function resolveCanvasBrush(brush: CanvasBrush, width: number): BrushstrokeBrush {\n\tconst size = Math.max(1, Number.isFinite(width) ? width : 1);\n\tif (typeof brush === 'string') {\n\t\tconst preset = BUILTIN_BRUSHES.find((b) => b.id === brush);\n\t\tconst ids = DRY.map((b) => b.id).join(', ');\n\t\tif (!preset) throw new Error(`Unknown brush '${brush}'. Use one of the dry paint presets (${ids}) or tip settings ({ hardness, spacing, flow, … }).`);\n\t\tif (!isBrushstrokeBrush(preset)) {\n\t\t\tthrow new Error(`Brush '${brush}' (${preset.name}) is not a dry brush: brushed canvas strokes use dry media only (wet paint needs an area to flow in; mixer, blender, smudge and eraser brushes need paint under them). Use one of: ${ids}.`);\n\t\t}\n\t\treturn { ...preset, tip: { ...preset.tip, size } };\n\t}\n\tif (!brush || typeof brush !== 'object' || Array.isArray(brush)) {\n\t\tthrow new Error('A brush is a dry paint preset id (see listCanvasBrushes / canvas.listBrushes) or an object of tip settings.');\n\t}\n\treturn { size, ...brush };\n}\n\n/**\n * The paint engine's `PaintSource` for a brushed stroke's `paint`; throws with what is wrong.\n * Mappings that need timed samples (`velocity`, `time`) are refused: canvas strokes carry no timing.\n */\nexport function resolveCanvasPaint(paint: CanvasBrushPaint | unknown): PaintSource {\n\tconst source = parsePaintSource(paint, 'paint');\n\tif (source.type === 'gradient' && (source.map.by === 'velocity' || source.map.by === 'time')) {\n\t\tthrow new Error(`paint.map.by \"${source.map.by}\" needs timed samples, which canvas strokes do not record; use distance, pressure, tilt, direction, across-tip or random.`);\n\t}\n\treturn source;\n}\n\n/** A stored stroke's paint, or null when it has none or it is not valid paint (the stroke colour is used then). */\nfunction shapePaint(shape: BrushedPathShape): PaintSource | null {\n\tif (shape.brush.paint === undefined || shape.brush.paint === null) return null;\n\ttry {\n\t\treturn resolveCanvasPaint(shape.brush.paint);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * RGBA of a shape's stroke paint: with `brush.paint` its alpha and the colour of `paint` stops.\n * A canvas gradient stroke without `brush.paint` uses its first stop.\n */\nfunction strokeColor(shape: BrushedPathShape): [number, number, number, number] {\n\tconst gradient = resolveCanvasGradient(shape.strokeGradient ?? shape.stroke);\n\tconst css = gradient ? (gradient.stops[0]?.color ?? '#000') : typeof shape.stroke === 'string' && shape.stroke !== 'none' ? shape.stroke : '#000';\n\tconst parsed = parseCssColor(css) ?? { hex: '#000000', alpha: 1 };\n\tconst n = parseInt(parsed.hex.slice(1), 16);\n\treturn [(n >> 16) & 255, (n >> 8) & 255, n & 255, Math.round(parsed.alpha * 255)];\n}\n\nconst cache = new BrushstrokeCache(128);\nconst urls = new WeakMap<BrushstrokeImage, string>();\n\nexport function renderShapeBrushstrokeNow(shape: BrushedPathShape, scale: number): CanvasBrushstrokeImage | null {\n\tconst brush = resolveCanvasBrush(shape.brush.brush, shape.strokeWidth ?? 3);\n\tconst points = pathDataToPolyline(shape.d);\n\tif (!points.length) return null;\n\tconst { pressure, tiltX, tiltY } = shape.brush;\n\tconst input = {\n\t\tpoints: points.map(([x, y]) => ({ x, y })),\n\t\t...(pressure?.length ? { pressure } : {}),\n\t\t...(tiltX?.length ? { tiltX } : {}),\n\t\t...(tiltY?.length ? { tiltY } : {})\n\t};\n\tconst paint = shapePaint(shape);\n\tconst stroke = cache.render(input, brush, { scale, color: strokeColor(shape), ...(paint ? { paint } : {}) });\n\tif (!stroke.bounds) return null;\n\tlet href = urls.get(stroke);\n\tif (href === undefined) {\n\t\thref = brushstrokeDataUrl(stroke);\n\t\turls.set(stroke, href);\n\t}\n\treturn { href, ...stroke.bounds, scale: stroke.scale };\n}\n\nconst escapeAttr = (s: string) => s.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<');\n\nexport function brushedShapeSvgNow(shape: BrushedPathShape, size: ShapeSize, scale: number): string {\n\tconst f = (n: number) => formatNumber(n, 3);\n\tconst image = renderShapeBrushstrokeNow(shape, scale);\n\tconst svg = getShapeSvg(shape, size);\n\tconst body = image\n\t\t? `<image href=\"${escapeAttr(image.href)}\" x=\"${f(image.x)}\" y=\"${f(image.y)}\" width=\"${f(image.width)}\" height=\"${f(image.height)}\" preserveAspectRatio=\"none\"${shape.opacity !== undefined ? ` opacity=\"${f(shape.opacity)}\"` : ''}/>`\n\t\t: '';\n\tconst content = svg.transform && body ? `<g transform=\"${svg.transform}\">${body}</g>` : body;\n\treturn `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${f(size.width)}\" height=\"${f(size.height)}\" viewBox=\"0 0 ${f(size.width)} ${f(size.height)}\">${content}</svg>`;\n}\n"]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-UYQUPUR6.js";
|
|
4
4
|
import {
|
|
5
5
|
pathDataToPolyline
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-SVYE5HIM.js";
|
|
7
7
|
import {
|
|
8
8
|
parseCssColor
|
|
9
9
|
} from "./chunk-CTTF4KYV.js";
|
|
@@ -12,7 +12,9 @@ import {
|
|
|
12
12
|
brushstrokeDataUrl,
|
|
13
13
|
isBrushstrokeBrush
|
|
14
14
|
} from "./chunk-64PYNEHJ.js";
|
|
15
|
-
import
|
|
15
|
+
import {
|
|
16
|
+
parsePaintSource
|
|
17
|
+
} from "./chunk-EM3FMJWE.js";
|
|
16
18
|
import "./chunk-63AZAUSN.js";
|
|
17
19
|
import "./chunk-BR7EKQUP.js";
|
|
18
20
|
import "./chunk-7QN76ESJ.js";
|
|
@@ -21,7 +23,7 @@ import {
|
|
|
21
23
|
formatNumber,
|
|
22
24
|
getShapeSvg,
|
|
23
25
|
resolveCanvasGradient
|
|
24
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-KHNZ6MOU.js";
|
|
25
27
|
|
|
26
28
|
// src/canvas/brushstrokeRender.ts
|
|
27
29
|
var DRY = BUILTIN_BRUSHES.filter((b) => isBrushstrokeBrush(b));
|
|
@@ -44,6 +46,21 @@ function resolveCanvasBrush(brush, width) {
|
|
|
44
46
|
}
|
|
45
47
|
return { size, ...brush };
|
|
46
48
|
}
|
|
49
|
+
function resolveCanvasPaint(paint) {
|
|
50
|
+
const source = parsePaintSource(paint, "paint");
|
|
51
|
+
if (source.type === "gradient" && (source.map.by === "velocity" || source.map.by === "time")) {
|
|
52
|
+
throw new Error(`paint.map.by "${source.map.by}" needs timed samples, which canvas strokes do not record; use distance, pressure, tilt, direction, across-tip or random.`);
|
|
53
|
+
}
|
|
54
|
+
return source;
|
|
55
|
+
}
|
|
56
|
+
function shapePaint(shape) {
|
|
57
|
+
if (shape.brush.paint === void 0 || shape.brush.paint === null) return null;
|
|
58
|
+
try {
|
|
59
|
+
return resolveCanvasPaint(shape.brush.paint);
|
|
60
|
+
} catch {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
47
64
|
function strokeColor(shape) {
|
|
48
65
|
const gradient = resolveCanvasGradient(shape.strokeGradient ?? shape.stroke);
|
|
49
66
|
const css = gradient ? gradient.stops[0]?.color ?? "#000" : typeof shape.stroke === "string" && shape.stroke !== "none" ? shape.stroke : "#000";
|
|
@@ -64,7 +81,8 @@ function renderShapeBrushstrokeNow(shape, scale) {
|
|
|
64
81
|
...tiltX?.length ? { tiltX } : {},
|
|
65
82
|
...tiltY?.length ? { tiltY } : {}
|
|
66
83
|
};
|
|
67
|
-
const
|
|
84
|
+
const paint = shapePaint(shape);
|
|
85
|
+
const stroke = cache.render(input, brush, { scale, color: strokeColor(shape), ...paint ? { paint } : {} });
|
|
68
86
|
if (!stroke.bounds) return null;
|
|
69
87
|
let href = urls.get(stroke);
|
|
70
88
|
if (href === void 0) {
|
|
@@ -86,6 +104,7 @@ export {
|
|
|
86
104
|
brushedShapeSvgNow,
|
|
87
105
|
listCanvasBrushes,
|
|
88
106
|
renderShapeBrushstrokeNow,
|
|
89
|
-
resolveCanvasBrush
|
|
107
|
+
resolveCanvasBrush,
|
|
108
|
+
resolveCanvasPaint
|
|
90
109
|
};
|
|
91
|
-
//# sourceMappingURL=brushstrokeRender-
|
|
110
|
+
//# sourceMappingURL=brushstrokeRender-SII6MG4R.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/canvas/brushstrokeRender.ts"],"sourcesContent":["/**\n * The lazily loaded half of brushed freehand strokes (`./brushstroke.ts` imports it on first use):\n * the paint engine's dry brushstroke renderer, the paint presets and a CSS colour parser. Keep\n * every import of the paint engine in this file, so the canvas entry never reaches it statically.\n */\nimport { BrushstrokeCache, brushstrokeDataUrl, isBrushstrokeBrush, type BrushstrokeBrush, type BrushstrokeImage } from '../paint/brushstroke.js';\nimport { parsePaintSource, type PaintSource } from '../paint/gradient-paint.js';\nimport { BUILTIN_BRUSHES } from '../paint-editor/brushes.js';\nimport { parseCssColor } from '../image-editor/layers/css-color.js';\nimport { resolveCanvasGradient } from './gradient.js';\nimport { formatNumber, getShapeSvg, type ShapeSize } from './shapeGeometry.js';\nimport { pathDataToPolyline, type BrushedPathShape, type CanvasBrush, type CanvasBrushPaint, type CanvasBrushPreset, type CanvasBrushstrokeImage } from './brushstroke.js';\n\nconst DRY = BUILTIN_BRUSHES.filter((b) => isBrushstrokeBrush(b));\n\nexport function listCanvasBrushes(): CanvasBrushPreset[] {\n\treturn DRY.map((b) => ({ id: b.id, name: b.name, category: b.category, size: b.tip.size }));\n}\n\n/** The paint engine brush for a canvas brush at stroke width `width`; throws with the usable ids. */\nexport function resolveCanvasBrush(brush: CanvasBrush, width: number): BrushstrokeBrush {\n\tconst size = Math.max(1, Number.isFinite(width) ? width : 1);\n\tif (typeof brush === 'string') {\n\t\tconst preset = BUILTIN_BRUSHES.find((b) => b.id === brush);\n\t\tconst ids = DRY.map((b) => b.id).join(', ');\n\t\tif (!preset) throw new Error(`Unknown brush '${brush}'. Use one of the dry paint presets (${ids}) or tip settings ({ hardness, spacing, flow, … }).`);\n\t\tif (!isBrushstrokeBrush(preset)) {\n\t\t\tthrow new Error(`Brush '${brush}' (${preset.name}) is not a dry brush: brushed canvas strokes use dry media only (wet paint needs an area to flow in; mixer, blender, smudge and eraser brushes need paint under them). Use one of: ${ids}.`);\n\t\t}\n\t\treturn { ...preset, tip: { ...preset.tip, size } };\n\t}\n\tif (!brush || typeof brush !== 'object' || Array.isArray(brush)) {\n\t\tthrow new Error('A brush is a dry paint preset id (see listCanvasBrushes / canvas.listBrushes) or an object of tip settings.');\n\t}\n\treturn { size, ...brush };\n}\n\n/**\n * The paint engine's `PaintSource` for a brushed stroke's `paint`; throws with what is wrong.\n * Mappings that need timed samples (`velocity`, `time`) are refused: canvas strokes carry no timing.\n */\nexport function resolveCanvasPaint(paint: CanvasBrushPaint | unknown): PaintSource {\n\tconst source = parsePaintSource(paint, 'paint');\n\tif (source.type === 'gradient' && (source.map.by === 'velocity' || source.map.by === 'time')) {\n\t\tthrow new Error(`paint.map.by \"${source.map.by}\" needs timed samples, which canvas strokes do not record; use distance, pressure, tilt, direction, across-tip or random.`);\n\t}\n\treturn source;\n}\n\n/** A stored stroke's paint, or null when it has none or it is not valid paint (the stroke colour is used then). */\nfunction shapePaint(shape: BrushedPathShape): PaintSource | null {\n\tif (shape.brush.paint === undefined || shape.brush.paint === null) return null;\n\ttry {\n\t\treturn resolveCanvasPaint(shape.brush.paint);\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/**\n * RGBA of a shape's stroke paint: with `brush.paint` its alpha and the colour of `paint` stops.\n * A canvas gradient stroke without `brush.paint` uses its first stop.\n */\nfunction strokeColor(shape: BrushedPathShape): [number, number, number, number] {\n\tconst gradient = resolveCanvasGradient(shape.strokeGradient ?? shape.stroke);\n\tconst css = gradient ? (gradient.stops[0]?.color ?? '#000') : typeof shape.stroke === 'string' && shape.stroke !== 'none' ? shape.stroke : '#000';\n\tconst parsed = parseCssColor(css) ?? { hex: '#000000', alpha: 1 };\n\tconst n = parseInt(parsed.hex.slice(1), 16);\n\treturn [(n >> 16) & 255, (n >> 8) & 255, n & 255, Math.round(parsed.alpha * 255)];\n}\n\nconst cache = new BrushstrokeCache(128);\nconst urls = new WeakMap<BrushstrokeImage, string>();\n\nexport function renderShapeBrushstrokeNow(shape: BrushedPathShape, scale: number): CanvasBrushstrokeImage | null {\n\tconst brush = resolveCanvasBrush(shape.brush.brush, shape.strokeWidth ?? 3);\n\tconst points = pathDataToPolyline(shape.d);\n\tif (!points.length) return null;\n\tconst { pressure, tiltX, tiltY } = shape.brush;\n\tconst input = {\n\t\tpoints: points.map(([x, y]) => ({ x, y })),\n\t\t...(pressure?.length ? { pressure } : {}),\n\t\t...(tiltX?.length ? { tiltX } : {}),\n\t\t...(tiltY?.length ? { tiltY } : {})\n\t};\n\tconst paint = shapePaint(shape);\n\tconst stroke = cache.render(input, brush, { scale, color: strokeColor(shape), ...(paint ? { paint } : {}) });\n\tif (!stroke.bounds) return null;\n\tlet href = urls.get(stroke);\n\tif (href === undefined) {\n\t\thref = brushstrokeDataUrl(stroke);\n\t\turls.set(stroke, href);\n\t}\n\treturn { href, ...stroke.bounds, scale: stroke.scale };\n}\n\nconst escapeAttr = (s: string) => s.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<');\n\nexport function brushedShapeSvgNow(shape: BrushedPathShape, size: ShapeSize, scale: number): string {\n\tconst f = (n: number) => formatNumber(n, 3);\n\tconst image = renderShapeBrushstrokeNow(shape, scale);\n\tconst svg = getShapeSvg(shape, size);\n\tconst body = image\n\t\t? `<image href=\"${escapeAttr(image.href)}\" x=\"${f(image.x)}\" y=\"${f(image.y)}\" width=\"${f(image.width)}\" height=\"${f(image.height)}\" preserveAspectRatio=\"none\"${shape.opacity !== undefined ? ` opacity=\"${f(shape.opacity)}\"` : ''}/>`\n\t\t: '';\n\tconst content = svg.transform && body ? `<g transform=\"${svg.transform}\">${body}</g>` : body;\n\treturn `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${f(size.width)}\" height=\"${f(size.height)}\" viewBox=\"0 0 ${f(size.width)} ${f(size.height)}\">${content}</svg>`;\n}\n"],"mappings":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as DistributeMode, Z as ZOrderOperation } from './arrange-
|
|
3
|
-
import { C as CanvasBrush, a as CanvasBrushPreset } from './brushTypes-
|
|
2
|
+
import { C as CanvasArrangeAction, A as AlignEdge, D as DistributeAxis, a as DistributeMode, Z as ZOrderOperation } from './arrange-CKXK_hf7.cjs';
|
|
3
|
+
import { C as CanvasBrush, a as CanvasBrushPaint, b as CanvasBrushPreset } from './brushTypes-C7N3EBK7.cjs';
|
|
4
4
|
import { S as ShortcutBinding, C as CommandSpec, K as KeyboardEventLike, P as Platform } from './registry-CaR7LC6W.cjs';
|
|
5
5
|
|
|
6
6
|
/** Minimal history surface (`HistoryManager` satisfies it). */
|
|
@@ -104,6 +104,7 @@ interface DrawCommandTarget {
|
|
|
104
104
|
width?: number;
|
|
105
105
|
opacity?: number;
|
|
106
106
|
brush?: CanvasBrush;
|
|
107
|
+
paint?: CanvasBrushPaint;
|
|
107
108
|
};
|
|
108
109
|
pressure?: readonly number[];
|
|
109
110
|
tiltX?: readonly number[];
|