@nmmty/lazycanvas 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ReadMe.md +1 -0
- package/dist/helpers/Filters.d.ts +10 -10
- package/dist/helpers/Fonts.d.ts +1 -1
- package/dist/helpers/FontsList.d.ts +1 -1
- package/dist/helpers/FontsList.js +19 -19
- package/dist/index.d.ts +11 -20
- package/dist/index.js +40 -47
- package/dist/structures/LazyCanvas.d.ts +126 -19
- package/dist/structures/LazyCanvas.js +100 -35
- package/dist/structures/components/BaseLayer.d.ts +188 -38
- package/dist/structures/components/BaseLayer.js +89 -43
- package/dist/structures/components/BezierLayer.d.ts +111 -33
- package/dist/structures/components/BezierLayer.js +72 -32
- package/dist/structures/components/ClearLayer.d.ts +120 -17
- package/dist/structures/components/ClearLayer.js +83 -22
- package/dist/structures/components/Group.d.ts +88 -20
- package/dist/structures/components/Group.js +69 -29
- package/dist/structures/components/ImageLayer.d.ts +76 -12
- package/dist/structures/components/ImageLayer.js +43 -39
- package/dist/structures/components/LineLayer.d.ts +111 -18
- package/dist/structures/components/LineLayer.js +57 -29
- package/dist/structures/components/MorphLayer.d.ts +109 -21
- package/dist/structures/components/MorphLayer.js +52 -33
- package/dist/structures/components/Path2DLayer.d.ts +164 -0
- package/dist/structures/components/Path2DLayer.js +293 -0
- package/dist/structures/components/QuadraticLayer.d.ts +108 -22
- package/dist/structures/components/QuadraticLayer.js +64 -38
- package/dist/structures/components/TextLayer.d.ts +201 -40
- package/dist/structures/components/TextLayer.js +98 -55
- package/dist/structures/components/index.d.ts +10 -0
- package/dist/structures/components/index.js +26 -0
- package/dist/structures/helpers/Exporter.d.ts +52 -0
- package/dist/structures/helpers/Exporter.js +168 -0
- package/dist/structures/helpers/Font.d.ts +64 -10
- package/dist/structures/helpers/Font.js +38 -11
- package/dist/structures/helpers/Gradient.d.ts +96 -9
- package/dist/structures/helpers/Gradient.js +49 -19
- package/dist/structures/helpers/Link.d.ts +52 -8
- package/dist/structures/helpers/Link.js +42 -11
- package/dist/structures/helpers/Pattern.d.ts +52 -7
- package/dist/structures/helpers/Pattern.js +48 -42
- package/dist/structures/helpers/index.d.ts +6 -0
- package/dist/structures/helpers/index.js +22 -0
- package/dist/structures/helpers/readers/JSONReader.d.ts +49 -0
- package/dist/structures/helpers/readers/JSONReader.js +172 -0
- package/dist/structures/helpers/readers/SVGReader.d.ts +20 -0
- package/dist/structures/helpers/readers/SVGReader.js +577 -0
- package/dist/structures/helpers/readers/YAMLReader.d.ts +0 -0
- package/dist/structures/helpers/readers/YAMLReader.js +1 -0
- package/dist/structures/managers/AnimationManager.d.ts +96 -20
- package/dist/structures/managers/AnimationManager.js +54 -26
- package/dist/structures/managers/FontsManager.d.ts +76 -32
- package/dist/structures/managers/FontsManager.js +70 -45
- package/dist/structures/managers/LayersManager.d.ts +84 -32
- package/dist/structures/managers/LayersManager.js +66 -28
- package/dist/structures/managers/RenderManager.d.ts +60 -6
- package/dist/structures/managers/RenderManager.js +120 -40
- package/dist/types/enum.d.ts +11 -6
- package/dist/types/enum.js +17 -12
- package/dist/types/index.d.ts +2 -19
- package/dist/types/index.js +17 -0
- package/dist/utils/LazyUtil.js +2 -2
- package/dist/utils/utils.d.ts +9 -11
- package/dist/utils/utils.js +163 -234
- package/package.json +4 -5
|
@@ -1,19 +1,39 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Font = void 0;
|
|
4
|
-
const
|
|
4
|
+
const types_1 = require("../../types");
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a font with properties such as family, weight, path, and base64.
|
|
7
|
+
*/
|
|
5
8
|
class Font {
|
|
9
|
+
/**
|
|
10
|
+
* The font family.
|
|
11
|
+
*/
|
|
6
12
|
family;
|
|
13
|
+
/**
|
|
14
|
+
* The weight of the font.
|
|
15
|
+
*/
|
|
7
16
|
weight;
|
|
17
|
+
/**
|
|
18
|
+
* The file path of the font (optional).
|
|
19
|
+
*/
|
|
8
20
|
path;
|
|
21
|
+
/**
|
|
22
|
+
* The base64 representation of the font (optional).
|
|
23
|
+
*/
|
|
9
24
|
base64;
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a new Font instance with default values.
|
|
27
|
+
*/
|
|
10
28
|
constructor() {
|
|
11
29
|
this.family = "Arial";
|
|
12
|
-
this.weight =
|
|
30
|
+
this.weight = types_1.FontWeight.Regular;
|
|
13
31
|
}
|
|
14
32
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @param family {string} - The `family` of the font
|
|
33
|
+
* Sets the font family.
|
|
34
|
+
* @param family {string} - The `family` of the font.
|
|
35
|
+
* @returns {this} The current instance for chaining.
|
|
36
|
+
* @throws {Error} If the family is not provided.
|
|
17
37
|
*/
|
|
18
38
|
setFamily(family) {
|
|
19
39
|
if (!family)
|
|
@@ -22,8 +42,10 @@ class Font {
|
|
|
22
42
|
return this;
|
|
23
43
|
}
|
|
24
44
|
/**
|
|
25
|
-
*
|
|
26
|
-
* @param weight {AnyWeight} - The `weight` of the font
|
|
45
|
+
* Sets the font weight.
|
|
46
|
+
* @param weight {AnyWeight} - The `weight` of the font.
|
|
47
|
+
* @returns {this} The current instance for chaining.
|
|
48
|
+
* @throws {Error} If the weight is not provided.
|
|
27
49
|
*/
|
|
28
50
|
setWeight(weight) {
|
|
29
51
|
if (!weight)
|
|
@@ -32,8 +54,10 @@ class Font {
|
|
|
32
54
|
return this;
|
|
33
55
|
}
|
|
34
56
|
/**
|
|
35
|
-
*
|
|
36
|
-
* @param path {string} - The `path` of the font
|
|
57
|
+
* Sets the file path of the font.
|
|
58
|
+
* @param path {string} - The `path` of the font.
|
|
59
|
+
* @returns {this} The current instance for chaining.
|
|
60
|
+
* @throws {Error} If the path is not provided.
|
|
37
61
|
*/
|
|
38
62
|
setPath(path) {
|
|
39
63
|
if (!path)
|
|
@@ -42,8 +66,10 @@ class Font {
|
|
|
42
66
|
return this;
|
|
43
67
|
}
|
|
44
68
|
/**
|
|
45
|
-
*
|
|
46
|
-
* @param base64 {
|
|
69
|
+
* Sets the base64 representation of the font.
|
|
70
|
+
* @param base64 {Buffer} - The `base64` of the font.
|
|
71
|
+
* @returns {this} The current instance for chaining.
|
|
72
|
+
* @throws {Error} If the base64 is not provided.
|
|
47
73
|
*/
|
|
48
74
|
setBase64(base64) {
|
|
49
75
|
if (!base64)
|
|
@@ -52,7 +78,8 @@ class Font {
|
|
|
52
78
|
return this;
|
|
53
79
|
}
|
|
54
80
|
/**
|
|
55
|
-
*
|
|
81
|
+
* Converts the Font instance to a JSON representation.
|
|
82
|
+
* @returns {IFont} The JSON representation of the font.
|
|
56
83
|
*/
|
|
57
84
|
toJSON() {
|
|
58
85
|
return {
|
|
@@ -1,28 +1,115 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnyGradientType, FillType, StringColorType } from "../../types";
|
|
2
2
|
import { SKRSContext2D } from "@napi-rs/canvas";
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing a gradient.
|
|
5
|
+
*/
|
|
6
|
+
export interface IGradient {
|
|
7
|
+
/**
|
|
8
|
+
* The type of fill, which is always `Gradient` for this interface.
|
|
9
|
+
*/
|
|
10
|
+
fillType: FillType;
|
|
11
|
+
/**
|
|
12
|
+
* The type of gradient (e.g., linear, radial, conic).
|
|
13
|
+
*/
|
|
14
|
+
type: AnyGradientType;
|
|
15
|
+
/**
|
|
16
|
+
* The points defining the gradient.
|
|
17
|
+
*/
|
|
18
|
+
points: Array<GradientPoint>;
|
|
19
|
+
/**
|
|
20
|
+
* The color stops for the gradient.
|
|
21
|
+
*/
|
|
22
|
+
stops: Array<GradientColorStop>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Interface representing a color stop in a gradient.
|
|
26
|
+
*/
|
|
27
|
+
export interface GradientColorStop {
|
|
28
|
+
/**
|
|
29
|
+
* The color of the stop in hexadecimal format.
|
|
30
|
+
*/
|
|
31
|
+
color: StringColorType;
|
|
32
|
+
/**
|
|
33
|
+
* The offset of the stop, ranging from 0 to 1.
|
|
34
|
+
*/
|
|
35
|
+
offset: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Interface representing a point in a gradient.
|
|
39
|
+
*/
|
|
40
|
+
export interface GradientPoint {
|
|
41
|
+
/**
|
|
42
|
+
* The x-coordinate of the point.
|
|
43
|
+
*/
|
|
44
|
+
x: number;
|
|
45
|
+
/**
|
|
46
|
+
* The y-coordinate of the point.
|
|
47
|
+
*/
|
|
48
|
+
y: number;
|
|
49
|
+
/**
|
|
50
|
+
* The radius of the point (optional, used for radial gradients).
|
|
51
|
+
*/
|
|
52
|
+
r?: number;
|
|
53
|
+
/**
|
|
54
|
+
* The starting angle of the point (optional, used for conic gradients).
|
|
55
|
+
*/
|
|
56
|
+
startAngle?: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Class representing a gradient with properties and methods to manipulate it.
|
|
60
|
+
*/
|
|
3
61
|
export declare class Gradient implements IGradient {
|
|
62
|
+
/**
|
|
63
|
+
* The type of fill, which is always `Gradient`.
|
|
64
|
+
*/
|
|
65
|
+
fillType: FillType;
|
|
66
|
+
/**
|
|
67
|
+
* The type of gradient (e.g., linear, radial, conic).
|
|
68
|
+
*/
|
|
4
69
|
type: AnyGradientType;
|
|
70
|
+
/**
|
|
71
|
+
* The points defining the gradient.
|
|
72
|
+
*/
|
|
5
73
|
points: Array<GradientPoint>;
|
|
74
|
+
/**
|
|
75
|
+
* The color stops for the gradient.
|
|
76
|
+
*/
|
|
6
77
|
stops: Array<GradientColorStop>;
|
|
7
|
-
constructor();
|
|
8
78
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param
|
|
79
|
+
* Constructs a new Gradient instance.
|
|
80
|
+
* @param opts {Object} - Optional properties for the gradient.
|
|
81
|
+
* @param opts.props {IGradient} - The gradient properties.
|
|
82
|
+
*/
|
|
83
|
+
constructor(opts?: {
|
|
84
|
+
props?: IGradient;
|
|
85
|
+
});
|
|
86
|
+
/**
|
|
87
|
+
* Sets the type of the gradient.
|
|
88
|
+
* @param type {AnyGradientType} - The type of the gradient (e.g., linear, radial, conic).
|
|
89
|
+
* @returns {this} The current instance for chaining.
|
|
11
90
|
*/
|
|
12
91
|
setType(type: AnyGradientType): this;
|
|
13
92
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @param points {GradientPoint[]} - The
|
|
93
|
+
* Adds points to the gradient.
|
|
94
|
+
* @param points {GradientPoint[]} - The points to add to the gradient.
|
|
95
|
+
* @returns {this} The current instance for chaining.
|
|
16
96
|
*/
|
|
17
97
|
addPoints(...points: GradientPoint[]): this;
|
|
18
98
|
/**
|
|
19
|
-
*
|
|
20
|
-
* @param stops {GradientColorStop[]} - The
|
|
99
|
+
* Adds color stops to the gradient.
|
|
100
|
+
* @param stops {GradientColorStop[]} - The color stops to add to the gradient.
|
|
101
|
+
* @returns {this} The current instance for chaining.
|
|
21
102
|
*/
|
|
22
103
|
addStops(...stops: GradientColorStop[]): this;
|
|
104
|
+
/**
|
|
105
|
+
* Draws the gradient on a canvas context.
|
|
106
|
+
* @param ctx {SKRSContext2D} - The canvas rendering context.
|
|
107
|
+
* @returns {CanvasGradient} The created gradient.
|
|
108
|
+
*/
|
|
23
109
|
draw(ctx: SKRSContext2D): CanvasGradient;
|
|
24
110
|
/**
|
|
25
|
-
*
|
|
111
|
+
* Converts the gradient to a JSON representation.
|
|
112
|
+
* @returns {IGradient} The JSON representation of the gradient.
|
|
26
113
|
*/
|
|
27
114
|
toJSON(): IGradient;
|
|
28
115
|
}
|
|
@@ -1,71 +1,101 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Gradient = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const types_1 = require("../../types");
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a gradient with properties and methods to manipulate it.
|
|
7
|
+
*/
|
|
6
8
|
class Gradient {
|
|
9
|
+
/**
|
|
10
|
+
* The type of fill, which is always `Gradient`.
|
|
11
|
+
*/
|
|
12
|
+
fillType = types_1.FillType.Gradient;
|
|
13
|
+
/**
|
|
14
|
+
* The type of gradient (e.g., linear, radial, conic).
|
|
15
|
+
*/
|
|
7
16
|
type;
|
|
17
|
+
/**
|
|
18
|
+
* The points defining the gradient.
|
|
19
|
+
*/
|
|
8
20
|
points;
|
|
21
|
+
/**
|
|
22
|
+
* The color stops for the gradient.
|
|
23
|
+
*/
|
|
9
24
|
stops;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Constructs a new Gradient instance.
|
|
27
|
+
* @param opts {Object} - Optional properties for the gradient.
|
|
28
|
+
* @param opts.props {IGradient} - The gradient properties.
|
|
29
|
+
*/
|
|
30
|
+
constructor(opts) {
|
|
31
|
+
this.type = opts?.props?.type || types_1.GradientType.Linear;
|
|
32
|
+
this.points = opts?.props?.points || [];
|
|
33
|
+
this.stops = opts?.props?.stops || [];
|
|
14
34
|
}
|
|
15
35
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @param type {AnyGradientType} - The
|
|
36
|
+
* Sets the type of the gradient.
|
|
37
|
+
* @param type {AnyGradientType} - The type of the gradient (e.g., linear, radial, conic).
|
|
38
|
+
* @returns {this} The current instance for chaining.
|
|
18
39
|
*/
|
|
19
40
|
setType(type) {
|
|
20
41
|
this.type = type;
|
|
21
42
|
return this;
|
|
22
43
|
}
|
|
23
44
|
/**
|
|
24
|
-
*
|
|
25
|
-
* @param points {GradientPoint[]} - The
|
|
45
|
+
* Adds points to the gradient.
|
|
46
|
+
* @param points {GradientPoint[]} - The points to add to the gradient.
|
|
47
|
+
* @returns {this} The current instance for chaining.
|
|
26
48
|
*/
|
|
27
49
|
addPoints(...points) {
|
|
28
50
|
this.points.push(...points);
|
|
29
51
|
return this;
|
|
30
52
|
}
|
|
31
53
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @param stops {GradientColorStop[]} - The
|
|
54
|
+
* Adds color stops to the gradient.
|
|
55
|
+
* @param stops {GradientColorStop[]} - The color stops to add to the gradient.
|
|
56
|
+
* @returns {this} The current instance for chaining.
|
|
34
57
|
*/
|
|
35
58
|
addStops(...stops) {
|
|
36
59
|
this.stops.push(...stops);
|
|
37
60
|
return this;
|
|
38
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Draws the gradient on a canvas context.
|
|
64
|
+
* @param ctx {SKRSContext2D} - The canvas rendering context.
|
|
65
|
+
* @returns {CanvasGradient} The created gradient.
|
|
66
|
+
*/
|
|
39
67
|
draw(ctx) {
|
|
40
68
|
let gradientData = this.toJSON();
|
|
41
69
|
let gradient;
|
|
42
70
|
switch (gradientData.type) {
|
|
43
|
-
case
|
|
71
|
+
case types_1.GradientType.Linear:
|
|
44
72
|
case "linear":
|
|
45
73
|
gradient = ctx.createLinearGradient(gradientData.points[0].x, gradientData.points[0].y, gradientData.points[1].x, gradientData.points[1].y);
|
|
46
74
|
break;
|
|
47
|
-
case
|
|
75
|
+
case types_1.GradientType.Radial:
|
|
48
76
|
case "radial":
|
|
49
|
-
gradient = ctx.createRadialGradient(gradientData.points[0].x, gradientData.points[0].y,
|
|
77
|
+
gradient = ctx.createRadialGradient(gradientData.points[0].x, gradientData.points[0].y, gradientData.points[0].r || 0, gradientData.points[1].x || gradientData.points[0].x, gradientData.points[1].y || gradientData.points[0].y, gradientData.points[1].r || 0);
|
|
50
78
|
break;
|
|
51
|
-
case
|
|
79
|
+
case types_1.GradientType.Conic:
|
|
52
80
|
case "conic":
|
|
53
|
-
gradient = ctx.createConicGradient(
|
|
81
|
+
gradient = ctx.createConicGradient(gradientData.points[0].startAngle || 0, gradientData.points[0].x, gradientData.points[0].y);
|
|
54
82
|
break;
|
|
55
83
|
default:
|
|
56
84
|
gradient = ctx.createLinearGradient(gradientData.points[0].x, gradientData.points[0].y, gradientData.points[1].x, gradientData.points[1].y);
|
|
57
85
|
break;
|
|
58
86
|
}
|
|
59
87
|
for (let stop of gradientData.stops) {
|
|
60
|
-
gradient.addColorStop(stop.offset,
|
|
88
|
+
gradient.addColorStop(stop.offset, stop.color);
|
|
61
89
|
}
|
|
62
90
|
return gradient;
|
|
63
91
|
}
|
|
64
92
|
/**
|
|
65
|
-
*
|
|
93
|
+
* Converts the gradient to a JSON representation.
|
|
94
|
+
* @returns {IGradient} The JSON representation of the gradient.
|
|
66
95
|
*/
|
|
67
96
|
toJSON() {
|
|
68
97
|
return {
|
|
98
|
+
fillType: this.fillType,
|
|
69
99
|
type: this.type,
|
|
70
100
|
points: this.points,
|
|
71
101
|
stops: this.stops,
|
|
@@ -1,22 +1,66 @@
|
|
|
1
|
-
import { AnyLinkType,
|
|
1
|
+
import { AnyLinkType, ScaleType } from "../../types";
|
|
2
|
+
/**
|
|
3
|
+
* Interface representing a link between layers.
|
|
4
|
+
*/
|
|
5
|
+
export interface ILink {
|
|
6
|
+
/**
|
|
7
|
+
* The source layers ID.
|
|
8
|
+
*/
|
|
9
|
+
source: string;
|
|
10
|
+
/**
|
|
11
|
+
* The type of the link (e.g., width, height, etc.).
|
|
12
|
+
*/
|
|
13
|
+
type: AnyLinkType;
|
|
14
|
+
/**
|
|
15
|
+
* The additional spacing applied to the link.
|
|
16
|
+
*/
|
|
17
|
+
additionalSpacing: ScaleType;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Class representing a link between layers with properties and methods to manipulate it.
|
|
21
|
+
*/
|
|
2
22
|
export declare class Link {
|
|
23
|
+
/**
|
|
24
|
+
* The source layers ID.
|
|
25
|
+
*/
|
|
3
26
|
source: string;
|
|
27
|
+
/**
|
|
28
|
+
* The type of the link (e.g., width, height, etc.).
|
|
29
|
+
*/
|
|
4
30
|
type: AnyLinkType;
|
|
31
|
+
/**
|
|
32
|
+
* The additional spacing applied to the link.
|
|
33
|
+
*/
|
|
5
34
|
additionalSpacing: ScaleType;
|
|
6
|
-
constructor(props?: ILink);
|
|
7
35
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param
|
|
36
|
+
* Constructs a new Link instance.
|
|
37
|
+
* @param opts {Object} - Optional properties for the link.
|
|
38
|
+
* @param opts.props {ILink} - The link properties.
|
|
39
|
+
*/
|
|
40
|
+
constructor(opts?: {
|
|
41
|
+
props?: ILink;
|
|
42
|
+
});
|
|
43
|
+
/**
|
|
44
|
+
* Sets the source of the link.
|
|
45
|
+
* @param source {string} - The ID of the layer to link.
|
|
46
|
+
* @returns {this} The current instance for chaining.
|
|
10
47
|
*/
|
|
11
48
|
setSource(source: string): this;
|
|
12
49
|
/**
|
|
13
|
-
*
|
|
14
|
-
* @param type {AnyLinkType} - The
|
|
50
|
+
* Sets the type of the link.
|
|
51
|
+
* @param type {AnyLinkType} - The type of the link.
|
|
52
|
+
* @returns {this} The current instance for chaining.
|
|
15
53
|
*/
|
|
16
54
|
setType(type: AnyLinkType): this;
|
|
17
55
|
/**
|
|
18
|
-
*
|
|
19
|
-
* @param additionalSpacing {ScaleType} - The
|
|
56
|
+
* Sets the additional spacing of the link.
|
|
57
|
+
* @param additionalSpacing {ScaleType} - The additional spacing of the link.
|
|
58
|
+
* @returns {this} The current instance for chaining.
|
|
20
59
|
*/
|
|
21
60
|
setSpacing(additionalSpacing: ScaleType): this;
|
|
61
|
+
/**
|
|
62
|
+
* Converts the Link instance to a JSON representation.
|
|
63
|
+
* @returns {ILink} The JSON representation of the link.
|
|
64
|
+
*/
|
|
65
|
+
toJSON(): ILink;
|
|
22
66
|
}
|
|
@@ -1,39 +1,70 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Link = void 0;
|
|
4
|
-
const
|
|
4
|
+
const types_1 = require("../../types");
|
|
5
|
+
/**
|
|
6
|
+
* Class representing a link between layers with properties and methods to manipulate it.
|
|
7
|
+
*/
|
|
5
8
|
class Link {
|
|
9
|
+
/**
|
|
10
|
+
* The source layers ID.
|
|
11
|
+
*/
|
|
6
12
|
source;
|
|
13
|
+
/**
|
|
14
|
+
* The type of the link (e.g., width, height, etc.).
|
|
15
|
+
*/
|
|
7
16
|
type;
|
|
17
|
+
/**
|
|
18
|
+
* The additional spacing applied to the link.
|
|
19
|
+
*/
|
|
8
20
|
additionalSpacing;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Constructs a new Link instance.
|
|
23
|
+
* @param opts {Object} - Optional properties for the link.
|
|
24
|
+
* @param opts.props {ILink} - The link properties.
|
|
25
|
+
*/
|
|
26
|
+
constructor(opts) {
|
|
27
|
+
this.source = opts?.props?.source || '';
|
|
28
|
+
this.type = opts?.props?.type || types_1.LinkType.Width;
|
|
29
|
+
this.additionalSpacing = opts?.props?.additionalSpacing || 0;
|
|
13
30
|
}
|
|
14
31
|
/**
|
|
15
|
-
*
|
|
16
|
-
* @param source {string} - The
|
|
32
|
+
* Sets the source of the link.
|
|
33
|
+
* @param source {string} - The ID of the layer to link.
|
|
34
|
+
* @returns {this} The current instance for chaining.
|
|
17
35
|
*/
|
|
18
36
|
setSource(source) {
|
|
19
37
|
this.source = source;
|
|
20
38
|
return this;
|
|
21
39
|
}
|
|
22
40
|
/**
|
|
23
|
-
*
|
|
24
|
-
* @param type {AnyLinkType} - The
|
|
41
|
+
* Sets the type of the link.
|
|
42
|
+
* @param type {AnyLinkType} - The type of the link.
|
|
43
|
+
* @returns {this} The current instance for chaining.
|
|
25
44
|
*/
|
|
26
45
|
setType(type) {
|
|
27
46
|
this.type = type;
|
|
28
47
|
return this;
|
|
29
48
|
}
|
|
30
49
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @param additionalSpacing {ScaleType} - The
|
|
50
|
+
* Sets the additional spacing of the link.
|
|
51
|
+
* @param additionalSpacing {ScaleType} - The additional spacing of the link.
|
|
52
|
+
* @returns {this} The current instance for chaining.
|
|
33
53
|
*/
|
|
34
54
|
setSpacing(additionalSpacing) {
|
|
35
55
|
this.additionalSpacing = additionalSpacing;
|
|
36
56
|
return this;
|
|
37
57
|
}
|
|
58
|
+
/**
|
|
59
|
+
* Converts the Link instance to a JSON representation.
|
|
60
|
+
* @returns {ILink} The JSON representation of the link.
|
|
61
|
+
*/
|
|
62
|
+
toJSON() {
|
|
63
|
+
return {
|
|
64
|
+
source: this.source,
|
|
65
|
+
type: this.type,
|
|
66
|
+
additionalSpacing: this.additionalSpacing
|
|
67
|
+
};
|
|
68
|
+
}
|
|
38
69
|
}
|
|
39
70
|
exports.Link = Link;
|
|
@@ -1,23 +1,68 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FillType, AnyPatternType } from "../../types";
|
|
2
2
|
import { LazyCanvas } from "../LazyCanvas";
|
|
3
3
|
import { SKRSContext2D } from "@napi-rs/canvas";
|
|
4
|
+
/**
|
|
5
|
+
* Interface representing a pattern.
|
|
6
|
+
*/
|
|
7
|
+
export interface IPattern {
|
|
8
|
+
/**
|
|
9
|
+
* The type of fill, which is always `Pattern` for this interface.
|
|
10
|
+
*/
|
|
11
|
+
fillType: FillType;
|
|
12
|
+
/**
|
|
13
|
+
* The type of the pattern (e.g., repeat, no-repeat, etc.).
|
|
14
|
+
*/
|
|
15
|
+
type: AnyPatternType;
|
|
16
|
+
/**
|
|
17
|
+
* The source of the pattern, which can be a string (URL or path) or a LazyCanvas instance.
|
|
18
|
+
*/
|
|
19
|
+
src: string | LazyCanvas;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Class representing a pattern with properties and methods to manipulate it.
|
|
23
|
+
*/
|
|
4
24
|
export declare class Pattern implements IPattern {
|
|
25
|
+
/**
|
|
26
|
+
* The type of fill, which is always `Pattern`.
|
|
27
|
+
*/
|
|
28
|
+
fillType: FillType;
|
|
29
|
+
/**
|
|
30
|
+
* The type of the pattern (e.g., repeat, no-repeat, etc.).
|
|
31
|
+
*/
|
|
5
32
|
type: AnyPatternType;
|
|
33
|
+
/**
|
|
34
|
+
* The source of the pattern, which can be a string (URL or path) or a LazyCanvas instance.
|
|
35
|
+
*/
|
|
6
36
|
src: string | LazyCanvas;
|
|
7
|
-
constructor();
|
|
8
37
|
/**
|
|
9
|
-
*
|
|
10
|
-
* @param
|
|
38
|
+
* Constructs a new Pattern instance.
|
|
39
|
+
* @param opts {Object} - Optional properties for the pattern.
|
|
40
|
+
* @param opts.props {IPattern} - The pattern properties.
|
|
41
|
+
*/
|
|
42
|
+
constructor(opts?: {
|
|
43
|
+
props?: IPattern;
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Sets the type of the pattern.
|
|
47
|
+
* @param type {AnyPatternType} - The type of the pattern (e.g., repeat, no-repeat).
|
|
48
|
+
* @returns {this} The current instance for chaining.
|
|
11
49
|
*/
|
|
12
50
|
setType(type: AnyPatternType): this;
|
|
13
51
|
/**
|
|
14
|
-
*
|
|
15
|
-
* @param src {string | LazyCanvas} - The
|
|
52
|
+
* Sets the source of the pattern.
|
|
53
|
+
* @param src {string | LazyCanvas} - The source of the pattern, which can be a string (URL or path) or a LazyCanvas instance.
|
|
54
|
+
* @returns {this} The current instance for chaining.
|
|
16
55
|
*/
|
|
17
56
|
setSrc(src: string | LazyCanvas): this;
|
|
57
|
+
/**
|
|
58
|
+
* Draws the pattern on a canvas context.
|
|
59
|
+
* @param ctx {SKRSContext2D} - The canvas rendering context.
|
|
60
|
+
* @returns {Promise<CanvasPattern>} The created pattern.
|
|
61
|
+
*/
|
|
18
62
|
draw(ctx: SKRSContext2D): Promise<CanvasPattern>;
|
|
19
63
|
/**
|
|
20
|
-
*
|
|
64
|
+
* Converts the Pattern instance to a JSON representation.
|
|
65
|
+
* @returns {IPattern} The JSON representation of the pattern.
|
|
21
66
|
*/
|
|
22
67
|
toJSON(): IPattern;
|
|
23
68
|
}
|