@overtone-art/canvas-editor-core 0.8.4 → 0.8.6
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/index.d.mts +9 -69
- package/dist/index.d.ts +9 -69
- package/dist/index.global.js +53 -53
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +294 -123
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +282 -111
- package/dist/index.mjs.map +1 -1
- package/dist/node.d.mts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/{types-BeaEHTFc.d.mts → types-F2GH3dcU.d.mts} +73 -2
- package/dist/{types-BeaEHTFc.d.ts → types-F2GH3dcU.d.ts} +73 -2
- package/package.json +1 -1
package/dist/node.d.mts
CHANGED
package/dist/node.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FabricObject } from 'fabric';
|
|
1
|
+
import { FabricObject, Gradient } from 'fabric';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Layer blend modes — the seventeen the canvas can composite natively, verified
|
|
@@ -29,6 +29,71 @@ declare const BLEND_GROUPS: {
|
|
|
29
29
|
/** Human label for a mode, e.g. `color-burn` → `Color Burn`. */
|
|
30
30
|
declare function blendModeLabel(mode: BlendMode): string;
|
|
31
31
|
|
|
32
|
+
type GradientKind = 'linear' | 'radial';
|
|
33
|
+
interface GradientStop {
|
|
34
|
+
/** `#rrggbb`. Alpha lives in `opacity`, so a colour input stays a colour input. */
|
|
35
|
+
color: string;
|
|
36
|
+
/** 0…1. */
|
|
37
|
+
opacity: number;
|
|
38
|
+
/** 0…1 along the gradient line. */
|
|
39
|
+
position: number;
|
|
40
|
+
}
|
|
41
|
+
interface GradientConfig {
|
|
42
|
+
kind: GradientKind;
|
|
43
|
+
/** Degrees, CSS convention: 0 paints towards the top, 90 towards the right. Linear only. */
|
|
44
|
+
angle: number;
|
|
45
|
+
/** 0…1 of the layer box. Radial only. */
|
|
46
|
+
center: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
};
|
|
50
|
+
/** 0…1 of the layer box. An ellipse, because percentage units follow the box. Radial only. */
|
|
51
|
+
radius: number;
|
|
52
|
+
/** At least two, ascending by position. */
|
|
53
|
+
stops: GradientStop[];
|
|
54
|
+
}
|
|
55
|
+
/** The layer's UNSCALED box — the space fabric paints a percentage filler in. */
|
|
56
|
+
interface GradientBox {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
}
|
|
60
|
+
declare const DEFAULT_GRADIENT_CONFIG: GradientConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Endpoints of the gradient line, in percentage space.
|
|
63
|
+
*
|
|
64
|
+
* fabric paints a percentage filler through `ctx.transform(width, 0, 0, height, …)`
|
|
65
|
+
* (`_applyPatternGradientTransform`), so the space is the unit box under a
|
|
66
|
+
* NON-UNIFORM scale — not a rotation. Drawing the line naively there would put
|
|
67
|
+
* the gradient's iso-lines at some angle other than the one asked for. These
|
|
68
|
+
* endpoints are solved the other way round: `v` is the direction whose iso-lines
|
|
69
|
+
* land perpendicular to `angle` in the box, and `length` is the CSS gradient-line
|
|
70
|
+
* length, which is what makes the run cover the box corners at every angle.
|
|
71
|
+
*
|
|
72
|
+
* A consequence, and the reason the test asserts it: at angles that are not
|
|
73
|
+
* axis-aligned in a non-square box the endpoints sit OUTSIDE 0…1. Clamping them
|
|
74
|
+
* would shorten the run and bunch the stops.
|
|
75
|
+
*/
|
|
76
|
+
declare function linearCoords(angle: number, box: GradientBox): {
|
|
77
|
+
x1: number;
|
|
78
|
+
y1: number;
|
|
79
|
+
x2: number;
|
|
80
|
+
y2: number;
|
|
81
|
+
};
|
|
82
|
+
/** Inverse of {@link linearCoords}. */
|
|
83
|
+
declare function angleFromCoords(coords: {
|
|
84
|
+
x1: number;
|
|
85
|
+
y1: number;
|
|
86
|
+
x2: number;
|
|
87
|
+
y2: number;
|
|
88
|
+
}, box: GradientBox): number;
|
|
89
|
+
declare function toFabricGradient(config: GradientConfig, box: GradientBox): Gradient<'linear'> | Gradient<'radial'>;
|
|
90
|
+
/**
|
|
91
|
+
* The config an object's gradient fill was built from, or null when the fill is
|
|
92
|
+
* flat. This is the ONLY reader: `fill` is the single source of truth, so a
|
|
93
|
+
* panel never has to be told what it is already looking at.
|
|
94
|
+
*/
|
|
95
|
+
declare function readGradientConfig(object: FabricObject): GradientConfig | null;
|
|
96
|
+
|
|
32
97
|
type Unit = 'px' | 'mm' | 'in';
|
|
33
98
|
type LayerType = 'image' | 'mask' | 'text' | 'shape' | 'template' | 'group' | 'gradient';
|
|
34
99
|
interface LayerData {
|
|
@@ -158,6 +223,12 @@ interface LayerMaskEntry {
|
|
|
158
223
|
rel?: number[];
|
|
159
224
|
/** Host data describing where the geometry came from (preset id, generator…). */
|
|
160
225
|
meta?: Record<string, unknown>;
|
|
226
|
+
/**
|
|
227
|
+
* Authored gradient paint. The composed clip stores a luminance-to-alpha
|
|
228
|
+
* rendering of it; this copy keeps the editable colours through recomposition,
|
|
229
|
+
* serialization and conversion back into an ordinary layer.
|
|
230
|
+
*/
|
|
231
|
+
gradient?: GradientConfig;
|
|
161
232
|
/** Original layer data retained so an unmask restores an editable layer. */
|
|
162
233
|
sourceLayer?: Omit<LayerData, 'id' | 'children'>;
|
|
163
234
|
/** Fabric properties the mask compositor temporarily overwrites. */
|
|
@@ -620,4 +691,4 @@ interface EditorEvents {
|
|
|
620
691
|
};
|
|
621
692
|
}
|
|
622
693
|
|
|
623
|
-
export { type
|
|
694
|
+
export { type ProjectState as $, type MaskPresetId as A, BLEND_GROUPS as B, type CanvasSizePreset as C, DEFAULT_GRADIENT_CONFIG as D, type EditorConfig as E, type FileAdapter as F, type GradientBox as G, type MaskRefinementPrompt as H, type ImageAdjustments as I, type MaskRefinementProvider as J, type MaskRefinementRequest as K, type LayerData as L, type MaskBrushOptions as M, type MaskRefinementResult as N, type MockupBlendMode as O, type MockupConfig as P, type MockupDisplacement as Q, type MockupDisplacementChannel as R, type MockupOverlay as S, type MockupPrintArea as T, type NormalizedLayerPosition as U, type PatternConfig as V, type PatternLocks as W, type PatternState as X, type PositioningAdapter as Y, type PrintifyPositioning as Z, type ProjectPage as _, BLEND_MODES as a, type ResizeOptions as a0, type SemanticExportOptions as a1, type SerializedBackgroundImageOptions as a2, type SerializedLayer as a3, type ShapeMaskPresetId as a4, type ShapePlugin as a5, type SvgExportOptions as a6, type TemplateDefinition as a7, type TemplateParameter as a8, type TextCurveConfig as a9, type TextCurveInput as aa, type TextCurveShape as ab, type TextOverflow as ac, type TextWrapMode as ad, type TextureMaskPresetId as ae, type TileMode as af, type Unit as ag, angleFromCoords as ah, blendModeLabel as ai, blendModeOf as aj, blendOperation as ak, linearCoords as al, readGradientConfig as am, toFabricGradient as an, type BackgroundImageOptions as b, type BlendMode as c, DEFAULT_PATTERN_CONFIG as d, type DpiIssue as e, type EditorEvents as f, type EditorState as g, type ExportFormat as h, type FontDefinition as i, type GradientConfig as j, type GradientKind as k, type GradientStop as l, type ImageAttribution as m, type ImageProvider as n, type ImageProviderResult as o, type ImageSearchOptions as p, type ImageSearchResult as q, type LayerMaskEntry as r, type LayerMaskMode as s, type LayerMeta as t, type LayerShadowConfig as u, type LayerType as v, type LicenseConfig as w, type LicensePayload as x, type LicenseStatus as y, type MaskPoint as z };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FabricObject } from 'fabric';
|
|
1
|
+
import { FabricObject, Gradient } from 'fabric';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Layer blend modes — the seventeen the canvas can composite natively, verified
|
|
@@ -29,6 +29,71 @@ declare const BLEND_GROUPS: {
|
|
|
29
29
|
/** Human label for a mode, e.g. `color-burn` → `Color Burn`. */
|
|
30
30
|
declare function blendModeLabel(mode: BlendMode): string;
|
|
31
31
|
|
|
32
|
+
type GradientKind = 'linear' | 'radial';
|
|
33
|
+
interface GradientStop {
|
|
34
|
+
/** `#rrggbb`. Alpha lives in `opacity`, so a colour input stays a colour input. */
|
|
35
|
+
color: string;
|
|
36
|
+
/** 0…1. */
|
|
37
|
+
opacity: number;
|
|
38
|
+
/** 0…1 along the gradient line. */
|
|
39
|
+
position: number;
|
|
40
|
+
}
|
|
41
|
+
interface GradientConfig {
|
|
42
|
+
kind: GradientKind;
|
|
43
|
+
/** Degrees, CSS convention: 0 paints towards the top, 90 towards the right. Linear only. */
|
|
44
|
+
angle: number;
|
|
45
|
+
/** 0…1 of the layer box. Radial only. */
|
|
46
|
+
center: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
};
|
|
50
|
+
/** 0…1 of the layer box. An ellipse, because percentage units follow the box. Radial only. */
|
|
51
|
+
radius: number;
|
|
52
|
+
/** At least two, ascending by position. */
|
|
53
|
+
stops: GradientStop[];
|
|
54
|
+
}
|
|
55
|
+
/** The layer's UNSCALED box — the space fabric paints a percentage filler in. */
|
|
56
|
+
interface GradientBox {
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
}
|
|
60
|
+
declare const DEFAULT_GRADIENT_CONFIG: GradientConfig;
|
|
61
|
+
/**
|
|
62
|
+
* Endpoints of the gradient line, in percentage space.
|
|
63
|
+
*
|
|
64
|
+
* fabric paints a percentage filler through `ctx.transform(width, 0, 0, height, …)`
|
|
65
|
+
* (`_applyPatternGradientTransform`), so the space is the unit box under a
|
|
66
|
+
* NON-UNIFORM scale — not a rotation. Drawing the line naively there would put
|
|
67
|
+
* the gradient's iso-lines at some angle other than the one asked for. These
|
|
68
|
+
* endpoints are solved the other way round: `v` is the direction whose iso-lines
|
|
69
|
+
* land perpendicular to `angle` in the box, and `length` is the CSS gradient-line
|
|
70
|
+
* length, which is what makes the run cover the box corners at every angle.
|
|
71
|
+
*
|
|
72
|
+
* A consequence, and the reason the test asserts it: at angles that are not
|
|
73
|
+
* axis-aligned in a non-square box the endpoints sit OUTSIDE 0…1. Clamping them
|
|
74
|
+
* would shorten the run and bunch the stops.
|
|
75
|
+
*/
|
|
76
|
+
declare function linearCoords(angle: number, box: GradientBox): {
|
|
77
|
+
x1: number;
|
|
78
|
+
y1: number;
|
|
79
|
+
x2: number;
|
|
80
|
+
y2: number;
|
|
81
|
+
};
|
|
82
|
+
/** Inverse of {@link linearCoords}. */
|
|
83
|
+
declare function angleFromCoords(coords: {
|
|
84
|
+
x1: number;
|
|
85
|
+
y1: number;
|
|
86
|
+
x2: number;
|
|
87
|
+
y2: number;
|
|
88
|
+
}, box: GradientBox): number;
|
|
89
|
+
declare function toFabricGradient(config: GradientConfig, box: GradientBox): Gradient<'linear'> | Gradient<'radial'>;
|
|
90
|
+
/**
|
|
91
|
+
* The config an object's gradient fill was built from, or null when the fill is
|
|
92
|
+
* flat. This is the ONLY reader: `fill` is the single source of truth, so a
|
|
93
|
+
* panel never has to be told what it is already looking at.
|
|
94
|
+
*/
|
|
95
|
+
declare function readGradientConfig(object: FabricObject): GradientConfig | null;
|
|
96
|
+
|
|
32
97
|
type Unit = 'px' | 'mm' | 'in';
|
|
33
98
|
type LayerType = 'image' | 'mask' | 'text' | 'shape' | 'template' | 'group' | 'gradient';
|
|
34
99
|
interface LayerData {
|
|
@@ -158,6 +223,12 @@ interface LayerMaskEntry {
|
|
|
158
223
|
rel?: number[];
|
|
159
224
|
/** Host data describing where the geometry came from (preset id, generator…). */
|
|
160
225
|
meta?: Record<string, unknown>;
|
|
226
|
+
/**
|
|
227
|
+
* Authored gradient paint. The composed clip stores a luminance-to-alpha
|
|
228
|
+
* rendering of it; this copy keeps the editable colours through recomposition,
|
|
229
|
+
* serialization and conversion back into an ordinary layer.
|
|
230
|
+
*/
|
|
231
|
+
gradient?: GradientConfig;
|
|
161
232
|
/** Original layer data retained so an unmask restores an editable layer. */
|
|
162
233
|
sourceLayer?: Omit<LayerData, 'id' | 'children'>;
|
|
163
234
|
/** Fabric properties the mask compositor temporarily overwrites. */
|
|
@@ -620,4 +691,4 @@ interface EditorEvents {
|
|
|
620
691
|
};
|
|
621
692
|
}
|
|
622
693
|
|
|
623
|
-
export { type
|
|
694
|
+
export { type ProjectState as $, type MaskPresetId as A, BLEND_GROUPS as B, type CanvasSizePreset as C, DEFAULT_GRADIENT_CONFIG as D, type EditorConfig as E, type FileAdapter as F, type GradientBox as G, type MaskRefinementPrompt as H, type ImageAdjustments as I, type MaskRefinementProvider as J, type MaskRefinementRequest as K, type LayerData as L, type MaskBrushOptions as M, type MaskRefinementResult as N, type MockupBlendMode as O, type MockupConfig as P, type MockupDisplacement as Q, type MockupDisplacementChannel as R, type MockupOverlay as S, type MockupPrintArea as T, type NormalizedLayerPosition as U, type PatternConfig as V, type PatternLocks as W, type PatternState as X, type PositioningAdapter as Y, type PrintifyPositioning as Z, type ProjectPage as _, BLEND_MODES as a, type ResizeOptions as a0, type SemanticExportOptions as a1, type SerializedBackgroundImageOptions as a2, type SerializedLayer as a3, type ShapeMaskPresetId as a4, type ShapePlugin as a5, type SvgExportOptions as a6, type TemplateDefinition as a7, type TemplateParameter as a8, type TextCurveConfig as a9, type TextCurveInput as aa, type TextCurveShape as ab, type TextOverflow as ac, type TextWrapMode as ad, type TextureMaskPresetId as ae, type TileMode as af, type Unit as ag, angleFromCoords as ah, blendModeLabel as ai, blendModeOf as aj, blendOperation as ak, linearCoords as al, readGradientConfig as am, toFabricGradient as an, type BackgroundImageOptions as b, type BlendMode as c, DEFAULT_PATTERN_CONFIG as d, type DpiIssue as e, type EditorEvents as f, type EditorState as g, type ExportFormat as h, type FontDefinition as i, type GradientConfig as j, type GradientKind as k, type GradientStop as l, type ImageAttribution as m, type ImageProvider as n, type ImageProviderResult as o, type ImageSearchOptions as p, type ImageSearchResult as q, type LayerMaskEntry as r, type LayerMaskMode as s, type LayerMeta as t, type LayerShadowConfig as u, type LayerType as v, type LicenseConfig as w, type LicensePayload as x, type LicenseStatus as y, type MaskPoint as z };
|