@nmmty/lazycanvas 0.6.4 → 1.0.0-dev.10
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/ReadMe.md +1 -1
- package/dist/core/Interpolation.d.ts +30 -0
- package/dist/core/Interpolation.js +200 -0
- package/dist/core/Scene.d.ts +94 -0
- package/dist/core/Scene.js +157 -0
- package/dist/core/Signal.d.ts +133 -0
- package/dist/core/Signal.js +255 -0
- package/dist/core/SignalUtils.d.ts +133 -0
- package/dist/core/SignalUtils.js +333 -0
- package/dist/core/ThreadScheduler.d.ts +38 -0
- package/dist/core/ThreadScheduler.js +74 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +21 -0
- package/dist/helpers/Filters.js +1 -1
- package/dist/helpers/FontsList.js +18 -18
- package/dist/helpers/Utlis.d.ts +3 -3
- package/dist/helpers/Utlis.js +25 -36
- package/dist/helpers/index.d.ts +3 -3
- package/dist/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/jsx-runtime.d.ts +17 -0
- package/dist/jsx-runtime.js +111 -0
- package/dist/structures/LazyCanvas.d.ts +10 -48
- package/dist/structures/LazyCanvas.js +17 -78
- package/dist/structures/components/BaseLayer.d.ts +78 -32
- package/dist/structures/components/BaseLayer.js +106 -37
- package/dist/structures/components/BezierLayer.d.ts +27 -40
- package/dist/structures/components/BezierLayer.js +90 -55
- package/dist/structures/components/{Group.d.ts → Div.d.ts} +41 -22
- package/dist/structures/components/Div.js +202 -0
- package/dist/structures/components/ImageLayer.d.ts +2 -2
- package/dist/structures/components/ImageLayer.js +29 -30
- package/dist/structures/components/LineLayer.d.ts +20 -38
- package/dist/structures/components/LineLayer.js +45 -47
- package/dist/structures/components/MorphLayer.d.ts +5 -34
- package/dist/structures/components/MorphLayer.js +38 -52
- package/dist/structures/components/Path2DLayer.d.ts +7 -35
- package/dist/structures/components/Path2DLayer.js +32 -41
- package/dist/structures/components/PolygonLayer.d.ts +95 -0
- package/dist/structures/components/PolygonLayer.js +203 -0
- package/dist/structures/components/QuadraticLayer.d.ts +36 -45
- package/dist/structures/components/QuadraticLayer.js +90 -54
- package/dist/structures/components/TextLayer.d.ts +17 -46
- package/dist/structures/components/TextLayer.js +94 -77
- package/dist/structures/components/index.d.ts +10 -10
- package/dist/structures/components/index.js +2 -2
- package/dist/structures/helpers/Exporter.d.ts +13 -4
- package/dist/structures/helpers/Exporter.js +82 -46
- package/dist/structures/helpers/Font.js +1 -17
- package/dist/structures/helpers/Gradient.js +35 -49
- package/dist/structures/helpers/Link.js +2 -14
- package/dist/structures/helpers/Pattern.js +10 -18
- package/dist/structures/helpers/index.d.ts +7 -7
- package/dist/structures/helpers/readers/JSONReader.d.ts +4 -4
- package/dist/structures/helpers/readers/JSONReader.js +46 -48
- package/dist/structures/helpers/readers/YAMLReader.js +11 -11
- package/dist/structures/managers/FontsManager.js +9 -18
- package/dist/structures/managers/LayersManager.d.ts +18 -28
- package/dist/structures/managers/LayersManager.js +14 -36
- package/dist/structures/managers/LayoutManager.d.ts +23 -0
- package/dist/structures/managers/LayoutManager.js +409 -0
- package/dist/structures/managers/index.d.ts +3 -5
- package/dist/structures/managers/index.js +1 -3
- package/dist/structures/managers/{RenderManager.d.ts → piplines/ClassicRenderPipeline.d.ts} +4 -30
- package/dist/structures/managers/piplines/ClassicRenderPipeline.js +90 -0
- package/dist/structures/managers/piplines/ModernRenderPipeline.d.ts +44 -0
- package/dist/structures/managers/piplines/ModernRenderPipeline.js +123 -0
- package/dist/structures/managers/piplines/index.d.ts +24 -0
- package/dist/structures/managers/piplines/index.js +18 -0
- package/dist/types/enum.d.ts +4 -3
- package/dist/types/enum.js +3 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +257 -105
- package/dist/utils/APNGEncoder.d.ts +67 -0
- package/dist/utils/APNGEncoder.js +205 -0
- package/dist/utils/DrawUtils.d.ts +9 -0
- package/dist/utils/DrawUtils.js +42 -0
- package/dist/utils/LazyUtil.js +1 -2
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +20 -0
- package/dist/utils/utils.d.ts +5 -9
- package/dist/utils/utils.js +154 -78
- package/package.json +61 -59
- package/dist/structures/components/ClearLayer.d.ts +0 -147
- package/dist/structures/components/ClearLayer.js +0 -158
- package/dist/structures/components/Group.js +0 -153
- package/dist/structures/managers/AnimationManager.d.ts +0 -120
- package/dist/structures/managers/AnimationManager.js +0 -99
- package/dist/structures/managers/PluginManager.d.ts +0 -230
- package/dist/structures/managers/PluginManager.js +0 -182
- package/dist/structures/managers/RenderManager.js +0 -183
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BaseLayer, IBaseLayer, IBaseLayerMisc, IBaseLayerProps } from "./BaseLayer";
|
|
2
|
+
import { ColorType, LayerType, ScaleType, StrokeOptions } from "../../types";
|
|
3
|
+
import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
|
|
4
|
+
import { LayersManager } from "../managers";
|
|
5
|
+
export interface IPolygonLayer extends IBaseLayer {
|
|
6
|
+
/**
|
|
7
|
+
* The type of the layer, which is `Polygon`.
|
|
8
|
+
*/
|
|
9
|
+
type: LayerType.Polygon;
|
|
10
|
+
/**
|
|
11
|
+
* The properties specific to the Polygon Layer.
|
|
12
|
+
*/
|
|
13
|
+
props: IPolygonLayerProps;
|
|
14
|
+
}
|
|
15
|
+
export interface IPolygonLayerProps extends IBaseLayerProps {
|
|
16
|
+
/**
|
|
17
|
+
* The size of the Polygon Layer, including width, height, and radius.
|
|
18
|
+
*/
|
|
19
|
+
size: {
|
|
20
|
+
/**
|
|
21
|
+
* The width of the Polygon Layer.
|
|
22
|
+
*/
|
|
23
|
+
width: ScaleType;
|
|
24
|
+
/**
|
|
25
|
+
* The height of the Polygon Layer.
|
|
26
|
+
*/
|
|
27
|
+
height: ScaleType;
|
|
28
|
+
/**
|
|
29
|
+
* The radius of corners in the Polygon Layer.
|
|
30
|
+
*/
|
|
31
|
+
radius: number;
|
|
32
|
+
/**
|
|
33
|
+
* The number of sides of the polygon.
|
|
34
|
+
*/
|
|
35
|
+
count: number;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The fill style (color or pattern) of the layer.
|
|
39
|
+
*/
|
|
40
|
+
color: ColorType;
|
|
41
|
+
/**
|
|
42
|
+
* The stroke properties of the polygon.
|
|
43
|
+
*/
|
|
44
|
+
stroke?: StrokeOptions;
|
|
45
|
+
}
|
|
46
|
+
export declare class PolygonLayer extends BaseLayer<IPolygonLayerProps> {
|
|
47
|
+
props: IPolygonLayerProps;
|
|
48
|
+
constructor(props?: IPolygonLayerProps, misc?: IBaseLayerMisc);
|
|
49
|
+
/**
|
|
50
|
+
* Sets the size of the Polygon layer.
|
|
51
|
+
* @param {ScaleType} [width] - The width of the Polygon layer.
|
|
52
|
+
* @param {ScaleType} [height] - The height of the Polygon layer.
|
|
53
|
+
* @param {number} [count] - The number of sides of the polygon.
|
|
54
|
+
* @param {number} [radius] - The radius of the Polygon Layer (optional).
|
|
55
|
+
* @returns {this} The current instance for chaining.
|
|
56
|
+
*/
|
|
57
|
+
setSize(width: ScaleType, height: ScaleType, count: number, radius?: number): this;
|
|
58
|
+
/**
|
|
59
|
+
* Sets the color of the Polygon layer.
|
|
60
|
+
* @param {ColorType} [color] - The color of the layer.
|
|
61
|
+
* @returns {this} The current instance for chaining.
|
|
62
|
+
* @throws {LazyError} If the color is not provided or invalid.
|
|
63
|
+
*/
|
|
64
|
+
setColor(color: ColorType): this;
|
|
65
|
+
/**
|
|
66
|
+
* Sets the stroke properties of the Polygon Layer.
|
|
67
|
+
* @param {number} [width] - The width of the stroke.
|
|
68
|
+
* @param {string} [cap] - The cap style of the stroke.
|
|
69
|
+
* @param {string} [join] - The join style of the stroke.
|
|
70
|
+
* @param {number[]} [dash] - The dash pattern of the stroke.
|
|
71
|
+
* @param {number} [dashOffset] - The dash offset of the stroke.
|
|
72
|
+
* @param {number} [miterLimit] - The miter limit of the stroke.
|
|
73
|
+
* @returns {this} The current instance for chaining.
|
|
74
|
+
*/
|
|
75
|
+
setStroke(width: number, cap?: CanvasLineCap, join?: CanvasLineJoin, dash?: number[], dashOffset?: number, miterLimit?: number): this;
|
|
76
|
+
/**
|
|
77
|
+
* Draws the Polygon layer on the given canvas context.
|
|
78
|
+
* @param {SKRSContext2D} [ctx] - The canvas rendering context.
|
|
79
|
+
* @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
|
|
80
|
+
* @param {LayersManager} [manager] - The layer's manager.
|
|
81
|
+
* @param {boolean} [debug] - Whether to enable debug logging.
|
|
82
|
+
*/
|
|
83
|
+
draw(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager, debug: boolean): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Converts the Polygon layer to a JSON representation.
|
|
86
|
+
* @returns {IPolygonLayer} The JSON representation of the Polygon layer.
|
|
87
|
+
*/
|
|
88
|
+
toJSON(): IPolygonLayer;
|
|
89
|
+
/**
|
|
90
|
+
* Validates the properties of the Morph Layer.
|
|
91
|
+
* @param {IPolygonLayerProps} [data] - The properties to validate.
|
|
92
|
+
* @returns {IPolygonLayerProps} The validated properties.
|
|
93
|
+
*/
|
|
94
|
+
protected validateProps(data: IPolygonLayerProps): IPolygonLayerProps;
|
|
95
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PolygonLayer = void 0;
|
|
4
|
+
const BaseLayer_1 = require("./BaseLayer");
|
|
5
|
+
const types_1 = require("../../types");
|
|
6
|
+
const utils_1 = require("../../utils");
|
|
7
|
+
class PolygonLayer extends BaseLayer_1.BaseLayer {
|
|
8
|
+
constructor(props, misc) {
|
|
9
|
+
super(types_1.LayerType.Polygon, props || {}, misc);
|
|
10
|
+
this.props = props ? props : {};
|
|
11
|
+
this.props = this.validateProps(this.props);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Sets the size of the Polygon layer.
|
|
15
|
+
* @param {ScaleType} [width] - The width of the Polygon layer.
|
|
16
|
+
* @param {ScaleType} [height] - The height of the Polygon layer.
|
|
17
|
+
* @param {number} [count] - The number of sides of the polygon.
|
|
18
|
+
* @param {number} [radius] - The radius of the Polygon Layer (optional).
|
|
19
|
+
* @returns {this} The current instance for chaining.
|
|
20
|
+
*/
|
|
21
|
+
setSize(width, height, count, radius) {
|
|
22
|
+
this.props.size = {
|
|
23
|
+
width: width,
|
|
24
|
+
height: height,
|
|
25
|
+
count: count,
|
|
26
|
+
radius: radius || 0,
|
|
27
|
+
};
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Sets the color of the Polygon layer.
|
|
32
|
+
* @param {ColorType} [color] - The color of the layer.
|
|
33
|
+
* @returns {this} The current instance for chaining.
|
|
34
|
+
* @throws {LazyError} If the color is not provided or invalid.
|
|
35
|
+
*/
|
|
36
|
+
setColor(color) {
|
|
37
|
+
if (!color)
|
|
38
|
+
throw new utils_1.LazyError("The color of the layer must be provided");
|
|
39
|
+
if (!(0, utils_1.isColor)(color))
|
|
40
|
+
throw new utils_1.LazyError("The color of the layer must be a valid color");
|
|
41
|
+
this.props.color = color;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Sets the stroke properties of the Polygon Layer.
|
|
46
|
+
* @param {number} [width] - The width of the stroke.
|
|
47
|
+
* @param {string} [cap] - The cap style of the stroke.
|
|
48
|
+
* @param {string} [join] - The join style of the stroke.
|
|
49
|
+
* @param {number[]} [dash] - The dash pattern of the stroke.
|
|
50
|
+
* @param {number} [dashOffset] - The dash offset of the stroke.
|
|
51
|
+
* @param {number} [miterLimit] - The miter limit of the stroke.
|
|
52
|
+
* @returns {this} The current instance for chaining.
|
|
53
|
+
*/
|
|
54
|
+
setStroke(width, cap, join, dash, dashOffset, miterLimit) {
|
|
55
|
+
this.props.stroke = {
|
|
56
|
+
width,
|
|
57
|
+
cap: cap || "butt",
|
|
58
|
+
join: join || "miter",
|
|
59
|
+
dash: dash || [],
|
|
60
|
+
dashOffset: dashOffset || 0,
|
|
61
|
+
miterLimit: miterLimit || 10,
|
|
62
|
+
};
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Draws the Polygon layer on the given canvas context.
|
|
67
|
+
* @param {SKRSContext2D} [ctx] - The canvas rendering context.
|
|
68
|
+
* @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
|
|
69
|
+
* @param {LayersManager} [manager] - The layer's manager.
|
|
70
|
+
* @param {boolean} [debug] - Whether to enable debug logging.
|
|
71
|
+
*/
|
|
72
|
+
async draw(ctx, canvas, manager, debug) {
|
|
73
|
+
const parcer = (0, utils_1.parser)(ctx, canvas, manager);
|
|
74
|
+
const { xs, ys, w } = parcer.parseBatch({
|
|
75
|
+
xs: { v: this.props.position?.x || 0 },
|
|
76
|
+
ys: { v: this.props.position?.y || 0, options: utils_1.defaultArg.vl(true) },
|
|
77
|
+
w: { v: this.props.size.width },
|
|
78
|
+
});
|
|
79
|
+
const h = parcer.parse(this.props.size.height, utils_1.defaultArg.wh(w), utils_1.defaultArg.vl(true));
|
|
80
|
+
let { x, y } = (0, utils_1.centring)(this.props.centring, this.type, w, h, xs, ys);
|
|
81
|
+
let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.color, {
|
|
82
|
+
debug,
|
|
83
|
+
layer: { width: w, height: h, x: xs, y: ys, align: this.props.centring },
|
|
84
|
+
manager,
|
|
85
|
+
});
|
|
86
|
+
if (debug)
|
|
87
|
+
utils_1.LazyLog.log("none", `PolygonLayer:`, {
|
|
88
|
+
x,
|
|
89
|
+
y,
|
|
90
|
+
w,
|
|
91
|
+
h,
|
|
92
|
+
count: this.props.size.count,
|
|
93
|
+
radius: this.props.size.radius,
|
|
94
|
+
});
|
|
95
|
+
ctx.save();
|
|
96
|
+
ctx.beginPath();
|
|
97
|
+
// Calculate polygon vertices
|
|
98
|
+
const vertices = [];
|
|
99
|
+
for (let i = 0; i < this.props.size.count; i++) {
|
|
100
|
+
const angle = (i / this.props.size.count) * (2 * Math.PI) - Math.PI / 2;
|
|
101
|
+
vertices.push({
|
|
102
|
+
x: x + w / 2 + (w / 2) * Math.cos(angle),
|
|
103
|
+
y: y + h / 2 + (h / 2) * Math.sin(angle),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (this.props.size.radius > 0) {
|
|
107
|
+
// Draw polygon with rounded corners
|
|
108
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
109
|
+
const current = vertices[i];
|
|
110
|
+
const next = vertices[(i + 1) % vertices.length];
|
|
111
|
+
const prev = vertices[(i - 1 + vertices.length) % vertices.length];
|
|
112
|
+
// Calculate vectors from current vertex to adjacent vertices
|
|
113
|
+
const dx1 = current.x - prev.x;
|
|
114
|
+
const dy1 = current.y - prev.y;
|
|
115
|
+
const dx2 = next.x - current.x;
|
|
116
|
+
const dy2 = next.y - current.y;
|
|
117
|
+
// Normalize vectors
|
|
118
|
+
const len1 = Math.sqrt(dx1 * dx1 + dy1 * dy1);
|
|
119
|
+
const len2 = Math.sqrt(dx2 * dx2 + dy2 * dy2);
|
|
120
|
+
const ndx1 = dx1 / len1;
|
|
121
|
+
const ndy1 = dy1 / len1;
|
|
122
|
+
const ndx2 = dx2 / len2;
|
|
123
|
+
const ndy2 = dy2 / len2;
|
|
124
|
+
// Calculate the maximum radius based on edge lengths
|
|
125
|
+
const maxRadius = Math.max(len1 / 2, len2 / 2);
|
|
126
|
+
const cornerRadius = Math.min(this.props.size.radius, maxRadius);
|
|
127
|
+
// Calculate arc start and end points
|
|
128
|
+
const arcStart = {
|
|
129
|
+
x: current.x - ndx1 * cornerRadius,
|
|
130
|
+
y: current.y - ndy1 * cornerRadius,
|
|
131
|
+
};
|
|
132
|
+
const arcEnd = {
|
|
133
|
+
x: current.x + ndx2 * cornerRadius,
|
|
134
|
+
y: current.y + ndy2 * cornerRadius,
|
|
135
|
+
};
|
|
136
|
+
if (i === 0) {
|
|
137
|
+
ctx.moveTo(arcStart.x, arcStart.y);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
ctx.lineTo(arcStart.x, arcStart.y);
|
|
141
|
+
}
|
|
142
|
+
// Draw arc at corner
|
|
143
|
+
ctx.arcTo(current.x, current.y, arcEnd.x, arcEnd.y, cornerRadius);
|
|
144
|
+
}
|
|
145
|
+
ctx.closePath();
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
// Draw polygon without rounded corners (original behavior)
|
|
149
|
+
for (let i = 0; i < vertices.length; i++) {
|
|
150
|
+
if (i === 0) {
|
|
151
|
+
ctx.moveTo(vertices[i].x, vertices[i].y);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
ctx.lineTo(vertices[i].x, vertices[i].y);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
ctx.closePath();
|
|
158
|
+
}
|
|
159
|
+
utils_1.DrawUtils.drawShadow(ctx, this.props.shadow);
|
|
160
|
+
utils_1.DrawUtils.opacity(ctx, this.props.opacity);
|
|
161
|
+
utils_1.DrawUtils.filters(ctx, this.props.filter);
|
|
162
|
+
utils_1.DrawUtils.fillStyle(ctx, fillStyle, this.props.stroke);
|
|
163
|
+
if (this.props.stroke) {
|
|
164
|
+
ctx.stroke();
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
ctx.fill();
|
|
168
|
+
}
|
|
169
|
+
ctx.restore();
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Converts the Polygon layer to a JSON representation.
|
|
173
|
+
* @returns {IPolygonLayer} The JSON representation of the Polygon layer.
|
|
174
|
+
*/
|
|
175
|
+
toJSON() {
|
|
176
|
+
let data = super.toJSON();
|
|
177
|
+
let copy = { ...this.props };
|
|
178
|
+
for (const key of ["x", "y", "size.width", "size.height", "fillStyle"]) {
|
|
179
|
+
if (copy[key] && typeof copy[key] === "object" && "toJSON" in copy[key]) {
|
|
180
|
+
copy[key] = copy[key].toJSON();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return { ...data, props: copy };
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Validates the properties of the Morph Layer.
|
|
187
|
+
* @param {IPolygonLayerProps} [data] - The properties to validate.
|
|
188
|
+
* @returns {IPolygonLayerProps} The validated properties.
|
|
189
|
+
*/
|
|
190
|
+
validateProps(data) {
|
|
191
|
+
return {
|
|
192
|
+
...super.validateProps(data),
|
|
193
|
+
size: {
|
|
194
|
+
width: data.size?.width || 100,
|
|
195
|
+
height: data.size?.height || 100,
|
|
196
|
+
radius: data.size?.radius || 0,
|
|
197
|
+
count: data.size?.count || 3,
|
|
198
|
+
},
|
|
199
|
+
color: data.color || "#000000",
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
exports.PolygonLayer = PolygonLayer;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseLayer, IBaseLayer, IBaseLayerMisc, IBaseLayerProps } from "./BaseLayer";
|
|
2
|
-
import { ColorType, ScaleType, Point, LayerType } from "../../types";
|
|
2
|
+
import { ColorType, ScaleType, Point, LayerType, StrokeOptions } from "../../types";
|
|
3
3
|
import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
|
|
4
4
|
import { LayersManager } from "../managers";
|
|
5
5
|
/**
|
|
6
|
-
* Interface representing a Quadratic
|
|
6
|
+
* Interface representing a Quadratic layer.
|
|
7
7
|
*/
|
|
8
8
|
export interface IQuadraticLayer extends IBaseLayer {
|
|
9
9
|
/**
|
|
@@ -11,22 +11,36 @@ export interface IQuadraticLayer extends IBaseLayer {
|
|
|
11
11
|
*/
|
|
12
12
|
type: LayerType.QuadraticCurve;
|
|
13
13
|
/**
|
|
14
|
-
* The properties specific to the Quadratic
|
|
14
|
+
* The properties specific to the Quadratic layer.
|
|
15
15
|
*/
|
|
16
16
|
props: IQuadraticLayerProps;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Interface representing the properties of a Quadratic
|
|
19
|
+
* Interface representing the properties of a Quadratic layer.
|
|
20
20
|
*/
|
|
21
21
|
export interface IQuadraticLayerProps extends IBaseLayerProps {
|
|
22
|
+
position: {
|
|
23
|
+
/**
|
|
24
|
+
* The x coordinate of the quadratic curve's starting point.
|
|
25
|
+
*/
|
|
26
|
+
x: ScaleType;
|
|
27
|
+
/**
|
|
28
|
+
* The y coordinate of the quadratic curve's starting point.
|
|
29
|
+
*/
|
|
30
|
+
y: ScaleType;
|
|
31
|
+
/**
|
|
32
|
+
* The end x coordinate of the quadratic curve.
|
|
33
|
+
*/
|
|
34
|
+
endX: ScaleType;
|
|
35
|
+
/**
|
|
36
|
+
* The end y coordinate of the quadratic curve.
|
|
37
|
+
*/
|
|
38
|
+
endY: ScaleType;
|
|
39
|
+
};
|
|
22
40
|
/**
|
|
23
41
|
* The control point of the quadratic curve, including x and y coordinates.
|
|
24
42
|
*/
|
|
25
43
|
controlPoints: Array<Point>;
|
|
26
|
-
/**
|
|
27
|
-
* The end point of the quadratic curve, including x and y coordinates.
|
|
28
|
-
*/
|
|
29
|
-
endPoint: Point;
|
|
30
44
|
/**
|
|
31
45
|
* Whether the layer is filled.
|
|
32
46
|
*/
|
|
@@ -34,48 +48,23 @@ export interface IQuadraticLayerProps extends IBaseLayerProps {
|
|
|
34
48
|
/**
|
|
35
49
|
* The fill style (color or pattern) of the layer.
|
|
36
50
|
*/
|
|
37
|
-
|
|
51
|
+
color: ColorType;
|
|
38
52
|
/**
|
|
39
53
|
* The stroke properties of the quadratic curve.
|
|
40
54
|
*/
|
|
41
|
-
stroke:
|
|
42
|
-
/**
|
|
43
|
-
* The width of the stroke.
|
|
44
|
-
*/
|
|
45
|
-
width: number;
|
|
46
|
-
/**
|
|
47
|
-
* The cap style of the stroke.
|
|
48
|
-
*/
|
|
49
|
-
cap: CanvasLineCap;
|
|
50
|
-
/**
|
|
51
|
-
* The join style of the stroke.
|
|
52
|
-
*/
|
|
53
|
-
join: CanvasLineJoin;
|
|
54
|
-
/**
|
|
55
|
-
* The dash offset of the stroke.
|
|
56
|
-
*/
|
|
57
|
-
dashOffset: number;
|
|
58
|
-
/**
|
|
59
|
-
* The dash pattern of the stroke.
|
|
60
|
-
*/
|
|
61
|
-
dash: number[];
|
|
62
|
-
/**
|
|
63
|
-
* The miter limit of the stroke.
|
|
64
|
-
*/
|
|
65
|
-
miterLimit: number;
|
|
66
|
-
};
|
|
55
|
+
stroke: StrokeOptions;
|
|
67
56
|
}
|
|
68
57
|
/**
|
|
69
|
-
* Class representing a Quadratic
|
|
58
|
+
* Class representing a Quadratic layer, extending the BaseLayer class.
|
|
70
59
|
*/
|
|
71
60
|
export declare class QuadraticLayer extends BaseLayer<IQuadraticLayerProps> {
|
|
72
61
|
/**
|
|
73
|
-
* The properties of the Quadratic
|
|
62
|
+
* The properties of the Quadratic layer.
|
|
74
63
|
*/
|
|
75
64
|
props: IQuadraticLayerProps;
|
|
76
65
|
/**
|
|
77
66
|
* Constructs a new QuadraticLayer instance.
|
|
78
|
-
* @param {IQuadraticLayerProps} [props] - The properties of the Quadratic
|
|
67
|
+
* @param {IQuadraticLayerProps} [props] - The properties of the Quadratic layer.
|
|
79
68
|
* @param {IBaseLayerMisc} [misc] - Miscellaneous options for the layer.
|
|
80
69
|
*/
|
|
81
70
|
constructor(props?: IQuadraticLayerProps, misc?: IBaseLayerMisc);
|
|
@@ -87,12 +76,14 @@ export declare class QuadraticLayer extends BaseLayer<IQuadraticLayerProps> {
|
|
|
87
76
|
*/
|
|
88
77
|
setControlPoint(x: ScaleType, y: ScaleType): this;
|
|
89
78
|
/**
|
|
90
|
-
* Sets the
|
|
79
|
+
* Sets the position of the quadratic layer.
|
|
91
80
|
* @param {ScaleType} [x] - The x-coordinate of the end point.
|
|
92
81
|
* @param {ScaleType} [y] - The y-coordinate of the end point.
|
|
82
|
+
* @param {ScaleType} [endX] - The x-coordinate of the end point.
|
|
83
|
+
* @param {ScaleType} [endY] - The y-coordinate of the end point.
|
|
93
84
|
* @returns {this} The current instance for chaining.
|
|
94
85
|
*/
|
|
95
|
-
|
|
86
|
+
setPosition(x: ScaleType, y: ScaleType, endX?: ScaleType, endY?: ScaleType): this;
|
|
96
87
|
/**
|
|
97
88
|
* Sets the color of the layer.
|
|
98
89
|
* @param {ColorType} [color] - The color of the layer.
|
|
@@ -115,7 +106,7 @@ export declare class QuadraticLayer extends BaseLayer<IQuadraticLayerProps> {
|
|
|
115
106
|
* Calculates the bounding box of the quadratic curve.
|
|
116
107
|
* @param {SKRSContext2D} [ctx] - The canvas rendering context.
|
|
117
108
|
* @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
|
|
118
|
-
* @param {LayersManager} [manager] - The
|
|
109
|
+
* @param {LayersManager} [manager] - The layer's manager.
|
|
119
110
|
* @returns {Object} The bounding box details including max, min, center, width, and height.
|
|
120
111
|
*/
|
|
121
112
|
getBoundingBox(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager): {
|
|
@@ -138,17 +129,17 @@ export declare class QuadraticLayer extends BaseLayer<IQuadraticLayerProps> {
|
|
|
138
129
|
* Draws the quadratic curve on the canvas.
|
|
139
130
|
* @param {SKRSContext2D} [ctx] - The canvas rendering context.
|
|
140
131
|
* @param {Canvas | SvgCanvas} [canvas] - The canvas instance.
|
|
141
|
-
* @param {LayersManager} [manager] - The
|
|
132
|
+
* @param {LayersManager} [manager] - The layer's manager.
|
|
142
133
|
* @param {boolean} [debug] - Whether to enable debug logging.
|
|
143
134
|
*/
|
|
144
135
|
draw(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager: LayersManager, debug: boolean): Promise<void>;
|
|
145
136
|
/**
|
|
146
|
-
* Converts the Quadratic
|
|
147
|
-
* @returns {IQuadraticLayer} The JSON representation of the Quadratic
|
|
137
|
+
* Converts the Quadratic layer to a JSON representation.
|
|
138
|
+
* @returns {IQuadraticLayer} The JSON representation of the Quadratic layer.
|
|
148
139
|
*/
|
|
149
140
|
toJSON(): IQuadraticLayer;
|
|
150
141
|
/**
|
|
151
|
-
* Validates the properties of the Quadratic
|
|
142
|
+
* Validates the properties of the Quadratic layer.
|
|
152
143
|
* @param {IQuadraticLayerProps} [data] - The properties to validate.
|
|
153
144
|
* @returns {IQuadraticLayerProps} The validated properties.
|
|
154
145
|
*/
|