@nmmty/lazycanvas 0.3.2 → 0.3.3
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 +6 -3
- package/dist/index.js +7 -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/LineLayer.js +2 -0
- package/dist/structures/components/TextLayer.d.ts +15 -11
- package/dist/structures/components/TextLayer.js +25 -18
- 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/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 +5 -6
- package/dist/types/enum.d.ts +1 -1
- package/dist/types/enum.js +1 -1
- package/dist/types/helpers/Font.d.ts +2 -2
- package/dist/types/helpers/Gradient.d.ts +2 -2
- package/dist/types/helpers/Pattern.d.ts +2 -2
- package/dist/types/types.d.ts +25 -1
- package/dist/utils/utils.d.ts +4 -4
- package/dist/utils/utils.js +10 -0
- 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,16 @@ 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
10
|
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";
|
|
11
|
+
import type { AnyLayer, AnyCentring, AnyPatternType, AnyGradientType, AnyTextAlign, AnyTextDirection, AnyTextBaseline, AnyWeight, AnyExport, AnyLineCap, AnyLineJoin, AnySaveFormat, 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";
|
|
14
15
|
import { saveFile } from "./utils/utils";
|
|
15
|
-
import { Filters } from "./helpers/
|
|
16
|
-
|
|
16
|
+
import { Filters } from "./helpers/Filters";
|
|
17
|
+
import { FontsList } from "./helpers/FontsList";
|
|
18
|
+
export { LazyCanvas, ImageLayer, MorphLayer, TextLayer, BezierLayer, QuadraticLayer, LineLayer, BaseLayer, Group, Font, Gradient, Pattern, LayerScaleType, LayerType, FontWeight, GradientType, Export, LineCap, LineJoin, TextAlign, TextDirection, TextBaseline, SaveFormat, Centring, PatternType, saveFile, Filters, FontsList, };
|
|
19
|
+
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, 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.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.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");
|
|
@@ -39,5 +41,7 @@ const Pattern_1 = require("./structures/helpers/Pattern");
|
|
|
39
41
|
Object.defineProperty(exports, "Pattern", { enumerable: true, get: function () { return Pattern_1.Pattern; } });
|
|
40
42
|
const utils_1 = require("./utils/utils");
|
|
41
43
|
Object.defineProperty(exports, "saveFile", { enumerable: true, get: function () { return utils_1.saveFile; } });
|
|
42
|
-
const
|
|
43
|
-
Object.defineProperty(exports, "Filters", { enumerable: true, get: function () { return
|
|
44
|
+
const Filters_1 = require("./helpers/Filters");
|
|
45
|
+
Object.defineProperty(exports, "Filters", { enumerable: true, get: function () { return Filters_1.Filters; } });
|
|
46
|
+
const FontsList_1 = require("./helpers/FontsList");
|
|
47
|
+
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;
|
|
@@ -90,7 +90,9 @@ class LineLayer extends BaseLayer_1.BaseLayer {
|
|
|
90
90
|
ctx.lineDashOffset = this.props.stroke?.dashOffset || 0;
|
|
91
91
|
ctx.setLineDash(this.props.stroke?.dash || []);
|
|
92
92
|
ctx.lineTo(xe, ye);
|
|
93
|
+
ctx.stroke();
|
|
93
94
|
ctx.closePath();
|
|
95
|
+
ctx.restore();
|
|
94
96
|
}
|
|
95
97
|
toJSON() {
|
|
96
98
|
let data = super.toJSON();
|
|
@@ -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.
|
|
@@ -16,7 +16,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
|
|
|
16
16
|
this.props.font = {
|
|
17
17
|
family: 'Geist',
|
|
18
18
|
size: 16,
|
|
19
|
-
weight: enum_1.FontWeight.
|
|
19
|
+
weight: enum_1.FontWeight.Regular,
|
|
20
20
|
};
|
|
21
21
|
this.props.fillStyle = '#ffffff';
|
|
22
22
|
this.props.filled = true;
|
|
@@ -38,22 +38,29 @@ class TextLayer extends BaseLayer_1.BaseLayer {
|
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* @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.
|
|
41
|
-
* @param
|
|
41
|
+
* @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.
|
|
42
42
|
* @param size {number} - The `size` of the font.
|
|
43
|
-
* @param weight {
|
|
43
|
+
* @param weight {AnyWeight} - The `weight` of the font.
|
|
44
44
|
*/
|
|
45
|
-
setFont(
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
45
|
+
setFont(familyOrConfig, size, weight) {
|
|
46
|
+
if (typeof familyOrConfig === "string") {
|
|
47
|
+
if (!size)
|
|
48
|
+
throw new LazyUtil_1.LazyError('The size of the font must be provided');
|
|
49
|
+
if (!weight)
|
|
50
|
+
throw new LazyUtil_1.LazyError('The weight of the font must be provided');
|
|
51
|
+
this.props.font = {
|
|
52
|
+
family: familyOrConfig,
|
|
53
|
+
size,
|
|
54
|
+
weight,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
this.props.font = {
|
|
59
|
+
family: familyOrConfig.family,
|
|
60
|
+
size: familyOrConfig.size,
|
|
61
|
+
weight: familyOrConfig.weight,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
57
64
|
return this;
|
|
58
65
|
}
|
|
59
66
|
/**
|
|
@@ -94,7 +101,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
|
|
|
94
101
|
}
|
|
95
102
|
/**
|
|
96
103
|
* @description Set the align of the text layer.
|
|
97
|
-
* @param align {
|
|
104
|
+
* @param align {AnyTextAlign} - The `align` of the text layer.
|
|
98
105
|
*/
|
|
99
106
|
setAlign(align) {
|
|
100
107
|
this.props.align = align;
|
|
@@ -102,7 +109,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
|
|
|
102
109
|
}
|
|
103
110
|
/**
|
|
104
111
|
* @description Set the baseline of the text layer.
|
|
105
|
-
* @param baseline {
|
|
112
|
+
* @param baseline {AnyTextBaseline} - The `baseline` of the text layer.
|
|
106
113
|
*/
|
|
107
114
|
setBaseline(baseline) {
|
|
108
115
|
this.props.baseline = baseline;
|
|
@@ -110,7 +117,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
|
|
|
110
117
|
}
|
|
111
118
|
/**
|
|
112
119
|
* @description Set the direction of the text layer.
|
|
113
|
-
* @param direction {
|
|
120
|
+
* @param direction {AnyTextDirection} - The `direction` of the text layer.
|
|
114
121
|
*/
|
|
115
122
|
setDirection(direction) {
|
|
116
123
|
this.props.direction = direction;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import {
|
|
3
|
+
import { AnyWeight } from "../../types";
|
|
4
4
|
import { IFont } from "../../types";
|
|
5
5
|
export declare class Font implements IFont {
|
|
6
6
|
family: string;
|
|
7
|
-
weight:
|
|
7
|
+
weight: AnyWeight;
|
|
8
8
|
path?: string;
|
|
9
9
|
base64?: Buffer;
|
|
10
10
|
constructor();
|
|
@@ -15,9 +15,9 @@ export declare class Font implements IFont {
|
|
|
15
15
|
setFamily(family: string): this;
|
|
16
16
|
/**
|
|
17
17
|
* Set the font weight
|
|
18
|
-
* @param weight {
|
|
18
|
+
* @param weight {AnyWeight} - The `weight` of the font
|
|
19
19
|
*/
|
|
20
|
-
setWeight(weight:
|
|
20
|
+
setWeight(weight: AnyWeight): this;
|
|
21
21
|
/**
|
|
22
22
|
* Set the path of the font
|
|
23
23
|
* @param path {string} - The `path` of the font
|
|
@@ -9,7 +9,7 @@ class Font {
|
|
|
9
9
|
base64;
|
|
10
10
|
constructor() {
|
|
11
11
|
this.family = "Arial";
|
|
12
|
-
this.weight = enum_1.FontWeight.
|
|
12
|
+
this.weight = enum_1.FontWeight.Regular;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Set the font family
|
|
@@ -23,7 +23,7 @@ class Font {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Set the font weight
|
|
26
|
-
* @param weight {
|
|
26
|
+
* @param weight {AnyWeight} - The `weight` of the font
|
|
27
27
|
*/
|
|
28
28
|
setWeight(weight) {
|
|
29
29
|
if (!weight)
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IGradient, GradientPoint, GradientColorStop } from "../../types";
|
|
1
|
+
import { IGradient, GradientPoint, GradientColorStop, AnyGradientType } from "../../types";
|
|
3
2
|
import { SKRSContext2D } from "@napi-rs/canvas";
|
|
4
3
|
export declare class Gradient implements IGradient {
|
|
5
|
-
type:
|
|
4
|
+
type: AnyGradientType;
|
|
6
5
|
points: Array<GradientPoint>;
|
|
7
6
|
stops: Array<GradientColorStop>;
|
|
8
7
|
constructor();
|
|
9
8
|
/**
|
|
10
9
|
* Set the type of the gradient
|
|
11
|
-
* @param type {
|
|
10
|
+
* @param type {AnyGradientType} - The `type` of the gradient. Can be `linear`, `radial`, or `conic`
|
|
12
11
|
*/
|
|
13
|
-
setType(type:
|
|
12
|
+
setType(type: AnyGradientType): this;
|
|
14
13
|
/**
|
|
15
14
|
* Add a point to the gradient
|
|
16
15
|
* @param points {GradientPoint[]} - The `points` to add to the gradient. `{ x: number, y: number }`
|
|
@@ -14,7 +14,7 @@ class Gradient {
|
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Set the type of the gradient
|
|
17
|
-
* @param type {
|
|
17
|
+
* @param type {AnyGradientType} - The `type` of the gradient. Can be `linear`, `radial`, or `conic`
|
|
18
18
|
*/
|
|
19
19
|
setType(type) {
|
|
20
20
|
this.type = type;
|
|
@@ -41,12 +41,15 @@ class Gradient {
|
|
|
41
41
|
let gradient;
|
|
42
42
|
switch (gradientData.type) {
|
|
43
43
|
case enum_1.GradientType.Linear:
|
|
44
|
+
case "linear":
|
|
44
45
|
gradient = ctx.createLinearGradient(gradientData.points[0].x, gradientData.points[0].y, gradientData.points[1].x, gradientData.points[1].y);
|
|
45
46
|
break;
|
|
46
47
|
case enum_1.GradientType.Radial:
|
|
48
|
+
case "radial":
|
|
47
49
|
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));
|
|
48
50
|
break;
|
|
49
51
|
case enum_1.GradientType.Conic:
|
|
52
|
+
case "conic":
|
|
50
53
|
gradient = ctx.createConicGradient((gradientData.points[0].startAngle || 0), gradientData.points[0].x, gradientData.points[0].y);
|
|
51
54
|
break;
|
|
52
55
|
default:
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { IPattern } from "../../types";
|
|
1
|
+
import { IPattern, AnyPatternType } from "../../types";
|
|
3
2
|
import { LazyCanvas } from "../LazyCanvas";
|
|
4
3
|
import { SKRSContext2D } from "@napi-rs/canvas";
|
|
5
4
|
export declare class Pattern implements IPattern {
|
|
6
|
-
type:
|
|
5
|
+
type: AnyPatternType;
|
|
7
6
|
src: string | LazyCanvas;
|
|
8
7
|
constructor();
|
|
9
8
|
/**
|
|
10
9
|
* Set the type of the pattern
|
|
11
|
-
* @param type {
|
|
10
|
+
* @param type {AnyPatternType} - The `type` of the pattern
|
|
12
11
|
*/
|
|
13
|
-
setType(type:
|
|
12
|
+
setType(type: AnyPatternType): this;
|
|
14
13
|
/**
|
|
15
14
|
* Set the source of the pattern
|
|
16
15
|
* @param src {string | LazyCanvas} - The `src` of the pattern
|
|
@@ -11,8 +11,7 @@ class FontsManager {
|
|
|
11
11
|
constructor(debug = false) {
|
|
12
12
|
this.debug = debug;
|
|
13
13
|
this.map = new Map();
|
|
14
|
-
|
|
15
|
-
this.loadFonts(fontList);
|
|
14
|
+
this.loadFonts(Fonts_1.Fonts);
|
|
16
15
|
}
|
|
17
16
|
/**
|
|
18
17
|
* Replace base fonts with custom fonts by special file.
|
|
@@ -35,10 +35,13 @@ class RenderManager {
|
|
|
35
35
|
}
|
|
36
36
|
switch (this.lazyCanvas.exportType) {
|
|
37
37
|
case enum_1.Export.Buffer:
|
|
38
|
+
case "buffer":
|
|
38
39
|
return this.lazyCanvas.canvas.toBuffer('image/png');
|
|
39
40
|
case enum_1.Export.CTX:
|
|
41
|
+
case "ctx":
|
|
40
42
|
return this.lazyCanvas.ctx;
|
|
41
43
|
case enum_1.Export.SVG:
|
|
44
|
+
case "svg":
|
|
42
45
|
// @ts-ignore
|
|
43
46
|
return this.lazyCanvas.canvas.getContent().toString('utf8');
|
|
44
47
|
default:
|
|
@@ -2,7 +2,7 @@ import { Canvas, SKRSContext2D } from "@napi-rs/canvas";
|
|
|
2
2
|
import { LayersManager } from "../structures/managers/LayersManager";
|
|
3
3
|
import { RenderManager } from "../structures/managers/RenderManager";
|
|
4
4
|
import { FontsManager } from "../structures/managers/FontsManager";
|
|
5
|
-
import {
|
|
5
|
+
import { AnyExport } from "../";
|
|
6
6
|
|
|
7
7
|
export interface ILazyCanvas {
|
|
8
8
|
width: number;
|
|
@@ -12,5 +12,5 @@ export interface ILazyCanvas {
|
|
|
12
12
|
layers: LayersManager;
|
|
13
13
|
render: RenderManager;
|
|
14
14
|
fonts: FontsManager;
|
|
15
|
-
exportType:
|
|
15
|
+
exportType: AnyExport;
|
|
16
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ColorType, ScaleType } from "../";
|
|
2
|
-
import {
|
|
1
|
+
import { ColorType, ScaleType, AnyCentring } from "../";
|
|
2
|
+
import { LayerType } from "../enum";
|
|
3
3
|
|
|
4
4
|
export interface IBaseLayer {
|
|
5
5
|
id: string;
|
|
@@ -12,7 +12,7 @@ export interface IBaseLayer {
|
|
|
12
12
|
export interface IBaseLayerProps {
|
|
13
13
|
x: ScaleType;
|
|
14
14
|
y: ScaleType;
|
|
15
|
-
centring:
|
|
15
|
+
centring: AnyCentring;
|
|
16
16
|
filter: string;
|
|
17
17
|
opacity: number;
|
|
18
18
|
filled: boolean;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AnyWeight, ScaleType, AnyTextAlign, AnyTextBaseline, AnyTextDirection } from "../";
|
|
2
2
|
import { IBaseLayer, IBaseLayerProps } from "./BaseLayer";
|
|
3
|
-
import { FontWeight, TextAlign, TextBaseline, TextDirection } from "../enum";
|
|
4
3
|
|
|
5
4
|
export interface ITextLayer extends IBaseLayer {
|
|
6
5
|
props: ITextLayerProps;
|
|
@@ -11,7 +10,7 @@ export interface ITextLayerProps extends IBaseLayerProps {
|
|
|
11
10
|
font: {
|
|
12
11
|
family: string;
|
|
13
12
|
size: number;
|
|
14
|
-
weight:
|
|
13
|
+
weight: AnyWeight;
|
|
15
14
|
};
|
|
16
15
|
multiline: {
|
|
17
16
|
enabled: boolean;
|
|
@@ -19,7 +18,7 @@ export interface ITextLayerProps extends IBaseLayerProps {
|
|
|
19
18
|
height: ScaleType;
|
|
20
19
|
spacing?: number;
|
|
21
20
|
};
|
|
22
|
-
align:
|
|
23
|
-
baseline:
|
|
24
|
-
direction:
|
|
21
|
+
align: AnyTextAlign;
|
|
22
|
+
baseline: AnyTextBaseline;
|
|
23
|
+
direction: AnyTextDirection;
|
|
25
24
|
}
|
package/dist/types/enum.d.ts
CHANGED
package/dist/types/enum.js
CHANGED
|
@@ -34,7 +34,7 @@ var FontWeight;
|
|
|
34
34
|
FontWeight[FontWeight["Thin"] = 100] = "Thin";
|
|
35
35
|
FontWeight[FontWeight["ExtraLight"] = 200] = "ExtraLight";
|
|
36
36
|
FontWeight[FontWeight["Light"] = 300] = "Light";
|
|
37
|
-
FontWeight[FontWeight["
|
|
37
|
+
FontWeight[FontWeight["Regular"] = 400] = "Regular";
|
|
38
38
|
FontWeight[FontWeight["Medium"] = 500] = "Medium";
|
|
39
39
|
FontWeight[FontWeight["SemiBold"] = 600] = "SemiBold";
|
|
40
40
|
FontWeight[FontWeight["Bold"] = 700] = "Bold";
|
package/dist/types/types.d.ts
CHANGED
|
@@ -5,13 +5,37 @@ import { ImageLayer } from "../structures/components/ImageLayer";
|
|
|
5
5
|
import { TextLayer } from "../structures/components/TextLayer";
|
|
6
6
|
import { BezierLayer } from "../structures/components/BezierLayer";
|
|
7
7
|
import { QuadraticLayer } from "../structures/components/QuadraticLayer";
|
|
8
|
+
import { LineLayer } from "../structures/components/LineLayer";
|
|
8
9
|
import { Group } from "../structures/components/Group";
|
|
10
|
+
import { FontWeight, GradientType, TextAlign, TextBaseline, TextDirection, LineCap, LineJoin, Export, Centring, PatternType, SaveFormat } from "./enum";
|
|
9
11
|
|
|
10
12
|
export type ScaleType = string | number | 'vw' | 'vh' | 'vmin' | 'vmax';
|
|
11
13
|
|
|
12
14
|
export type ColorType = string | Gradient | Pattern;
|
|
13
15
|
|
|
14
|
-
export type AnyLayer = MorphLayer | ImageLayer | TextLayer | BezierLayer | QuadraticLayer | Group;
|
|
16
|
+
export type AnyLayer = MorphLayer | ImageLayer | TextLayer | BezierLayer | QuadraticLayer | LineLayer | Group;
|
|
17
|
+
|
|
18
|
+
export type AnyWeight = FontWeight | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
19
|
+
|
|
20
|
+
export type AnyGradientType = GradientType | 'linear' | 'radial' | 'conic';
|
|
21
|
+
|
|
22
|
+
export type AnyTextAlign = TextAlign | 'left' | 'right' | 'center' | 'start' | 'end';
|
|
23
|
+
|
|
24
|
+
export type AnyTextBaseline = TextBaseline | 'top' | 'hanging' | 'middle' | 'alphabetic' | 'ideographic' | 'bottom';
|
|
25
|
+
|
|
26
|
+
export type AnyTextDirection = TextDirection | 'ltr' | 'rtl' | 'inherit';
|
|
27
|
+
|
|
28
|
+
export type AnyLineCap = LineCap | 'butt' | 'round' | 'square';
|
|
29
|
+
|
|
30
|
+
export type AnyLineJoin = LineJoin | 'bevel' | 'round' | 'miter';
|
|
31
|
+
|
|
32
|
+
export type AnyExport = Export | 'buffer' | 'svg' | 'ctx';
|
|
33
|
+
|
|
34
|
+
export type AnyCentring = Centring | 'start' | 'start-top' | 'start-bottom' | 'center' | 'center-top' | 'center-bottom' | 'end' | 'end-top' | 'end-bottom' | 'none';
|
|
35
|
+
|
|
36
|
+
export type AnyPatternType = PatternType | 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
|
|
37
|
+
|
|
38
|
+
export type AnySaveFormat = SaveFormat | 'png' | 'jpeg' | 'jpg' | 'svg';
|
|
15
39
|
|
|
16
40
|
export type Point = {
|
|
17
41
|
x: ScaleType;
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Transform, ScaleType, ColorType, PointNumber } from "../types";
|
|
1
|
+
import { LayerType, SaveFormat } from "../types/enum";
|
|
2
|
+
import { Transform, ScaleType, ColorType, PointNumber, AnyCentring, AnyTextAlign } from "../types";
|
|
3
3
|
import { Gradient } from "../structures/helpers/Gradient";
|
|
4
4
|
import { Canvas, SKRSContext2D } from "@napi-rs/canvas";
|
|
5
5
|
import { Pattern } from "../structures/helpers/Pattern";
|
|
@@ -27,14 +27,14 @@ export declare function transform(ctx: SKRSContext2D, transform: Transform, laye
|
|
|
27
27
|
type: LayerType;
|
|
28
28
|
}, extra?: {
|
|
29
29
|
text: string;
|
|
30
|
-
textAlign:
|
|
30
|
+
textAlign: AnyTextAlign;
|
|
31
31
|
fontSize: number;
|
|
32
32
|
multiline: boolean;
|
|
33
33
|
}): void;
|
|
34
34
|
export declare function saveFile(buffer: any, extension: SaveFormat, name: string): Promise<void>;
|
|
35
35
|
export declare function generateRandomName(): string;
|
|
36
36
|
export declare function isImageUrlValid(src: string): boolean;
|
|
37
|
-
export declare function centring(centring:
|
|
37
|
+
export declare function centring(centring: AnyCentring, type: LayerType, width: number, height: number, x: number, y: number): {
|
|
38
38
|
x: number;
|
|
39
39
|
y: number;
|
|
40
40
|
};
|
package/dist/utils/utils.js
CHANGED
|
@@ -269,6 +269,7 @@ exports.isImageUrlValid = isImageUrlValid;
|
|
|
269
269
|
function centring(centring, type, width, height, x, y) {
|
|
270
270
|
switch (centring) {
|
|
271
271
|
case enum_1.Centring.Center:
|
|
272
|
+
case "center":
|
|
272
273
|
switch (type) {
|
|
273
274
|
case enum_1.LayerType.Image:
|
|
274
275
|
case enum_1.LayerType.Morph:
|
|
@@ -278,6 +279,7 @@ function centring(centring, type, width, height, x, y) {
|
|
|
278
279
|
}
|
|
279
280
|
return { x, y };
|
|
280
281
|
case enum_1.Centring.CenterBottom:
|
|
282
|
+
case "center-bottom":
|
|
281
283
|
switch (type) {
|
|
282
284
|
case enum_1.LayerType.Image:
|
|
283
285
|
case enum_1.LayerType.Morph:
|
|
@@ -286,6 +288,7 @@ function centring(centring, type, width, height, x, y) {
|
|
|
286
288
|
}
|
|
287
289
|
return { x, y };
|
|
288
290
|
case enum_1.Centring.CenterTop:
|
|
291
|
+
case "center-top":
|
|
289
292
|
switch (type) {
|
|
290
293
|
case enum_1.LayerType.Image:
|
|
291
294
|
case enum_1.LayerType.Morph:
|
|
@@ -295,6 +298,7 @@ function centring(centring, type, width, height, x, y) {
|
|
|
295
298
|
}
|
|
296
299
|
return { x, y };
|
|
297
300
|
case enum_1.Centring.Start:
|
|
301
|
+
case "start":
|
|
298
302
|
switch (type) {
|
|
299
303
|
case enum_1.LayerType.Image:
|
|
300
304
|
case enum_1.LayerType.Morph:
|
|
@@ -303,8 +307,10 @@ function centring(centring, type, width, height, x, y) {
|
|
|
303
307
|
}
|
|
304
308
|
return { x, y };
|
|
305
309
|
case enum_1.Centring.StartBottom:
|
|
310
|
+
case "start-bottom":
|
|
306
311
|
return { x, y };
|
|
307
312
|
case enum_1.Centring.StartTop:
|
|
313
|
+
case "start-top":
|
|
308
314
|
switch (type) {
|
|
309
315
|
case enum_1.LayerType.Image:
|
|
310
316
|
case enum_1.LayerType.Morph:
|
|
@@ -313,6 +319,7 @@ function centring(centring, type, width, height, x, y) {
|
|
|
313
319
|
}
|
|
314
320
|
return { x, y };
|
|
315
321
|
case enum_1.Centring.End:
|
|
322
|
+
case "end":
|
|
316
323
|
switch (type) {
|
|
317
324
|
case enum_1.LayerType.Image:
|
|
318
325
|
case enum_1.LayerType.Morph:
|
|
@@ -322,6 +329,7 @@ function centring(centring, type, width, height, x, y) {
|
|
|
322
329
|
}
|
|
323
330
|
return { x, y };
|
|
324
331
|
case enum_1.Centring.EndBottom:
|
|
332
|
+
case "end-bottom":
|
|
325
333
|
switch (type) {
|
|
326
334
|
case enum_1.LayerType.Image:
|
|
327
335
|
case enum_1.LayerType.Morph:
|
|
@@ -330,6 +338,7 @@ function centring(centring, type, width, height, x, y) {
|
|
|
330
338
|
}
|
|
331
339
|
return { x, y };
|
|
332
340
|
case enum_1.Centring.EndTop:
|
|
341
|
+
case "end-top":
|
|
333
342
|
switch (type) {
|
|
334
343
|
case enum_1.LayerType.Image:
|
|
335
344
|
case enum_1.LayerType.Morph:
|
|
@@ -339,6 +348,7 @@ function centring(centring, type, width, height, x, y) {
|
|
|
339
348
|
}
|
|
340
349
|
return { x, y };
|
|
341
350
|
case enum_1.Centring.None:
|
|
351
|
+
case "none":
|
|
342
352
|
return { x, y };
|
|
343
353
|
}
|
|
344
354
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nmmty/lazycanvas",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "A simple way to interact with @napi-rs/canvas in an advanced way!",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"logo": "tsc ./test/logo.ts && node ./test/logo.js",
|
|
11
11
|
"text": "tsc ./test/text.ts && node ./test/text.js",
|
|
12
12
|
"doc": "tsx docgen.ts",
|
|
13
|
+
"font": "tsc ./scripts/font-gen.ts && node ./scripts/font-gen.js",
|
|
13
14
|
"build": "tsc"
|
|
14
15
|
},
|
|
15
16
|
"repository": {
|
|
@@ -30,12 +31,13 @@
|
|
|
30
31
|
},
|
|
31
32
|
"homepage": "https://github.com/NMMTY/LazyCanvas#readme",
|
|
32
33
|
"dependencies": {
|
|
33
|
-
"@napi-rs/canvas": "^0.1.
|
|
34
|
+
"@napi-rs/canvas": "^0.1.68",
|
|
34
35
|
"jimp": "0.22.12",
|
|
35
36
|
"path": "^0.12.7",
|
|
36
37
|
"svgson": "^5.3.1"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
40
|
+
"@hitomihiumi/colors.ts": "^1.0.3",
|
|
39
41
|
"@hitomihiumi/micro-docgen": "^0.3.0",
|
|
40
42
|
"@types/jimp": "^0.2.28",
|
|
41
43
|
"@types/node": "^22.10.2",
|
package/example.png
DELETED
|
Binary file
|
|
File without changes
|
|
File without changes
|