@nmmty/lazycanvas 0.3.2 → 0.3.4
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/FontsList.d.ts +98 -0
- package/dist/helpers/FontsList.js +65 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.js +10 -3
- package/dist/structures/LazyCanvas.d.ts +4 -5
- package/dist/structures/LazyCanvas.js +1 -1
- package/dist/structures/components/BaseLayer.d.ts +4 -4
- package/dist/structures/components/BaseLayer.js +1 -1
- package/dist/structures/components/BezierLayer.d.ts +16 -0
- package/dist/structures/components/BezierLayer.js +26 -8
- package/dist/structures/components/ImageLayer.js +8 -5
- package/dist/structures/components/LineLayer.d.ts +8 -0
- package/dist/structures/components/LineLayer.js +21 -4
- package/dist/structures/components/MorphLayer.js +8 -5
- package/dist/structures/components/QuadraticLayer.d.ts +16 -0
- package/dist/structures/components/QuadraticLayer.js +22 -6
- package/dist/structures/components/TextLayer.d.ts +15 -11
- package/dist/structures/components/TextLayer.js +41 -27
- package/dist/structures/helpers/Font.d.ts +4 -4
- package/dist/structures/helpers/Font.js +2 -2
- package/dist/structures/helpers/Gradient.d.ts +4 -5
- package/dist/structures/helpers/Gradient.js +4 -1
- package/dist/structures/helpers/Link.d.ts +22 -0
- package/dist/structures/helpers/Link.js +39 -0
- package/dist/structures/helpers/Pattern.d.ts +4 -5
- package/dist/structures/helpers/Pattern.js +1 -1
- package/dist/structures/managers/FontsManager.d.ts +1 -1
- package/dist/structures/managers/FontsManager.js +1 -2
- package/dist/structures/managers/RenderManager.js +3 -0
- package/dist/types/LazyCanvas.d.ts +2 -2
- package/dist/types/components/BaseLayer.d.ts +3 -3
- package/dist/types/components/Group.d.ts +3 -1
- package/dist/types/components/MorphLayer.d.ts +1 -1
- package/dist/types/components/TextLayer.d.ts +8 -7
- package/dist/types/enum.d.ts +7 -1
- package/dist/types/enum.js +9 -2
- package/dist/types/helpers/Font.d.ts +2 -2
- package/dist/types/helpers/Gradient.d.ts +2 -2
- package/dist/types/helpers/Link.d.ts +7 -0
- package/dist/types/helpers/Pattern.d.ts +2 -2
- package/dist/types/index.d.ts +17 -16
- package/dist/types/types.d.ts +42 -2
- package/dist/utils/LazyUtil.d.ts +10 -0
- package/dist/utils/LazyUtil.js +9 -1
- package/dist/utils/utils.d.ts +24 -4
- package/dist/utils/utils.js +152 -28
- package/package.json +4 -2
- package/example.png +0 -0
- /package/dist/helpers/{filters.d.ts → Filters.d.ts} +0 -0
- /package/dist/helpers/{filters.js → Filters.js} +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { FontWeight } from "../types/enum";
|
|
2
|
+
/**
|
|
3
|
+
* The bundled fonts in this package.
|
|
4
|
+
* Used fonts:
|
|
5
|
+
* @see https://vercel.com/font
|
|
6
|
+
*/
|
|
7
|
+
export declare const FontsList: {
|
|
8
|
+
Geist_Thin(size: number): {
|
|
9
|
+
family: string;
|
|
10
|
+
size: number;
|
|
11
|
+
weight: FontWeight;
|
|
12
|
+
};
|
|
13
|
+
Geist_ExtraLight(size: number): {
|
|
14
|
+
family: string;
|
|
15
|
+
size: number;
|
|
16
|
+
weight: FontWeight;
|
|
17
|
+
};
|
|
18
|
+
Geist_Light(size: number): {
|
|
19
|
+
family: string;
|
|
20
|
+
size: number;
|
|
21
|
+
weight: FontWeight;
|
|
22
|
+
};
|
|
23
|
+
Geist_Regular(size: number): {
|
|
24
|
+
family: string;
|
|
25
|
+
size: number;
|
|
26
|
+
weight: FontWeight;
|
|
27
|
+
};
|
|
28
|
+
Geist_Medium(size: number): {
|
|
29
|
+
family: string;
|
|
30
|
+
size: number;
|
|
31
|
+
weight: FontWeight;
|
|
32
|
+
};
|
|
33
|
+
Geist_SemiBold(size: number): {
|
|
34
|
+
family: string;
|
|
35
|
+
size: number;
|
|
36
|
+
weight: FontWeight;
|
|
37
|
+
};
|
|
38
|
+
Geist_Bold(size: number): {
|
|
39
|
+
family: string;
|
|
40
|
+
size: number;
|
|
41
|
+
weight: FontWeight;
|
|
42
|
+
};
|
|
43
|
+
Geist_ExtraBold(size: number): {
|
|
44
|
+
family: string;
|
|
45
|
+
size: number;
|
|
46
|
+
weight: FontWeight;
|
|
47
|
+
};
|
|
48
|
+
Geist_Black(size: number): {
|
|
49
|
+
family: string;
|
|
50
|
+
size: number;
|
|
51
|
+
weight: FontWeight;
|
|
52
|
+
};
|
|
53
|
+
GeistMono_Thin(size: number): {
|
|
54
|
+
family: string;
|
|
55
|
+
size: number;
|
|
56
|
+
weight: FontWeight;
|
|
57
|
+
};
|
|
58
|
+
GeistMono_ExtraLight(size: number): {
|
|
59
|
+
family: string;
|
|
60
|
+
size: number;
|
|
61
|
+
weight: FontWeight;
|
|
62
|
+
};
|
|
63
|
+
GeistMono_Light(size: number): {
|
|
64
|
+
family: string;
|
|
65
|
+
size: number;
|
|
66
|
+
weight: FontWeight;
|
|
67
|
+
};
|
|
68
|
+
GeistMono_Regular(size: number): {
|
|
69
|
+
family: string;
|
|
70
|
+
size: number;
|
|
71
|
+
weight: FontWeight;
|
|
72
|
+
};
|
|
73
|
+
GeistMono_Medium(size: number): {
|
|
74
|
+
family: string;
|
|
75
|
+
size: number;
|
|
76
|
+
weight: FontWeight;
|
|
77
|
+
};
|
|
78
|
+
GeistMono_SemiBold(size: number): {
|
|
79
|
+
family: string;
|
|
80
|
+
size: number;
|
|
81
|
+
weight: FontWeight;
|
|
82
|
+
};
|
|
83
|
+
GeistMono_Bold(size: number): {
|
|
84
|
+
family: string;
|
|
85
|
+
size: number;
|
|
86
|
+
weight: FontWeight;
|
|
87
|
+
};
|
|
88
|
+
GeistMono_Black(size: number): {
|
|
89
|
+
family: string;
|
|
90
|
+
size: number;
|
|
91
|
+
weight: FontWeight;
|
|
92
|
+
};
|
|
93
|
+
GeistMono_ExtraBlack(size: number): {
|
|
94
|
+
family: string;
|
|
95
|
+
size: number;
|
|
96
|
+
weight: FontWeight;
|
|
97
|
+
};
|
|
98
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FontsList = void 0;
|
|
4
|
+
const enum_1 = require("../types/enum");
|
|
5
|
+
/**
|
|
6
|
+
* The bundled fonts in this package.
|
|
7
|
+
* Used fonts:
|
|
8
|
+
* @see https://vercel.com/font
|
|
9
|
+
*/
|
|
10
|
+
exports.FontsList = {
|
|
11
|
+
Geist_Thin(size) {
|
|
12
|
+
return { family: 'Geist', size, weight: enum_1.FontWeight.Thin };
|
|
13
|
+
},
|
|
14
|
+
Geist_ExtraLight(size) {
|
|
15
|
+
return { family: 'Geist', size, weight: enum_1.FontWeight.ExtraLight };
|
|
16
|
+
},
|
|
17
|
+
Geist_Light(size) {
|
|
18
|
+
return { family: 'Geist', size, weight: enum_1.FontWeight.Light };
|
|
19
|
+
},
|
|
20
|
+
Geist_Regular(size) {
|
|
21
|
+
return { family: 'Geist', size, weight: enum_1.FontWeight.Regular };
|
|
22
|
+
},
|
|
23
|
+
Geist_Medium(size) {
|
|
24
|
+
return { family: 'Geist', size, weight: enum_1.FontWeight.Medium };
|
|
25
|
+
},
|
|
26
|
+
Geist_SemiBold(size) {
|
|
27
|
+
return { family: 'Geist', size, weight: enum_1.FontWeight.SemiBold };
|
|
28
|
+
},
|
|
29
|
+
Geist_Bold(size) {
|
|
30
|
+
return { family: 'Geist', size, weight: enum_1.FontWeight.Bold };
|
|
31
|
+
},
|
|
32
|
+
Geist_ExtraBold(size) {
|
|
33
|
+
return { family: 'Geist', size, weight: enum_1.FontWeight.ExtraBold };
|
|
34
|
+
},
|
|
35
|
+
Geist_Black(size) {
|
|
36
|
+
return { family: 'Geist', size, weight: enum_1.FontWeight.Black };
|
|
37
|
+
},
|
|
38
|
+
GeistMono_Thin(size) {
|
|
39
|
+
return { family: 'GeistMono', size, weight: enum_1.FontWeight.Thin };
|
|
40
|
+
},
|
|
41
|
+
GeistMono_ExtraLight(size) {
|
|
42
|
+
return { family: 'GeistMono', size, weight: enum_1.FontWeight.ExtraLight };
|
|
43
|
+
},
|
|
44
|
+
GeistMono_Light(size) {
|
|
45
|
+
return { family: 'GeistMono', size, weight: enum_1.FontWeight.Light };
|
|
46
|
+
},
|
|
47
|
+
GeistMono_Regular(size) {
|
|
48
|
+
return { family: 'GeistMono', size, weight: enum_1.FontWeight.Regular };
|
|
49
|
+
},
|
|
50
|
+
GeistMono_Medium(size) {
|
|
51
|
+
return { family: 'GeistMono', size, weight: enum_1.FontWeight.Medium };
|
|
52
|
+
},
|
|
53
|
+
GeistMono_SemiBold(size) {
|
|
54
|
+
return { family: 'GeistMono', size, weight: enum_1.FontWeight.SemiBold };
|
|
55
|
+
},
|
|
56
|
+
GeistMono_Bold(size) {
|
|
57
|
+
return { family: 'GeistMono', size, weight: enum_1.FontWeight.Bold };
|
|
58
|
+
},
|
|
59
|
+
GeistMono_Black(size) {
|
|
60
|
+
return { family: 'GeistMono', size, weight: enum_1.FontWeight.Black };
|
|
61
|
+
},
|
|
62
|
+
GeistMono_ExtraBlack(size) {
|
|
63
|
+
return { family: 'GeistMono', size, weight: enum_1.FontWeight.ExtraBlack };
|
|
64
|
+
},
|
|
65
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -4,13 +4,17 @@ import { MorphLayer } from "./structures/components/MorphLayer";
|
|
|
4
4
|
import { TextLayer } from "./structures/components/TextLayer";
|
|
5
5
|
import { BezierLayer } from "./structures/components/BezierLayer";
|
|
6
6
|
import { QuadraticLayer } from "./structures/components/QuadraticLayer";
|
|
7
|
+
import { LineLayer } from "./structures/components/LineLayer";
|
|
7
8
|
import { BaseLayer } from "./structures/components/BaseLayer";
|
|
8
9
|
import { Group } from "./structures/components/Group";
|
|
9
|
-
import { LayerType, LayerScaleType, LineCap, LineJoin, TextAlign, TextDirection, TextBaseline, FontWeight, Export, Centring, PatternType, SaveFormat, GradientType } from "./types/enum";
|
|
10
|
-
import type { AnyLayer, ScaleType, ColorType, IFont, IFonts, IGradient, IPattern, IImageLayer, IImageLayerProps, IMorphLayer, IMorphLayerProps, ITextLayer, ITextLayerProps, IBezierLayer, IBezierLayerProps, IQuadraticLayer, IQuadraticLayerProps, IBaseLayer, IBaseLayerProps, IGroup } from "./types";
|
|
10
|
+
import { LayerType, LayerScaleType, LineCap, LineJoin, TextAlign, TextDirection, TextBaseline, FontWeight, Export, Centring, PatternType, SaveFormat, GradientType, LinkType } from "./types/enum";
|
|
11
|
+
import type { AnyLayer, AnyCentring, AnyPatternType, AnyGradientType, AnyTextAlign, AnyTextDirection, AnyTextBaseline, AnyWeight, AnyExport, AnyLineCap, AnyLineJoin, AnySaveFormat, AnyLinkType, ScaleType, ColorType, IFont, IFonts, IGradient, IPattern, IImageLayer, IImageLayerProps, IMorphLayer, IMorphLayerProps, ITextLayer, ITextLayerProps, IBezierLayer, IBezierLayerProps, IQuadraticLayer, IQuadraticLayerProps, ILineLayer, ILineLayerProps, IBaseLayer, IBaseLayerProps, IGroup } from "./types";
|
|
11
12
|
import { Font } from "./structures/helpers/Font";
|
|
12
13
|
import { Gradient } from "./structures/helpers/Gradient";
|
|
13
14
|
import { Pattern } from "./structures/helpers/Pattern";
|
|
15
|
+
import { Link } from "./structures/helpers/Link";
|
|
14
16
|
import { saveFile } from "./utils/utils";
|
|
15
|
-
import { Filters } from "./helpers/
|
|
16
|
-
|
|
17
|
+
import { Filters } from "./helpers/Filters";
|
|
18
|
+
import { FontsList } from "./helpers/FontsList";
|
|
19
|
+
export { LazyCanvas, ImageLayer, MorphLayer, TextLayer, BezierLayer, QuadraticLayer, LineLayer, BaseLayer, Group, Font, Gradient, Pattern, Link, LayerScaleType, LayerType, FontWeight, GradientType, Export, LineCap, LineJoin, TextAlign, TextDirection, TextBaseline, SaveFormat, Centring, PatternType, LinkType, saveFile, Filters, FontsList, };
|
|
20
|
+
export type { IFont, IFonts, IGradient, IPattern, IImageLayer, IImageLayerProps, IMorphLayer, IMorphLayerProps, ITextLayer, ITextLayerProps, IBaseLayer, IBaseLayerProps, IBezierLayer, IBezierLayerProps, IQuadraticLayer, IQuadraticLayerProps, ILineLayer, ILineLayerProps, IGroup, AnyLayer, AnyCentring, AnyPatternType, AnyGradientType, AnyTextAlign, AnyTextDirection, AnyTextBaseline, AnyWeight, AnyExport, AnyLineCap, AnyLineJoin, AnySaveFormat, AnyLinkType, ScaleType, ColorType };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Filters = exports.saveFile = exports.PatternType = exports.Centring = exports.SaveFormat = exports.TextBaseline = exports.TextDirection = exports.TextAlign = exports.LineJoin = exports.LineCap = exports.Export = exports.GradientType = exports.FontWeight = exports.LayerType = exports.LayerScaleType = exports.Pattern = exports.Gradient = exports.Font = exports.Group = exports.BaseLayer = exports.QuadraticLayer = exports.BezierLayer = exports.TextLayer = exports.MorphLayer = exports.ImageLayer = exports.LazyCanvas = void 0;
|
|
3
|
+
exports.FontsList = exports.Filters = exports.saveFile = exports.LinkType = exports.PatternType = exports.Centring = exports.SaveFormat = exports.TextBaseline = exports.TextDirection = exports.TextAlign = exports.LineJoin = exports.LineCap = exports.Export = exports.GradientType = exports.FontWeight = exports.LayerType = exports.LayerScaleType = exports.Link = exports.Pattern = exports.Gradient = exports.Font = exports.Group = exports.BaseLayer = exports.LineLayer = exports.QuadraticLayer = exports.BezierLayer = exports.TextLayer = exports.MorphLayer = exports.ImageLayer = exports.LazyCanvas = void 0;
|
|
4
4
|
const LazyCanvas_1 = require("./structures/LazyCanvas");
|
|
5
5
|
Object.defineProperty(exports, "LazyCanvas", { enumerable: true, get: function () { return LazyCanvas_1.LazyCanvas; } });
|
|
6
6
|
const ImageLayer_1 = require("./structures/components/ImageLayer");
|
|
@@ -13,6 +13,8 @@ const BezierLayer_1 = require("./structures/components/BezierLayer");
|
|
|
13
13
|
Object.defineProperty(exports, "BezierLayer", { enumerable: true, get: function () { return BezierLayer_1.BezierLayer; } });
|
|
14
14
|
const QuadraticLayer_1 = require("./structures/components/QuadraticLayer");
|
|
15
15
|
Object.defineProperty(exports, "QuadraticLayer", { enumerable: true, get: function () { return QuadraticLayer_1.QuadraticLayer; } });
|
|
16
|
+
const LineLayer_1 = require("./structures/components/LineLayer");
|
|
17
|
+
Object.defineProperty(exports, "LineLayer", { enumerable: true, get: function () { return LineLayer_1.LineLayer; } });
|
|
16
18
|
const BaseLayer_1 = require("./structures/components/BaseLayer");
|
|
17
19
|
Object.defineProperty(exports, "BaseLayer", { enumerable: true, get: function () { return BaseLayer_1.BaseLayer; } });
|
|
18
20
|
const Group_1 = require("./structures/components/Group");
|
|
@@ -31,13 +33,18 @@ Object.defineProperty(exports, "Centring", { enumerable: true, get: function ()
|
|
|
31
33
|
Object.defineProperty(exports, "PatternType", { enumerable: true, get: function () { return enum_1.PatternType; } });
|
|
32
34
|
Object.defineProperty(exports, "SaveFormat", { enumerable: true, get: function () { return enum_1.SaveFormat; } });
|
|
33
35
|
Object.defineProperty(exports, "GradientType", { enumerable: true, get: function () { return enum_1.GradientType; } });
|
|
36
|
+
Object.defineProperty(exports, "LinkType", { enumerable: true, get: function () { return enum_1.LinkType; } });
|
|
34
37
|
const Font_1 = require("./structures/helpers/Font");
|
|
35
38
|
Object.defineProperty(exports, "Font", { enumerable: true, get: function () { return Font_1.Font; } });
|
|
36
39
|
const Gradient_1 = require("./structures/helpers/Gradient");
|
|
37
40
|
Object.defineProperty(exports, "Gradient", { enumerable: true, get: function () { return Gradient_1.Gradient; } });
|
|
38
41
|
const Pattern_1 = require("./structures/helpers/Pattern");
|
|
39
42
|
Object.defineProperty(exports, "Pattern", { enumerable: true, get: function () { return Pattern_1.Pattern; } });
|
|
43
|
+
const Link_1 = require("./structures/helpers/Link");
|
|
44
|
+
Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return Link_1.Link; } });
|
|
40
45
|
const utils_1 = require("./utils/utils");
|
|
41
46
|
Object.defineProperty(exports, "saveFile", { enumerable: true, get: function () { return utils_1.saveFile; } });
|
|
42
|
-
const
|
|
43
|
-
Object.defineProperty(exports, "Filters", { enumerable: true, get: function () { return
|
|
47
|
+
const Filters_1 = require("./helpers/Filters");
|
|
48
|
+
Object.defineProperty(exports, "Filters", { enumerable: true, get: function () { return Filters_1.Filters; } });
|
|
49
|
+
const FontsList_1 = require("./helpers/FontsList");
|
|
50
|
+
Object.defineProperty(exports, "FontsList", { enumerable: true, get: function () { return FontsList_1.FontsList; } });
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ILazyCanvas } from "../types";
|
|
1
|
+
import { AnyExport, ILazyCanvas } from "../types";
|
|
3
2
|
import { Canvas, SKRSContext2D, SvgExportFlag } from "@napi-rs/canvas";
|
|
4
3
|
import { LayersManager } from "./managers/LayersManager";
|
|
5
4
|
import { RenderManager } from "./managers/RenderManager";
|
|
@@ -12,13 +11,13 @@ export declare class LazyCanvas implements ILazyCanvas {
|
|
|
12
11
|
layers: LayersManager;
|
|
13
12
|
render: RenderManager;
|
|
14
13
|
fonts: FontsManager;
|
|
15
|
-
exportType:
|
|
14
|
+
exportType: AnyExport;
|
|
16
15
|
constructor(debug?: boolean);
|
|
17
16
|
/**
|
|
18
17
|
* Set the export type
|
|
19
|
-
* @param type {
|
|
18
|
+
* @param type {AnyExport} - The `export` type
|
|
20
19
|
*/
|
|
21
|
-
setExportType(type:
|
|
20
|
+
setExportType(type: AnyExport): this;
|
|
22
21
|
/**
|
|
23
22
|
* Set the SVG export flag. This method should be called after `setExportType` method.
|
|
24
23
|
* @param flag {SvgExportFlag} - The `flag` of the SVG export
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ScaleType, IBaseLayer, IBaseLayerProps } from "../../types";
|
|
2
|
-
import {
|
|
1
|
+
import { ScaleType, IBaseLayer, IBaseLayerProps, AnyCentring } from "../../types";
|
|
2
|
+
import { LayerType } from "../../types/enum";
|
|
3
3
|
export declare class BaseLayer<T extends IBaseLayerProps> {
|
|
4
4
|
id: string;
|
|
5
5
|
type: LayerType;
|
|
@@ -61,9 +61,9 @@ export declare class BaseLayer<T extends IBaseLayerProps> {
|
|
|
61
61
|
setFilters(...filter: string[]): this;
|
|
62
62
|
/**
|
|
63
63
|
* @description Sets type of centring of the layer.
|
|
64
|
-
* @param centring {
|
|
64
|
+
* @param centring {AnyCentring} - The `centring` of the layer
|
|
65
65
|
*/
|
|
66
|
-
setCentring(centring:
|
|
66
|
+
setCentring(centring: AnyCentring): this;
|
|
67
67
|
/**
|
|
68
68
|
* @description Sets the visibility of the layer.
|
|
69
69
|
* @param visible {boolean} - The `visibility` of the layer
|
|
@@ -119,7 +119,7 @@ class BaseLayer {
|
|
|
119
119
|
}
|
|
120
120
|
/**
|
|
121
121
|
* @description Sets type of centring of the layer.
|
|
122
|
-
* @param centring {
|
|
122
|
+
* @param centring {AnyCentring} - The `centring` of the layer
|
|
123
123
|
*/
|
|
124
124
|
setCentring(centring) {
|
|
125
125
|
this.props.centring = centring;
|
|
@@ -34,6 +34,22 @@ export declare class BezierLayer extends BaseLayer<IBezierLayerProps> {
|
|
|
34
34
|
* @param miterLimit {number} - The `miterLimit` of the stroke.
|
|
35
35
|
*/
|
|
36
36
|
setStroke(width: number, cap?: CanvasLineCap, join?: CanvasLineJoin, dash?: number[], dashOffset?: number, miterLimit?: number): this;
|
|
37
|
+
getBoundingBox(ctx: SKRSContext2D, canvas: Canvas, manager: LayersManager): {
|
|
38
|
+
max: {
|
|
39
|
+
x: number;
|
|
40
|
+
y: number;
|
|
41
|
+
};
|
|
42
|
+
min: {
|
|
43
|
+
x: number;
|
|
44
|
+
y: number;
|
|
45
|
+
};
|
|
46
|
+
center: {
|
|
47
|
+
x: number;
|
|
48
|
+
y: number;
|
|
49
|
+
};
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
};
|
|
37
53
|
draw(ctx: SKRSContext2D, canvas: Canvas, manager: LayersManager, debug: boolean): Promise<void>;
|
|
38
54
|
/**
|
|
39
55
|
* @returns {IBezierLayer}
|
|
@@ -75,15 +75,33 @@ class BezierLayer extends BaseLayer_1.BaseLayer {
|
|
|
75
75
|
};
|
|
76
76
|
return this;
|
|
77
77
|
}
|
|
78
|
+
getBoundingBox(ctx, canvas, manager) {
|
|
79
|
+
const parcer = (0, utils_1.parser)(ctx, canvas, manager);
|
|
80
|
+
const { xs, ys, cp1x, cp1y, cp2x, cp2y, xe, ye } = parcer.parseBatch({
|
|
81
|
+
xs: { v: this.props.x },
|
|
82
|
+
ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
83
|
+
cp1x: { v: this.props.controlPoints[0].x },
|
|
84
|
+
cp1y: { v: this.props.controlPoints[0].y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
85
|
+
cp2x: { v: this.props.controlPoints[1].x },
|
|
86
|
+
cp2y: { v: this.props.controlPoints[1].y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
87
|
+
xe: { v: this.props.endPoint.x },
|
|
88
|
+
ye: { v: this.props.endPoint.y, options: LazyUtil_1.defaultArg.vl(true) }
|
|
89
|
+
});
|
|
90
|
+
const { max, min, center, width, height } = (0, utils_1.getBoundingBoxBezier)([{ x: xs, y: ys }, { x: cp1x, y: cp1y }, { x: cp2x, y: cp2y }, { x: xe, y: ye }]);
|
|
91
|
+
return { max, min, center, width, height };
|
|
92
|
+
}
|
|
78
93
|
async draw(ctx, canvas, manager, debug) {
|
|
79
|
-
const
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
94
|
+
const parcer = (0, utils_1.parser)(ctx, canvas, manager);
|
|
95
|
+
const { xs, ys, cp1x, cp1y, cp2x, cp2y, xe, ye } = parcer.parseBatch({
|
|
96
|
+
xs: { v: this.props.x },
|
|
97
|
+
ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
98
|
+
cp1x: { v: this.props.controlPoints[0].x },
|
|
99
|
+
cp1y: { v: this.props.controlPoints[0].y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
100
|
+
cp2x: { v: this.props.controlPoints[1].x },
|
|
101
|
+
cp2y: { v: this.props.controlPoints[1].y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
102
|
+
xe: { v: this.props.endPoint.x },
|
|
103
|
+
ye: { v: this.props.endPoint.y, options: LazyUtil_1.defaultArg.vl(true) }
|
|
104
|
+
});
|
|
87
105
|
const { max, min, center, width, height } = (0, utils_1.getBoundingBoxBezier)([{ x: xs, y: ys }, { x: cp1x, y: cp1y }, { x: cp2x, y: cp2y }, { x: xe, y: ye }]);
|
|
88
106
|
let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle);
|
|
89
107
|
if (debug)
|
|
@@ -62,11 +62,14 @@ class ImageLayer extends BaseLayer_1.BaseLayer {
|
|
|
62
62
|
return this;
|
|
63
63
|
}
|
|
64
64
|
async draw(ctx, canvas, manager, debug) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
const parcer = (0, utils_1.parser)(ctx, canvas, manager);
|
|
66
|
+
const { xs, ys, w, h } = parcer.parseBatch({
|
|
67
|
+
xs: { v: this.props.x },
|
|
68
|
+
ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
69
|
+
w: { v: this.props.size.width },
|
|
70
|
+
h: { v: this.props.size.height, options: LazyUtil_1.defaultArg.vl(true) },
|
|
71
|
+
});
|
|
72
|
+
const r = parcer.parse(this.props.size.radius, LazyUtil_1.defaultArg.wh(w / 2, h / 2), LazyUtil_1.defaultArg.vl(false, true));
|
|
70
73
|
let { x, y } = (0, utils_1.centring)(this.props.centring, this.type, w, h, xs, ys);
|
|
71
74
|
if (debug)
|
|
72
75
|
LazyUtil_1.LazyLog.log('none', `ImageLayer:`, { x, y, w, h, r });
|
|
@@ -26,6 +26,14 @@ export declare class LineLayer extends BaseLayer<ILineLayerProps> {
|
|
|
26
26
|
* @param miterLimit {number} - The `miterLimit` of the stroke.
|
|
27
27
|
*/
|
|
28
28
|
setStroke(width: number, cap?: CanvasLineCap, join?: CanvasLineJoin, dash?: number[], dashOffset?: number, miterLimit?: number): this;
|
|
29
|
+
getBoundingBox(ctx: SKRSContext2D, canvas: Canvas, manager: LayersManager): {
|
|
30
|
+
xs: number;
|
|
31
|
+
ys: number;
|
|
32
|
+
xe: number;
|
|
33
|
+
ye: number;
|
|
34
|
+
width: number;
|
|
35
|
+
height: number;
|
|
36
|
+
};
|
|
29
37
|
draw(ctx: SKRSContext2D, canvas: Canvas, manager: LayersManager, debug: boolean): Promise<void>;
|
|
30
38
|
toJSON(): ILineLayer;
|
|
31
39
|
}
|
|
@@ -65,11 +65,26 @@ class LineLayer extends BaseLayer_1.BaseLayer {
|
|
|
65
65
|
};
|
|
66
66
|
return this;
|
|
67
67
|
}
|
|
68
|
+
getBoundingBox(ctx, canvas, manager) {
|
|
69
|
+
const parcer = (0, utils_1.parser)(ctx, canvas, manager);
|
|
70
|
+
const { xs, ys, xe, ye } = parcer.parseBatch({
|
|
71
|
+
xs: { v: this.props.x },
|
|
72
|
+
ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
73
|
+
xe: { v: this.props.endPoint.x },
|
|
74
|
+
ye: { v: this.props.endPoint.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
75
|
+
});
|
|
76
|
+
let width = xe - xs;
|
|
77
|
+
let height = ye - ys;
|
|
78
|
+
return { xs, ys, xe, ye, width, height };
|
|
79
|
+
}
|
|
68
80
|
async draw(ctx, canvas, manager, debug) {
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
const parcer = (0, utils_1.parser)(ctx, canvas, manager);
|
|
82
|
+
const { xs, ys, xe, ye } = parcer.parseBatch({
|
|
83
|
+
xs: { v: this.props.x },
|
|
84
|
+
ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
85
|
+
xe: { v: this.props.endPoint.x },
|
|
86
|
+
ye: { v: this.props.endPoint.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
87
|
+
});
|
|
73
88
|
let width = xe - xs;
|
|
74
89
|
let height = ye - ys;
|
|
75
90
|
let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle);
|
|
@@ -90,7 +105,9 @@ class LineLayer extends BaseLayer_1.BaseLayer {
|
|
|
90
105
|
ctx.lineDashOffset = this.props.stroke?.dashOffset || 0;
|
|
91
106
|
ctx.setLineDash(this.props.stroke?.dash || []);
|
|
92
107
|
ctx.lineTo(xe, ye);
|
|
108
|
+
ctx.stroke();
|
|
93
109
|
ctx.closePath();
|
|
110
|
+
ctx.restore();
|
|
94
111
|
}
|
|
95
112
|
toJSON() {
|
|
96
113
|
let data = super.toJSON();
|
|
@@ -81,11 +81,14 @@ class MorphLayer extends BaseLayer_1.BaseLayer {
|
|
|
81
81
|
return this;
|
|
82
82
|
}
|
|
83
83
|
async draw(ctx, canvas, manager, debug) {
|
|
84
|
-
const
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
const parcer = (0, utils_1.parser)(ctx, canvas, manager);
|
|
85
|
+
const { xs, ys, w, h } = parcer.parseBatch({
|
|
86
|
+
xs: { v: this.props.x },
|
|
87
|
+
ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
88
|
+
w: { v: this.props.size.width },
|
|
89
|
+
h: { v: this.props.size.height, options: LazyUtil_1.defaultArg.vl(true) },
|
|
90
|
+
});
|
|
91
|
+
const r = parcer.parse(this.props.size.radius, LazyUtil_1.defaultArg.wh(w / 2, h / 2), LazyUtil_1.defaultArg.vl(false, true));
|
|
89
92
|
let { x, y } = (0, utils_1.centring)(this.props.centring, this.type, w, h, xs, ys);
|
|
90
93
|
let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle);
|
|
91
94
|
if (debug)
|
|
@@ -32,6 +32,22 @@ export declare class QuadraticLayer extends BaseLayer<IQuadraticLayerProps> {
|
|
|
32
32
|
* @param miterLimit {number} - The `miterLimit` of the stroke.
|
|
33
33
|
*/
|
|
34
34
|
setStroke(width: number, cap?: CanvasLineCap, join?: CanvasLineJoin, dash?: number[], dashOffset?: number, miterLimit?: number): this;
|
|
35
|
+
getBoundingBox(ctx: SKRSContext2D, canvas: Canvas, manager: LayersManager): {
|
|
36
|
+
max: {
|
|
37
|
+
x: number;
|
|
38
|
+
y: number;
|
|
39
|
+
};
|
|
40
|
+
min: {
|
|
41
|
+
x: number;
|
|
42
|
+
y: number;
|
|
43
|
+
};
|
|
44
|
+
center: {
|
|
45
|
+
x: number;
|
|
46
|
+
y: number;
|
|
47
|
+
};
|
|
48
|
+
width: number;
|
|
49
|
+
height: number;
|
|
50
|
+
};
|
|
35
51
|
draw(ctx: SKRSContext2D, canvas: Canvas, manager: LayersManager, debug: boolean): Promise<void>;
|
|
36
52
|
/**
|
|
37
53
|
* @returns {IQuadraticLayer}
|
|
@@ -74,13 +74,29 @@ class QuadraticLayer extends BaseLayer_1.BaseLayer {
|
|
|
74
74
|
};
|
|
75
75
|
return this;
|
|
76
76
|
}
|
|
77
|
+
getBoundingBox(ctx, canvas, manager) {
|
|
78
|
+
const parcer = (0, utils_1.parser)(ctx, canvas, manager);
|
|
79
|
+
const { xs, ys, cx, cy, xe, ye } = parcer.parseBatch({
|
|
80
|
+
xs: { v: this.props.x },
|
|
81
|
+
ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
82
|
+
cx: { v: this.props.controlPoint.x },
|
|
83
|
+
cy: { v: this.props.controlPoint.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
84
|
+
xe: { v: this.props.endPoint.x },
|
|
85
|
+
ye: { v: this.props.endPoint.y, options: LazyUtil_1.defaultArg.vl(true) }
|
|
86
|
+
});
|
|
87
|
+
const { max, min, center, width, height } = (0, utils_1.getBoundingBoxBezier)([{ x: xs, y: ys }, { x: cx, y: cy }, { x: xe, y: ye }]);
|
|
88
|
+
return { max, min, center, width, height };
|
|
89
|
+
}
|
|
77
90
|
async draw(ctx, canvas, manager, debug) {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
91
|
+
const parcer = (0, utils_1.parser)(ctx, canvas, manager);
|
|
92
|
+
const { xs, ys, cx, cy, xe, ye } = parcer.parseBatch({
|
|
93
|
+
xs: { v: this.props.x },
|
|
94
|
+
ys: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
95
|
+
cx: { v: this.props.controlPoint.x },
|
|
96
|
+
cy: { v: this.props.controlPoint.y, options: LazyUtil_1.defaultArg.vl(true) },
|
|
97
|
+
xe: { v: this.props.endPoint.x },
|
|
98
|
+
ye: { v: this.props.endPoint.y, options: LazyUtil_1.defaultArg.vl(true) }
|
|
99
|
+
});
|
|
84
100
|
const { max, min, center, width, height } = (0, utils_1.getBoundingBoxBezier)([{ x: xs, y: ys }, { x: cx, y: cy }, { x: xe, y: ye }]);
|
|
85
101
|
let fillStyle = await (0, utils_1.parseFillStyle)(ctx, this.props.fillStyle);
|
|
86
102
|
if (debug)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BaseLayer } from "./BaseLayer";
|
|
2
|
-
import {
|
|
3
|
-
import { ITextLayer, ITextLayerProps, ScaleType, ColorType } from "../../types";
|
|
2
|
+
import { LineCap, LineJoin } from "../../types/enum";
|
|
3
|
+
import { ITextLayer, ITextLayerProps, ScaleType, ColorType, AnyWeight, AnyTextAlign, AnyTextBaseline, AnyTextDirection } from "../../types";
|
|
4
4
|
import { Canvas, SKRSContext2D } from "@napi-rs/canvas";
|
|
5
5
|
import { LayersManager } from "../managers/LayersManager";
|
|
6
6
|
export declare class TextLayer extends BaseLayer<ITextLayerProps> {
|
|
@@ -13,11 +13,15 @@ export declare class TextLayer extends BaseLayer<ITextLayerProps> {
|
|
|
13
13
|
setText(text: string): this;
|
|
14
14
|
/**
|
|
15
15
|
* @description Set the font of the text layer. You can use `Geist` and `GeistMono`, or you can upload your own font from file/base64 buffer.
|
|
16
|
-
* @param
|
|
16
|
+
* @param familyOrConfig {string | { font: string; size: number; weight: AnyWeight }} - The `family` of the font. If you want to use FontsList, you can use the object config.
|
|
17
17
|
* @param size {number} - The `size` of the font.
|
|
18
|
-
* @param weight {
|
|
18
|
+
* @param weight {AnyWeight} - The `weight` of the font.
|
|
19
19
|
*/
|
|
20
|
-
setFont(
|
|
20
|
+
setFont(familyOrConfig: string | {
|
|
21
|
+
family: string;
|
|
22
|
+
size: number;
|
|
23
|
+
weight: AnyWeight;
|
|
24
|
+
}, size?: number, weight?: AnyWeight): this;
|
|
21
25
|
/**
|
|
22
26
|
* @description Set the multiline of the text layer. You can use `numbers`, `percentages`, `px`, `vw`, `vh`, `vmin`, `vmax`.
|
|
23
27
|
* @param enabled {boolean} - Whether the text is multiline.
|
|
@@ -33,19 +37,19 @@ export declare class TextLayer extends BaseLayer<ITextLayerProps> {
|
|
|
33
37
|
setColor(color: ColorType): this;
|
|
34
38
|
/**
|
|
35
39
|
* @description Set the align of the text layer.
|
|
36
|
-
* @param align {
|
|
40
|
+
* @param align {AnyTextAlign} - The `align` of the text layer.
|
|
37
41
|
*/
|
|
38
|
-
setAlign(align:
|
|
42
|
+
setAlign(align: AnyTextAlign): this;
|
|
39
43
|
/**
|
|
40
44
|
* @description Set the baseline of the text layer.
|
|
41
|
-
* @param baseline {
|
|
45
|
+
* @param baseline {AnyTextBaseline} - The `baseline` of the text layer.
|
|
42
46
|
*/
|
|
43
|
-
setBaseline(baseline:
|
|
47
|
+
setBaseline(baseline: AnyTextBaseline): this;
|
|
44
48
|
/**
|
|
45
49
|
* @description Set the direction of the text layer.
|
|
46
|
-
* @param direction {
|
|
50
|
+
* @param direction {AnyTextDirection} - The `direction` of the text layer.
|
|
47
51
|
*/
|
|
48
|
-
setDirection(direction:
|
|
52
|
+
setDirection(direction: AnyTextDirection): this;
|
|
49
53
|
/**
|
|
50
54
|
* @description Set the stroke of the layer.
|
|
51
55
|
* @param width {number} - The `width` of the stroke.
|