@nmmty/lazycanvas 0.6.0 → 0.6.2
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/helpers/index.d.ts +3 -0
- package/dist/helpers/index.js +19 -0
- package/dist/index.d.ts +5 -12
- package/dist/index.js +5 -31
- package/dist/structures/LazyCanvas.d.ts +12 -16
- package/dist/structures/LazyCanvas.js +24 -27
- package/dist/structures/components/BaseLayer.d.ts +17 -25
- package/dist/structures/components/BaseLayer.js +16 -18
- package/dist/structures/components/BezierLayer.d.ts +29 -21
- package/dist/structures/components/BezierLayer.js +22 -20
- package/dist/structures/components/ClearLayer.d.ts +15 -15
- package/dist/structures/components/ClearLayer.js +14 -14
- package/dist/structures/components/Group.d.ts +10 -11
- package/dist/structures/components/Group.js +9 -10
- package/dist/structures/components/ImageLayer.d.ts +15 -15
- package/dist/structures/components/ImageLayer.js +11 -11
- package/dist/structures/components/LineLayer.d.ts +28 -20
- package/dist/structures/components/LineLayer.js +21 -19
- package/dist/structures/components/MorphLayer.d.ts +29 -21
- package/dist/structures/components/MorphLayer.js +19 -17
- package/dist/structures/components/Path2DLayer.d.ts +21 -72
- package/dist/structures/components/Path2DLayer.js +4 -108
- package/dist/structures/components/QuadraticLayer.d.ts +30 -22
- package/dist/structures/components/QuadraticLayer.js +23 -21
- package/dist/structures/components/TextLayer.d.ts +54 -41
- package/dist/structures/components/TextLayer.js +165 -69
- package/dist/structures/helpers/Exporter.d.ts +9 -9
- package/dist/structures/helpers/Exporter.js +9 -9
- package/dist/structures/helpers/Font.d.ts +4 -4
- package/dist/structures/helpers/Font.js +4 -4
- package/dist/structures/helpers/Gradient.d.ts +15 -10
- package/dist/structures/helpers/Gradient.js +14 -9
- package/dist/structures/helpers/Link.d.ts +5 -5
- package/dist/structures/helpers/Link.js +5 -5
- package/dist/structures/helpers/Pattern.d.ts +5 -5
- package/dist/structures/helpers/Pattern.js +5 -5
- package/dist/structures/helpers/index.d.ts +7 -7
- package/dist/structures/helpers/readers/JSONReader.d.ts +12 -12
- package/dist/structures/helpers/readers/JSONReader.js +12 -12
- package/dist/structures/helpers/readers/YAMLReader.d.ts +4 -4
- package/dist/structures/helpers/readers/YAMLReader.js +4 -4
- package/dist/structures/managers/AnimationManager.d.ts +11 -11
- package/dist/structures/managers/AnimationManager.js +11 -11
- package/dist/structures/managers/FontsManager.d.ts +14 -15
- package/dist/structures/managers/FontsManager.js +14 -15
- package/dist/structures/managers/LayersManager.d.ts +15 -15
- package/dist/structures/managers/LayersManager.js +19 -19
- package/dist/structures/managers/PluginManager.d.ts +11 -9
- package/dist/structures/managers/PluginManager.js +9 -8
- package/dist/structures/managers/RenderManager.d.ts +10 -10
- package/dist/structures/managers/RenderManager.js +10 -10
- package/dist/structures/managers/index.d.ts +5 -0
- package/dist/structures/managers/index.js +21 -0
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/types.d.ts +7 -1
- package/dist/utils/utils.d.ts +5 -5
- package/dist/utils/utils.js +8 -2
- package/package.json +1 -2
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Utlis"), exports);
|
|
18
|
+
__exportStar(require("./Filters"), exports);
|
|
19
|
+
__exportStar(require("./FontsList"), exports);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export { IAnimationManager, IAnimationOptions } from "./structures/managers/AnimationManager";
|
|
4
|
-
export { IRenderManager } from "./structures/managers/RenderManager";
|
|
5
|
-
export { ILayersManager } from "./structures/managers/LayersManager";
|
|
6
|
-
export { IPluginManager, ILazyCanvasPlugin, IPluginHooks } from "./structures/managers/PluginManager";
|
|
1
|
+
export * from "./structures/LazyCanvas";
|
|
2
|
+
export * from "./structures/managers";
|
|
7
3
|
export * from "./structures/components";
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
11
|
-
export { FontsList } from "./helpers/FontsList";
|
|
12
|
-
export type { AnyLayer, AnyCentring, AnyPatternType, AnyGradientType, AnyTextAlign, AnyTextDirection, AnyTextBaseline, AnyWeight, AnyLineCap, AnyLineJoin, AnyExport, AnyLinkType, AnyGlobalCompositeOperation, AnyColorSpace, ScaleType, ColorType, Point, PointNumber, Transform, Extensions } from "./types";
|
|
13
|
-
export { Utils } from "./helpers/Utlis";
|
|
4
|
+
export * from "./types";
|
|
5
|
+
export * from "./structures/helpers";
|
|
6
|
+
export * from "./helpers";
|
package/dist/index.js
CHANGED
|
@@ -14,35 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
Object.defineProperty(exports, "LazyCanvas", { enumerable: true, get: function () { return LazyCanvas_1.LazyCanvas; } });
|
|
17
|
+
__exportStar(require("./structures/LazyCanvas"), exports);
|
|
18
|
+
__exportStar(require("./structures/managers"), exports);
|
|
20
19
|
__exportStar(require("./structures/components"), exports);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
Object.defineProperty(exports, "LineCap", { enumerable: true, get: function () { return types_1.LineCap; } });
|
|
25
|
-
Object.defineProperty(exports, "LineJoin", { enumerable: true, get: function () { return types_1.LineJoin; } });
|
|
26
|
-
Object.defineProperty(exports, "TextAlign", { enumerable: true, get: function () { return types_1.TextAlign; } });
|
|
27
|
-
Object.defineProperty(exports, "TextDirection", { enumerable: true, get: function () { return types_1.TextDirection; } });
|
|
28
|
-
Object.defineProperty(exports, "TextBaseline", { enumerable: true, get: function () { return types_1.TextBaseline; } });
|
|
29
|
-
Object.defineProperty(exports, "FontWeight", { enumerable: true, get: function () { return types_1.FontWeight; } });
|
|
30
|
-
Object.defineProperty(exports, "Export", { enumerable: true, get: function () { return types_1.Export; } });
|
|
31
|
-
Object.defineProperty(exports, "Centring", { enumerable: true, get: function () { return types_1.Centring; } });
|
|
32
|
-
Object.defineProperty(exports, "PatternType", { enumerable: true, get: function () { return types_1.PatternType; } });
|
|
33
|
-
Object.defineProperty(exports, "GradientType", { enumerable: true, get: function () { return types_1.GradientType; } });
|
|
34
|
-
Object.defineProperty(exports, "LinkType", { enumerable: true, get: function () { return types_1.LinkType; } });
|
|
35
|
-
var helpers_1 = require("./structures/helpers");
|
|
36
|
-
Object.defineProperty(exports, "Font", { enumerable: true, get: function () { return helpers_1.Font; } });
|
|
37
|
-
Object.defineProperty(exports, "Gradient", { enumerable: true, get: function () { return helpers_1.Gradient; } });
|
|
38
|
-
Object.defineProperty(exports, "Pattern", { enumerable: true, get: function () { return helpers_1.Pattern; } });
|
|
39
|
-
Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return helpers_1.Link; } });
|
|
40
|
-
Object.defineProperty(exports, "Exporter", { enumerable: true, get: function () { return helpers_1.Exporter; } });
|
|
41
|
-
Object.defineProperty(exports, "JSONReader", { enumerable: true, get: function () { return helpers_1.JSONReader; } });
|
|
42
|
-
Object.defineProperty(exports, "YAMLReader", { enumerable: true, get: function () { return helpers_1.YAMLReader; } });
|
|
43
|
-
var Filters_1 = require("./helpers/Filters");
|
|
44
|
-
Object.defineProperty(exports, "Filters", { enumerable: true, get: function () { return Filters_1.Filters; } });
|
|
45
|
-
var FontsList_1 = require("./helpers/FontsList");
|
|
46
|
-
Object.defineProperty(exports, "FontsList", { enumerable: true, get: function () { return FontsList_1.FontsList; } });
|
|
47
|
-
var Utlis_1 = require("./helpers/Utlis");
|
|
48
|
-
Object.defineProperty(exports, "Utils", { enumerable: true, get: function () { return Utlis_1.Utils; } });
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
__exportStar(require("./structures/helpers"), exports);
|
|
22
|
+
__exportStar(require("./helpers"), exports);
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { AnyExport, JSONLayer } from "../types";
|
|
2
2
|
import { Canvas, SKRSContext2D, SvgCanvas, SvgExportFlag } from "@napi-rs/canvas";
|
|
3
|
-
import { LayersManager } from "./managers
|
|
4
|
-
import { RenderManager } from "./managers/RenderManager";
|
|
5
|
-
import { FontsManager } from "./managers/FontsManager";
|
|
6
|
-
import { AnimationManager, IAnimationOptions } from "./managers/AnimationManager";
|
|
7
|
-
import { PluginManager, ILazyCanvasPlugin } from "./managers/PluginManager";
|
|
3
|
+
import { LayersManager, RenderManager, FontsManager, AnimationManager, IAnimationOptions, PluginManager, ILazyCanvasPlugin } from "./managers";
|
|
8
4
|
import { Group } from "./components";
|
|
9
5
|
/**
|
|
10
6
|
* Interface representing the LazyCanvas structure.
|
|
@@ -104,9 +100,9 @@ export declare class LazyCanvas implements ILazyCanvas {
|
|
|
104
100
|
options: ILazyCanvasOptions;
|
|
105
101
|
/**
|
|
106
102
|
* Constructs a new LazyCanvas instance.
|
|
107
|
-
* @param
|
|
108
|
-
* @param opts.debug
|
|
109
|
-
* @param opts.settings
|
|
103
|
+
* @param {Object} [opts] - Optional settings for the LazyCanvas instance.
|
|
104
|
+
* @param {boolean} [opts.debug] - Whether debugging is enabled.
|
|
105
|
+
* @param {IOLazyCanvas} [opts.settings] - The input settings for the LazyCanvas instance.
|
|
110
106
|
*/
|
|
111
107
|
constructor(opts?: {
|
|
112
108
|
debug?: boolean;
|
|
@@ -114,13 +110,13 @@ export declare class LazyCanvas implements ILazyCanvas {
|
|
|
114
110
|
});
|
|
115
111
|
/**
|
|
116
112
|
* Sets the export type for the canvas.
|
|
117
|
-
* @param
|
|
113
|
+
* @param {AnyExport} [type] - The export type (e.g., buffer, SVG, etc.).
|
|
118
114
|
* @returns {this} The current instance for chaining.
|
|
119
115
|
*/
|
|
120
116
|
setExportType(type: AnyExport): this;
|
|
121
117
|
/**
|
|
122
118
|
* Sets the SVG export flag. This method should be called after `setExportType`.
|
|
123
|
-
* @param
|
|
119
|
+
* @param {SvgExportFlag} [flag] - The SVG export flag.
|
|
124
120
|
* @returns {this} The current instance for chaining.
|
|
125
121
|
*/
|
|
126
122
|
setSvgExportFlag(flag: SvgExportFlag): this;
|
|
@@ -131,32 +127,32 @@ export declare class LazyCanvas implements ILazyCanvas {
|
|
|
131
127
|
animated(): this;
|
|
132
128
|
/**
|
|
133
129
|
* Resizes the canvas to the specified dimensions.
|
|
134
|
-
* @param
|
|
130
|
+
* @param {number} [ratio] - The ratio to resize the canvas.
|
|
135
131
|
* @returns {this} The current instance for chaining.
|
|
136
132
|
*/
|
|
137
133
|
resize(ratio: number): this;
|
|
138
134
|
/**
|
|
139
135
|
* Creates a new canvas with the specified dimensions.
|
|
140
|
-
* @param
|
|
141
|
-
* @param
|
|
136
|
+
* @param {number} [width] - The width of the canvas.
|
|
137
|
+
* @param {number} [height] - The height of the canvas.
|
|
142
138
|
* @returns {this} The current instance for chaining.
|
|
143
139
|
*/
|
|
144
140
|
create(width: number, height: number): this;
|
|
145
141
|
/**
|
|
146
142
|
* Installs a plugin to the canvas.
|
|
147
|
-
* @param
|
|
143
|
+
* @param {ILazyCanvasPlugin} [plugin] - The plugin to install.
|
|
148
144
|
* @returns {this} The current instance for chaining.
|
|
149
145
|
*/
|
|
150
146
|
use(plugin: ILazyCanvasPlugin): this;
|
|
151
147
|
/**
|
|
152
148
|
* Removes a plugin from the canvas.
|
|
153
|
-
* @param
|
|
149
|
+
* @param {string} [pluginName] - The name of the plugin to remove.
|
|
154
150
|
* @returns {this} The current instance for chaining.
|
|
155
151
|
*/
|
|
156
152
|
removePlugin(pluginName: string): this;
|
|
157
153
|
/**
|
|
158
154
|
* Gets a plugin by name.
|
|
159
|
-
* @param
|
|
155
|
+
* @param {string} [pluginName] - The name of the plugin.
|
|
160
156
|
* @returns {ILazyCanvasPlugin | undefined} The plugin or undefined if not found.
|
|
161
157
|
*/
|
|
162
158
|
getPlugin(pluginName: string): ILazyCanvasPlugin | undefined;
|
|
@@ -3,11 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.LazyCanvas = void 0;
|
|
4
4
|
const types_1 = require("../types");
|
|
5
5
|
const canvas_1 = require("@napi-rs/canvas");
|
|
6
|
-
const
|
|
7
|
-
const RenderManager_1 = require("./managers/RenderManager");
|
|
8
|
-
const FontsManager_1 = require("./managers/FontsManager");
|
|
9
|
-
const AnimationManager_1 = require("./managers/AnimationManager");
|
|
10
|
-
const PluginManager_1 = require("./managers/PluginManager");
|
|
6
|
+
const managers_1 = require("./managers");
|
|
11
7
|
const LazyUtil_1 = require("../utils/LazyUtil");
|
|
12
8
|
const utils_1 = require("../utils/utils");
|
|
13
9
|
/**
|
|
@@ -33,33 +29,34 @@ class LazyCanvas {
|
|
|
33
29
|
options;
|
|
34
30
|
/**
|
|
35
31
|
* Constructs a new LazyCanvas instance.
|
|
36
|
-
* @param
|
|
37
|
-
* @param opts.debug
|
|
38
|
-
* @param opts.settings
|
|
32
|
+
* @param {Object} [opts] - Optional settings for the LazyCanvas instance.
|
|
33
|
+
* @param {boolean} [opts.debug] - Whether debugging is enabled.
|
|
34
|
+
* @param {IOLazyCanvas} [opts.settings] - The input settings for the LazyCanvas instance.
|
|
39
35
|
*/
|
|
40
36
|
constructor(opts) {
|
|
41
37
|
this.canvas = new canvas_1.Canvas(0, 0);
|
|
42
38
|
this.ctx = this.canvas.getContext('2d');
|
|
43
39
|
this.manager = {
|
|
44
|
-
layers: new
|
|
45
|
-
render: new
|
|
46
|
-
fonts: new
|
|
47
|
-
animation: new
|
|
48
|
-
plugins: new
|
|
40
|
+
layers: new managers_1.LayersManager(this, { debug: opts?.debug }),
|
|
41
|
+
render: new managers_1.RenderManager(this, { debug: opts?.debug }),
|
|
42
|
+
fonts: new managers_1.FontsManager({ debug: opts?.debug }),
|
|
43
|
+
animation: new managers_1.AnimationManager({ debug: opts?.debug, settings: { options: opts?.settings?.animation } }),
|
|
44
|
+
plugins: new managers_1.PluginManager(this, { debug: opts?.debug })
|
|
49
45
|
};
|
|
50
46
|
this.options = {
|
|
51
|
-
width:
|
|
52
|
-
height:
|
|
53
|
-
animated:
|
|
54
|
-
exportType:
|
|
55
|
-
flag:
|
|
47
|
+
width: 0,
|
|
48
|
+
height: 0,
|
|
49
|
+
animated: false,
|
|
50
|
+
exportType: types_1.Export.BUFFER,
|
|
51
|
+
flag: canvas_1.SvgExportFlag.RelativePathEncoding,
|
|
52
|
+
...opts?.settings?.options
|
|
56
53
|
};
|
|
57
54
|
if (opts?.debug)
|
|
58
55
|
LazyUtil_1.LazyLog.log('info', 'LazyCanvas initialized with settings:', opts.settings);
|
|
59
56
|
}
|
|
60
57
|
/**
|
|
61
58
|
* Sets the export type for the canvas.
|
|
62
|
-
* @param
|
|
59
|
+
* @param {AnyExport} [type] - The export type (e.g., buffer, SVG, etc.).
|
|
63
60
|
* @returns {this} The current instance for chaining.
|
|
64
61
|
*/
|
|
65
62
|
setExportType(type) {
|
|
@@ -80,7 +77,7 @@ class LazyCanvas {
|
|
|
80
77
|
}
|
|
81
78
|
/**
|
|
82
79
|
* Sets the SVG export flag. This method should be called after `setExportType`.
|
|
83
|
-
* @param
|
|
80
|
+
* @param {SvgExportFlag} [flag] - The SVG export flag.
|
|
84
81
|
* @returns {this} The current instance for chaining.
|
|
85
82
|
*/
|
|
86
83
|
setSvgExportFlag(flag) {
|
|
@@ -101,7 +98,7 @@ class LazyCanvas {
|
|
|
101
98
|
}
|
|
102
99
|
/**
|
|
103
100
|
* Resizes the canvas to the specified dimensions.
|
|
104
|
-
* @param
|
|
101
|
+
* @param {number} [ratio] - The ratio to resize the canvas.
|
|
105
102
|
* @returns {this} The current instance for chaining.
|
|
106
103
|
*/
|
|
107
104
|
resize(ratio) {
|
|
@@ -125,8 +122,8 @@ class LazyCanvas {
|
|
|
125
122
|
}
|
|
126
123
|
/**
|
|
127
124
|
* Creates a new canvas with the specified dimensions.
|
|
128
|
-
* @param
|
|
129
|
-
* @param
|
|
125
|
+
* @param {number} [width] - The width of the canvas.
|
|
126
|
+
* @param {number} [height] - The height of the canvas.
|
|
130
127
|
* @returns {this} The current instance for chaining.
|
|
131
128
|
*/
|
|
132
129
|
create(width, height) {
|
|
@@ -139,14 +136,14 @@ class LazyCanvas {
|
|
|
139
136
|
this.canvas = new canvas_1.Canvas(width, height);
|
|
140
137
|
}
|
|
141
138
|
this.ctx = this.canvas.getContext('2d');
|
|
142
|
-
this.manager.layers = new
|
|
139
|
+
this.manager.layers = new managers_1.LayersManager(this, { debug: this.manager.layers.debug });
|
|
143
140
|
// Выполняем хук onCanvasCreated для всех плагинов
|
|
144
141
|
this.manager.plugins.executeHook('onCanvasCreated', this, width, height);
|
|
145
142
|
return this;
|
|
146
143
|
}
|
|
147
144
|
/**
|
|
148
145
|
* Installs a plugin to the canvas.
|
|
149
|
-
* @param
|
|
146
|
+
* @param {ILazyCanvasPlugin} [plugin] - The plugin to install.
|
|
150
147
|
* @returns {this} The current instance for chaining.
|
|
151
148
|
*/
|
|
152
149
|
use(plugin) {
|
|
@@ -155,7 +152,7 @@ class LazyCanvas {
|
|
|
155
152
|
}
|
|
156
153
|
/**
|
|
157
154
|
* Removes a plugin from the canvas.
|
|
158
|
-
* @param
|
|
155
|
+
* @param {string} [pluginName] - The name of the plugin to remove.
|
|
159
156
|
* @returns {this} The current instance for chaining.
|
|
160
157
|
*/
|
|
161
158
|
removePlugin(pluginName) {
|
|
@@ -164,7 +161,7 @@ class LazyCanvas {
|
|
|
164
161
|
}
|
|
165
162
|
/**
|
|
166
163
|
* Gets a plugin by name.
|
|
167
|
-
* @param
|
|
164
|
+
* @param {string} [pluginName] - The name of the plugin.
|
|
168
165
|
* @returns {ILazyCanvasPlugin | undefined} The plugin or undefined if not found.
|
|
169
166
|
*/
|
|
170
167
|
getPlugin(pluginName) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ScaleType, AnyCentring, AnyGlobalCompositeOperation,
|
|
1
|
+
import { ScaleType, AnyCentring, AnyGlobalCompositeOperation, Transform, AnyFilter, LayerType } from "../../types";
|
|
2
2
|
/**
|
|
3
3
|
* Interface representing the base structure of a layer.
|
|
4
4
|
*/
|
|
@@ -48,14 +48,6 @@ export interface IBaseLayerProps {
|
|
|
48
48
|
* The opacity of the layer, ranging from 0 to 1.
|
|
49
49
|
*/
|
|
50
50
|
opacity: number;
|
|
51
|
-
/**
|
|
52
|
-
* Whether the layer is filled.
|
|
53
|
-
*/
|
|
54
|
-
filled: boolean;
|
|
55
|
-
/**
|
|
56
|
-
* The fill style (color or pattern) of the layer.
|
|
57
|
-
*/
|
|
58
|
-
fillStyle: ColorType;
|
|
59
51
|
/**
|
|
60
52
|
* The shadow properties of the layer.
|
|
61
53
|
*/
|
|
@@ -144,27 +136,27 @@ export declare class BaseLayer<T extends IBaseLayerProps> {
|
|
|
144
136
|
constructor(type?: LayerType, props?: T, misc?: IBaseLayerMisc);
|
|
145
137
|
/**
|
|
146
138
|
* Sets the position of the layer in the 2D plane.
|
|
147
|
-
* @param {ScaleType} x - The x-coordinate of the layer.
|
|
148
|
-
* @param {ScaleType} y - The y-coordinate of the layer.
|
|
139
|
+
* @param {ScaleType} [x] - The x-coordinate of the layer.
|
|
140
|
+
* @param {ScaleType} [y] - The y-coordinate of the layer.
|
|
149
141
|
* @returns {this} The current instance for chaining.
|
|
150
142
|
*/
|
|
151
143
|
setPosition(x: ScaleType, y: ScaleType): this;
|
|
152
144
|
/**
|
|
153
145
|
* Sets the opacity of the layer.
|
|
154
|
-
* @param {number} opacity - The opacity value, between 0 and 1.
|
|
146
|
+
* @param {number} [opacity] - The opacity value, between 0 and 1.
|
|
155
147
|
* @returns {this} The current instance for chaining.
|
|
156
148
|
*/
|
|
157
149
|
setOpacity(opacity: number): this;
|
|
158
150
|
/**
|
|
159
151
|
* Sets the unique identifier of the layer.
|
|
160
152
|
*
|
|
161
|
-
* @param {string} id - The unique identifier.
|
|
153
|
+
* @param {string} [id] - The unique identifier.
|
|
162
154
|
* @returns {this} The current instance for chaining.
|
|
163
155
|
*/
|
|
164
156
|
setID(id: string): this;
|
|
165
157
|
/**
|
|
166
158
|
* Sets the shadow properties of the layer.
|
|
167
|
-
* @param {string} color - The color of the shadow.
|
|
159
|
+
* @param {string} [color] - The color of the shadow.
|
|
168
160
|
* @param {number} [blur] - The blur radius of the shadow.
|
|
169
161
|
* @param {number} [offsetX] - The horizontal offset of the shadow.
|
|
170
162
|
* @param {number} [offsetY] - The vertical offset of the shadow.
|
|
@@ -174,57 +166,57 @@ export declare class BaseLayer<T extends IBaseLayerProps> {
|
|
|
174
166
|
setShadow(color: string, blur?: number, offsetX?: number, offsetY?: number): this;
|
|
175
167
|
/**
|
|
176
168
|
* Sets the transformation matrix of the layer.
|
|
177
|
-
* @param {DOMMatrix2DInit} matrix - The transformation matrix.
|
|
169
|
+
* @param {DOMMatrix2DInit} [matrix] - The transformation matrix.
|
|
178
170
|
* @returns {this} The current instance for chaining.
|
|
179
171
|
*/
|
|
180
172
|
setMatrix(matrix: DOMMatrix2DInit): this;
|
|
181
173
|
/**
|
|
182
174
|
* Sets the scale of the layer in the x and y directions.
|
|
183
|
-
* @param {number} x - The scale factor in the x direction.
|
|
184
|
-
* @param {number} y - The scale factor in the y direction.
|
|
175
|
+
* @param {number} [x] - The scale factor in the x direction.
|
|
176
|
+
* @param {number} [y] - The scale factor in the y direction.
|
|
185
177
|
* @returns {this} The current instance for chaining.
|
|
186
178
|
*/
|
|
187
179
|
setScale(x: number, y: number): this;
|
|
188
180
|
/**
|
|
189
181
|
* Sets the rotation of the layer.
|
|
190
|
-
* @param {number} rotate - The rotation angle in degrees.
|
|
182
|
+
* @param {number} [rotate] - The rotation angle in degrees.
|
|
191
183
|
* @returns {this} The current instance for chaining.
|
|
192
184
|
*/
|
|
193
185
|
setRotate(rotate: number): this;
|
|
194
186
|
/**
|
|
195
187
|
* Sets the translation of the layer in the x and y directions.
|
|
196
|
-
* @param {number} x - The translation in the x direction.
|
|
197
|
-
* @param {number} y - The translation in the y direction.
|
|
188
|
+
* @param {number} [x] - The translation in the x direction.
|
|
189
|
+
* @param {number} [y] - The translation in the y direction.
|
|
198
190
|
* @returns {this} The current instance for chaining.
|
|
199
191
|
*/
|
|
200
192
|
setTranslate(x: number, y: number): this;
|
|
201
193
|
/**
|
|
202
194
|
* Sets the filter effects for the layer.
|
|
203
|
-
* @param {...AnyFilter} filter - The filter effects to apply.
|
|
195
|
+
* @param {...AnyFilter} [filter] - The filter effects to apply.
|
|
204
196
|
* @returns {this} The current instance for chaining.
|
|
205
197
|
*/
|
|
206
198
|
setFilters(...filter: AnyFilter[]): this;
|
|
207
199
|
/**
|
|
208
200
|
* Sets the centring type of the layer. **Don't affect on Bezier, Line, Quadratic and Text layers**.
|
|
209
|
-
* @param {AnyCentring} centring - The centring type.
|
|
201
|
+
* @param {AnyCentring} [centring] - The centring type.
|
|
210
202
|
* @returns {this} The current instance for chaining.
|
|
211
203
|
*/
|
|
212
204
|
setCentring(centring: AnyCentring): this;
|
|
213
205
|
/**
|
|
214
206
|
* Sets the visibility of the layer.
|
|
215
|
-
* @param {boolean} visible - The visibility state.
|
|
207
|
+
* @param {boolean} [visible] - The visibility state.
|
|
216
208
|
* @returns {this} The current instance for chaining.
|
|
217
209
|
*/
|
|
218
210
|
setVisible(visible: boolean): this;
|
|
219
211
|
/**
|
|
220
212
|
* Sets the z-index of the layer.
|
|
221
|
-
* @param {number} zIndex - The z-index value.
|
|
213
|
+
* @param {number} [zIndex] - The z-index value.
|
|
222
214
|
* @returns {this} The current instance for chaining.
|
|
223
215
|
*/
|
|
224
216
|
setZIndex(zIndex: number): this;
|
|
225
217
|
/**
|
|
226
218
|
* Sets the global composite operation for the layer.
|
|
227
|
-
* @param {AnyGlobalCompositeOperation} operation - The composite operation.
|
|
219
|
+
* @param {AnyGlobalCompositeOperation} [operation] - The composite operation.
|
|
228
220
|
* @returns {this} The current instance for chaining.
|
|
229
221
|
*/
|
|
230
222
|
setGlobalCompositeOperation(operation: AnyGlobalCompositeOperation): this;
|
|
@@ -52,8 +52,8 @@ class BaseLayer {
|
|
|
52
52
|
}
|
|
53
53
|
/**
|
|
54
54
|
* Sets the position of the layer in the 2D plane.
|
|
55
|
-
* @param {ScaleType} x - The x-coordinate of the layer.
|
|
56
|
-
* @param {ScaleType} y - The y-coordinate of the layer.
|
|
55
|
+
* @param {ScaleType} [x] - The x-coordinate of the layer.
|
|
56
|
+
* @param {ScaleType} [y] - The y-coordinate of the layer.
|
|
57
57
|
* @returns {this} The current instance for chaining.
|
|
58
58
|
*/
|
|
59
59
|
setPosition(x, y) {
|
|
@@ -63,7 +63,7 @@ class BaseLayer {
|
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
65
|
* Sets the opacity of the layer.
|
|
66
|
-
* @param {number} opacity - The opacity value, between 0 and 1.
|
|
66
|
+
* @param {number} [opacity] - The opacity value, between 0 and 1.
|
|
67
67
|
* @returns {this} The current instance for chaining.
|
|
68
68
|
*/
|
|
69
69
|
setOpacity(opacity) {
|
|
@@ -73,7 +73,7 @@ class BaseLayer {
|
|
|
73
73
|
/**
|
|
74
74
|
* Sets the unique identifier of the layer.
|
|
75
75
|
*
|
|
76
|
-
* @param {string} id - The unique identifier.
|
|
76
|
+
* @param {string} [id] - The unique identifier.
|
|
77
77
|
* @returns {this} The current instance for chaining.
|
|
78
78
|
*/
|
|
79
79
|
setID(id) {
|
|
@@ -82,7 +82,7 @@ class BaseLayer {
|
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
84
84
|
* Sets the shadow properties of the layer.
|
|
85
|
-
* @param {string} color - The color of the shadow.
|
|
85
|
+
* @param {string} [color] - The color of the shadow.
|
|
86
86
|
* @param {number} [blur] - The blur radius of the shadow.
|
|
87
87
|
* @param {number} [offsetX] - The horizontal offset of the shadow.
|
|
88
88
|
* @param {number} [offsetY] - The vertical offset of the shadow.
|
|
@@ -104,7 +104,7 @@ class BaseLayer {
|
|
|
104
104
|
}
|
|
105
105
|
/**
|
|
106
106
|
* Sets the transformation matrix of the layer.
|
|
107
|
-
* @param {DOMMatrix2DInit} matrix - The transformation matrix.
|
|
107
|
+
* @param {DOMMatrix2DInit} [matrix] - The transformation matrix.
|
|
108
108
|
* @returns {this} The current instance for chaining.
|
|
109
109
|
*/
|
|
110
110
|
setMatrix(matrix) {
|
|
@@ -113,8 +113,8 @@ class BaseLayer {
|
|
|
113
113
|
}
|
|
114
114
|
/**
|
|
115
115
|
* Sets the scale of the layer in the x and y directions.
|
|
116
|
-
* @param {number} x - The scale factor in the x direction.
|
|
117
|
-
* @param {number} y - The scale factor in the y direction.
|
|
116
|
+
* @param {number} [x] - The scale factor in the x direction.
|
|
117
|
+
* @param {number} [y] - The scale factor in the y direction.
|
|
118
118
|
* @returns {this} The current instance for chaining.
|
|
119
119
|
*/
|
|
120
120
|
setScale(x, y) {
|
|
@@ -123,7 +123,7 @@ class BaseLayer {
|
|
|
123
123
|
}
|
|
124
124
|
/**
|
|
125
125
|
* Sets the rotation of the layer.
|
|
126
|
-
* @param {number} rotate - The rotation angle in degrees.
|
|
126
|
+
* @param {number} [rotate] - The rotation angle in degrees.
|
|
127
127
|
* @returns {this} The current instance for chaining.
|
|
128
128
|
*/
|
|
129
129
|
setRotate(rotate) {
|
|
@@ -132,8 +132,8 @@ class BaseLayer {
|
|
|
132
132
|
}
|
|
133
133
|
/**
|
|
134
134
|
* Sets the translation of the layer in the x and y directions.
|
|
135
|
-
* @param {number} x - The translation in the x direction.
|
|
136
|
-
* @param {number} y - The translation in the y direction.
|
|
135
|
+
* @param {number} [x] - The translation in the x direction.
|
|
136
|
+
* @param {number} [y] - The translation in the y direction.
|
|
137
137
|
* @returns {this} The current instance for chaining.
|
|
138
138
|
*/
|
|
139
139
|
setTranslate(x, y) {
|
|
@@ -142,7 +142,7 @@ class BaseLayer {
|
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* Sets the filter effects for the layer.
|
|
145
|
-
* @param {...AnyFilter} filter - The filter effects to apply.
|
|
145
|
+
* @param {...AnyFilter} [filter] - The filter effects to apply.
|
|
146
146
|
* @returns {this} The current instance for chaining.
|
|
147
147
|
*/
|
|
148
148
|
setFilters(...filter) {
|
|
@@ -151,7 +151,7 @@ class BaseLayer {
|
|
|
151
151
|
}
|
|
152
152
|
/**
|
|
153
153
|
* Sets the centring type of the layer. **Don't affect on Bezier, Line, Quadratic and Text layers**.
|
|
154
|
-
* @param {AnyCentring} centring - The centring type.
|
|
154
|
+
* @param {AnyCentring} [centring] - The centring type.
|
|
155
155
|
* @returns {this} The current instance for chaining.
|
|
156
156
|
*/
|
|
157
157
|
setCentring(centring) {
|
|
@@ -160,7 +160,7 @@ class BaseLayer {
|
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* Sets the visibility of the layer.
|
|
163
|
-
* @param {boolean} visible - The visibility state.
|
|
163
|
+
* @param {boolean} [visible] - The visibility state.
|
|
164
164
|
* @returns {this} The current instance for chaining.
|
|
165
165
|
*/
|
|
166
166
|
setVisible(visible) {
|
|
@@ -169,7 +169,7 @@ class BaseLayer {
|
|
|
169
169
|
}
|
|
170
170
|
/**
|
|
171
171
|
* Sets the z-index of the layer.
|
|
172
|
-
* @param {number} zIndex - The z-index value.
|
|
172
|
+
* @param {number} [zIndex] - The z-index value.
|
|
173
173
|
* @returns {this} The current instance for chaining.
|
|
174
174
|
*/
|
|
175
175
|
setZIndex(zIndex) {
|
|
@@ -178,7 +178,7 @@ class BaseLayer {
|
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
180
|
* Sets the global composite operation for the layer.
|
|
181
|
-
* @param {AnyGlobalCompositeOperation} operation - The composite operation.
|
|
181
|
+
* @param {AnyGlobalCompositeOperation} [operation] - The composite operation.
|
|
182
182
|
* @returns {this} The current instance for chaining.
|
|
183
183
|
*/
|
|
184
184
|
setGlobalCompositeOperation(operation) {
|
|
@@ -206,8 +206,6 @@ class BaseLayer {
|
|
|
206
206
|
centring: data.centring || types_1.Centring.Center,
|
|
207
207
|
filter: data.filter || '',
|
|
208
208
|
opacity: data.opacity || 1,
|
|
209
|
-
filled: data.filled || true,
|
|
210
|
-
fillStyle: data.fillStyle || '#000000',
|
|
211
209
|
transform: data.transform || {},
|
|
212
210
|
globalComposite: data.globalComposite || 'source-over',
|
|
213
211
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BaseLayer, IBaseLayer, IBaseLayerMisc, IBaseLayerProps } from "./BaseLayer";
|
|
2
2
|
import { ColorType, Point, ScaleType, LayerType } from "../../types";
|
|
3
3
|
import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
|
|
4
|
-
import { LayersManager } from "../managers
|
|
4
|
+
import { LayersManager } from "../managers";
|
|
5
5
|
/**
|
|
6
6
|
* Interface representing a Bezier layer.
|
|
7
7
|
*/
|
|
@@ -27,6 +27,14 @@ export interface IBezierLayerProps extends IBaseLayerProps {
|
|
|
27
27
|
* The end point of the Bézier curve.
|
|
28
28
|
*/
|
|
29
29
|
endPoint: Point;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the layer is filled.
|
|
32
|
+
*/
|
|
33
|
+
filled: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The fill style (color or pattern) of the layer.
|
|
36
|
+
*/
|
|
37
|
+
fillStyle: ColorType;
|
|
30
38
|
/**
|
|
31
39
|
* The stroke properties of the Bézier curve.
|
|
32
40
|
*/
|
|
@@ -67,13 +75,13 @@ export declare class BezierLayer extends BaseLayer<IBezierLayerProps> {
|
|
|
67
75
|
props: IBezierLayerProps;
|
|
68
76
|
/**
|
|
69
77
|
* Constructs a new BezierLayer instance.
|
|
70
|
-
* @param
|
|
71
|
-
* @param
|
|
78
|
+
* @param {IBezierLayerProps} [props] - The properties of the Bezier layer.
|
|
79
|
+
* @param {IBaseLayerMisc} [misc] - Miscellaneous options for the layer.
|
|
72
80
|
*/
|
|
73
81
|
constructor(props?: IBezierLayerProps, misc?: IBaseLayerMisc);
|
|
74
82
|
/**
|
|
75
83
|
* Sets the control points of the Bezier layer.
|
|
76
|
-
* @param
|
|
84
|
+
* @param {Array<{ x: ScaleType, y: ScaleType }>} [controlPoints] - The control points of the Bezier layer.
|
|
77
85
|
* @returns {this} The current instance for chaining.
|
|
78
86
|
* @throws {LazyError} If the number of control points is not exactly 2.
|
|
79
87
|
*/
|
|
@@ -83,34 +91,34 @@ export declare class BezierLayer extends BaseLayer<IBezierLayerProps> {
|
|
|
83
91
|
}[]): this;
|
|
84
92
|
/**
|
|
85
93
|
* Sets the end position of the Bezier layer.
|
|
86
|
-
* @param
|
|
87
|
-
* @param
|
|
94
|
+
* @param {ScaleType} [x] - The x-coordinate of the end point.
|
|
95
|
+
* @param {ScaleType} [y] - The y-coordinate of the end point.
|
|
88
96
|
* @returns {this} The current instance for chaining.
|
|
89
97
|
*/
|
|
90
98
|
setEndPosition(x: ScaleType, y: ScaleType): this;
|
|
91
99
|
/**
|
|
92
100
|
* Sets the color of the Bezier layer.
|
|
93
|
-
* @param
|
|
101
|
+
* @param {ColorType} [color] - The color of the layer.
|
|
94
102
|
* @returns {this} The current instance for chaining.
|
|
95
103
|
* @throws {LazyError} If the color is not provided or invalid.
|
|
96
104
|
*/
|
|
97
105
|
setColor(color: ColorType): this;
|
|
98
106
|
/**
|
|
99
107
|
* Sets the stroke properties of the Bezier layer.
|
|
100
|
-
* @param
|
|
101
|
-
* @param
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
108
|
+
* @param {number} [width] - The width of the stroke.
|
|
109
|
+
* @param {string} [cap] - The cap style of the stroke.
|
|
110
|
+
* @param {string} [join] - The join style of the stroke.
|
|
111
|
+
* @param {number[]} [dash] - The dash pattern of the stroke.
|
|
112
|
+
* @param {number} [dashOffset] - The dash offset of the stroke.
|
|
113
|
+
* @param {number} [miterLimit] - The miter limit of the stroke.
|
|
106
114
|
* @returns {this} The current instance for chaining.
|
|
107
115
|
*/
|
|
108
116
|
setStroke(width: number, cap?: CanvasLineCap, join?: CanvasLineJoin, dash?: number[], dashOffset?: number, miterLimit?: number): this;
|
|
109
117
|
/**
|
|
110
118
|
* Calculates the bounding box of the Bezier layer.
|
|
111
|
-
* @param
|
|
112
|
-
* @param
|
|
113
|
-
* @param
|
|
119
|
+
* @param {SKRSContext2D} [ctx] - The canvas rendering context.
|
|
120
|
+
* @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
|
|
121
|
+
* @param {LayersManager} [manager] - The layers manager.
|
|
114
122
|
* @returns {Object} The bounding box details including max, min, center, width, and height.
|
|
115
123
|
*/
|
|
116
124
|
getBoundingBox(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager): {
|
|
@@ -122,10 +130,10 @@ export declare class BezierLayer extends BaseLayer<IBezierLayerProps> {
|
|
|
122
130
|
};
|
|
123
131
|
/**
|
|
124
132
|
* Draws the Bezier layer on the canvas.
|
|
125
|
-
* @param
|
|
126
|
-
* @param
|
|
127
|
-
* @param
|
|
128
|
-
* @param
|
|
133
|
+
* @param {SKRSContext2D} [ctx] - The canvas rendering context.
|
|
134
|
+
* @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
|
|
135
|
+
* @param {LayersManager} [manager] - The layers manager.
|
|
136
|
+
* @param {boolean} [debug] - Whether to enable debug logging.
|
|
129
137
|
*/
|
|
130
138
|
draw(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager, debug: boolean): Promise<void>;
|
|
131
139
|
/**
|
|
@@ -135,7 +143,7 @@ export declare class BezierLayer extends BaseLayer<IBezierLayerProps> {
|
|
|
135
143
|
toJSON(): IBezierLayer;
|
|
136
144
|
/**
|
|
137
145
|
* Validates the properties of the Bezier layer.
|
|
138
|
-
* @param
|
|
146
|
+
* @param {IBezierLayerProps} [data] - The properties to validate.
|
|
139
147
|
* @returns {IBezierLayerProps} The validated properties.
|
|
140
148
|
*/
|
|
141
149
|
protected validateProps(data: IBezierLayerProps): IBezierLayerProps;
|