@nmmty/lazycanvas 0.3.6 → 0.5.0
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/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 -45
- package/dist/structures/LazyCanvas.d.ts +126 -17
- package/dist/structures/LazyCanvas.js +101 -33
- package/dist/structures/components/BaseLayer.d.ts +188 -38
- package/dist/structures/components/BaseLayer.js +88 -41
- package/dist/structures/components/BezierLayer.d.ts +108 -21
- package/dist/structures/components/BezierLayer.js +73 -24
- package/dist/structures/components/ClearLayer.d.ts +142 -0
- package/dist/structures/components/ClearLayer.js +152 -0
- package/dist/structures/components/Group.d.ts +86 -18
- package/dist/structures/components/Group.js +69 -29
- package/dist/structures/components/ImageLayer.d.ts +85 -12
- package/dist/structures/components/ImageLayer.js +55 -42
- package/dist/structures/components/LineLayer.d.ts +111 -18
- package/dist/structures/components/LineLayer.js +58 -21
- package/dist/structures/components/MorphLayer.d.ts +109 -21
- package/dist/structures/components/MorphLayer.js +55 -27
- package/dist/structures/components/Path2DLayer.d.ts +191 -0
- package/dist/structures/components/Path2DLayer.js +318 -0
- package/dist/structures/components/QuadraticLayer.d.ts +108 -22
- package/dist/structures/components/QuadraticLayer.js +65 -30
- package/dist/structures/components/TextLayer.d.ts +201 -40
- package/dist/structures/components/TextLayer.js +101 -49
- 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 +48 -17
- 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 +45 -40
- 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 +120 -0
- package/dist/structures/managers/AnimationManager.js +99 -0
- 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 +67 -29
- package/dist/structures/managers/RenderManager.d.ts +63 -6
- package/dist/structures/managers/RenderManager.js +162 -33
- package/dist/types/LazyCanvas.d.ts +2 -0
- package/dist/types/components/ClearLayer.d.ts +19 -0
- package/dist/types/enum.d.ts +20 -7
- package/dist/types/enum.js +24 -10
- package/dist/types/index.d.ts +2 -17
- package/dist/types/index.js +17 -0
- package/dist/types/managers/AnimationManager.d.ts +14 -0
- package/dist/types/types.d.ts +7 -3
- package/dist/utils/LazyUtil.js +2 -2
- package/dist/utils/utils.d.ts +10 -9
- package/dist/utils/utils.js +159 -164
- package/package.json +9 -5
|
@@ -2,6 +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 { AnimationManager } from "../structures/managers/AnimationManager";
|
|
5
6
|
import { AnyExport } from "../";
|
|
6
7
|
|
|
7
8
|
export interface ILazyCanvas {
|
|
@@ -12,5 +13,6 @@ export interface ILazyCanvas {
|
|
|
12
13
|
layers: LayersManager;
|
|
13
14
|
render: RenderManager;
|
|
14
15
|
fonts: FontsManager;
|
|
16
|
+
animation: AnimationManager;
|
|
15
17
|
exportType: AnyExport;
|
|
16
18
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ScaleType } from "../types";
|
|
2
|
+
import { LayerType } from "../enum";
|
|
3
|
+
|
|
4
|
+
export interface IClearLayer {
|
|
5
|
+
id: string;
|
|
6
|
+
type: LayerType;
|
|
7
|
+
zIndex: number;
|
|
8
|
+
visible: boolean;
|
|
9
|
+
props: IClearLayerProps;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface IClearLayerProps {
|
|
13
|
+
x: ScaleType;
|
|
14
|
+
y: ScaleType;
|
|
15
|
+
size: {
|
|
16
|
+
width: ScaleType;
|
|
17
|
+
height: ScaleType;
|
|
18
|
+
};
|
|
19
|
+
}
|
package/dist/types/enum.d.ts
CHANGED
|
@@ -10,7 +10,8 @@ export declare enum LayerType {
|
|
|
10
10
|
QuadraticCurve = "quadraticCurve",
|
|
11
11
|
Morph = "morph",
|
|
12
12
|
Text = "text",
|
|
13
|
-
Group = "group"
|
|
13
|
+
Group = "group",
|
|
14
|
+
Clear = "clear"
|
|
14
15
|
}
|
|
15
16
|
export declare enum LayerScaleType {
|
|
16
17
|
Pixel = "px",
|
|
@@ -66,15 +67,17 @@ export declare enum LineJoin {
|
|
|
66
67
|
Miter = "miter"
|
|
67
68
|
}
|
|
68
69
|
export declare enum Export {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
export declare enum SaveFormat {
|
|
70
|
+
CANVAS = "canvas",
|
|
71
|
+
CTX = "ctx",
|
|
72
|
+
BUFFER = "buffer",
|
|
74
73
|
PNG = "png",
|
|
75
74
|
JPEG = "jpeg",
|
|
76
75
|
JPG = "jpg",
|
|
77
|
-
SVG = "svg"
|
|
76
|
+
SVG = "svg",
|
|
77
|
+
GIF = "gif",
|
|
78
|
+
WEBP = "webp",
|
|
79
|
+
YAML = "yaml",
|
|
80
|
+
JSON = "json"
|
|
78
81
|
}
|
|
79
82
|
export declare enum Centring {
|
|
80
83
|
Start = "start",
|
|
@@ -128,3 +131,13 @@ export declare enum GlobalCompositeOperation {
|
|
|
128
131
|
Color = "color",
|
|
129
132
|
Luminosity = "luminosity"
|
|
130
133
|
}
|
|
134
|
+
export declare enum ColorSpace {
|
|
135
|
+
RGB565 = "rgb565",
|
|
136
|
+
RGBA4444 = "rgba4444",
|
|
137
|
+
RGBA444 = "rgba444"
|
|
138
|
+
}
|
|
139
|
+
export declare enum FillType {
|
|
140
|
+
Solid = "solid",
|
|
141
|
+
Gradient = "gradient",
|
|
142
|
+
Pattern = "pattern"
|
|
143
|
+
}
|
package/dist/types/enum.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FillType = exports.ColorSpace = exports.GlobalCompositeOperation = exports.LinkType = exports.PatternType = exports.Centring = exports.Export = exports.LineJoin = exports.LineCap = exports.TextDirection = exports.TextBaseline = exports.TextAlign = exports.FontWeight = exports.GradientType = exports.LayerScaleType = exports.LayerType = void 0;
|
|
4
4
|
var LayerType;
|
|
5
5
|
(function (LayerType) {
|
|
6
6
|
LayerType["Base"] = "base";
|
|
@@ -15,6 +15,7 @@ var LayerType;
|
|
|
15
15
|
LayerType["Morph"] = "morph";
|
|
16
16
|
LayerType["Text"] = "text";
|
|
17
17
|
LayerType["Group"] = "group";
|
|
18
|
+
LayerType["Clear"] = "clear";
|
|
18
19
|
})(LayerType || (exports.LayerType = LayerType = {}));
|
|
19
20
|
var LayerScaleType;
|
|
20
21
|
(function (LayerScaleType) {
|
|
@@ -79,17 +80,18 @@ var LineJoin;
|
|
|
79
80
|
})(LineJoin || (exports.LineJoin = LineJoin = {}));
|
|
80
81
|
var Export;
|
|
81
82
|
(function (Export) {
|
|
82
|
-
Export["
|
|
83
|
-
Export["SVG"] = "svg";
|
|
83
|
+
Export["CANVAS"] = "canvas";
|
|
84
84
|
Export["CTX"] = "ctx";
|
|
85
|
+
Export["BUFFER"] = "buffer";
|
|
86
|
+
Export["PNG"] = "png";
|
|
87
|
+
Export["JPEG"] = "jpeg";
|
|
88
|
+
Export["JPG"] = "jpg";
|
|
89
|
+
Export["SVG"] = "svg";
|
|
90
|
+
Export["GIF"] = "gif";
|
|
91
|
+
Export["WEBP"] = "webp";
|
|
92
|
+
Export["YAML"] = "yaml";
|
|
93
|
+
Export["JSON"] = "json";
|
|
85
94
|
})(Export || (exports.Export = Export = {}));
|
|
86
|
-
var SaveFormat;
|
|
87
|
-
(function (SaveFormat) {
|
|
88
|
-
SaveFormat["PNG"] = "png";
|
|
89
|
-
SaveFormat["JPEG"] = "jpeg";
|
|
90
|
-
SaveFormat["JPG"] = "jpg";
|
|
91
|
-
SaveFormat["SVG"] = "svg";
|
|
92
|
-
})(SaveFormat || (exports.SaveFormat = SaveFormat = {}));
|
|
93
95
|
var Centring;
|
|
94
96
|
(function (Centring) {
|
|
95
97
|
Centring["Start"] = "start";
|
|
@@ -146,3 +148,15 @@ var GlobalCompositeOperation;
|
|
|
146
148
|
GlobalCompositeOperation["Color"] = "color";
|
|
147
149
|
GlobalCompositeOperation["Luminosity"] = "luminosity";
|
|
148
150
|
})(GlobalCompositeOperation || (exports.GlobalCompositeOperation = GlobalCompositeOperation = {}));
|
|
151
|
+
var ColorSpace;
|
|
152
|
+
(function (ColorSpace) {
|
|
153
|
+
ColorSpace["RGB565"] = "rgb565";
|
|
154
|
+
ColorSpace["RGBA4444"] = "rgba4444";
|
|
155
|
+
ColorSpace["RGBA444"] = "rgba444";
|
|
156
|
+
})(ColorSpace || (exports.ColorSpace = ColorSpace = {}));
|
|
157
|
+
var FillType;
|
|
158
|
+
(function (FillType) {
|
|
159
|
+
FillType["Solid"] = "solid";
|
|
160
|
+
FillType["Gradient"] = "gradient";
|
|
161
|
+
FillType["Pattern"] = "pattern";
|
|
162
|
+
})(FillType || (exports.FillType = FillType = {}));
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,17 +1,2 @@
|
|
|
1
|
-
export type * from "./types";
|
|
2
|
-
export
|
|
3
|
-
export type * from "./components/TextLayer";
|
|
4
|
-
export type * from "./components/ImageLayer";
|
|
5
|
-
export type * from "./components/MorphLayer";
|
|
6
|
-
export type * from "./components/BezierLayer";
|
|
7
|
-
export type * from "./components/QuadraticLayer";
|
|
8
|
-
export type * from "./components/LineLayer";
|
|
9
|
-
export type * from "./components/Group";
|
|
10
|
-
export type * from "./helpers/Font";
|
|
11
|
-
export type * from "./helpers/Gradient";
|
|
12
|
-
export type * from "./helpers/Pattern";
|
|
13
|
-
export type * from "./helpers/Link";
|
|
14
|
-
export type * from "./managers/LayersManager";
|
|
15
|
-
export type * from "./managers/RenderManager";
|
|
16
|
-
export type * from "./managers/FontsManager";
|
|
17
|
-
export type * from "./LazyCanvas";
|
|
1
|
+
export type * from "./types";
|
|
2
|
+
export * from './enum';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./enum"), exports);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AnyColorSpace } from "../types";
|
|
2
|
+
|
|
3
|
+
export interface IAnimationManager {
|
|
4
|
+
opts: {
|
|
5
|
+
frameRate: number;
|
|
6
|
+
maxColors: number;
|
|
7
|
+
colorSpace: AnyColorSpace;
|
|
8
|
+
loop: boolean;
|
|
9
|
+
transparency: boolean;
|
|
10
|
+
clear: boolean;
|
|
11
|
+
};
|
|
12
|
+
animated: boolean;
|
|
13
|
+
debug: boolean;
|
|
14
|
+
}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import { BezierLayer } from "../structures/components/BezierLayer";
|
|
|
7
7
|
import { QuadraticLayer } from "../structures/components/QuadraticLayer";
|
|
8
8
|
import { LineLayer } from "../structures/components/LineLayer";
|
|
9
9
|
import { Group } from "../structures/components/Group";
|
|
10
|
+
import { ClearLayer } from "../structures/components/ClearLayer";
|
|
10
11
|
import { Link } from "../structures/helpers/Link";
|
|
11
12
|
import {
|
|
12
13
|
FontWeight,
|
|
@@ -21,14 +22,15 @@ import {
|
|
|
21
22
|
PatternType,
|
|
22
23
|
SaveFormat,
|
|
23
24
|
LinkType,
|
|
24
|
-
GlobalCompositeOperation
|
|
25
|
+
GlobalCompositeOperation,
|
|
26
|
+
ColorSpace
|
|
25
27
|
} from "./enum";
|
|
26
28
|
|
|
27
29
|
export type ScaleType = string | number | 'vw' | 'vh' | 'vmin' | 'vmax' | Link;
|
|
28
30
|
|
|
29
31
|
export type ColorType = string | Gradient | Pattern;
|
|
30
32
|
|
|
31
|
-
export type AnyLayer = MorphLayer | ImageLayer | TextLayer | BezierLayer | QuadraticLayer | LineLayer | Group;
|
|
33
|
+
export type AnyLayer = MorphLayer | ImageLayer | TextLayer | BezierLayer | QuadraticLayer | LineLayer | ClearLayer | Group;
|
|
32
34
|
|
|
33
35
|
export type AnyWeight = FontWeight | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
|
|
34
36
|
|
|
@@ -50,12 +52,14 @@ export type AnyCentring = Centring | 'start' | 'start-top' | 'start-bottom' | 'c
|
|
|
50
52
|
|
|
51
53
|
export type AnyPatternType = PatternType | 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
|
|
52
54
|
|
|
53
|
-
export type AnySaveFormat = SaveFormat | 'png' | 'jpeg' | 'jpg' | 'svg';
|
|
55
|
+
export type AnySaveFormat = SaveFormat | 'png' | 'jpeg' | 'jpg' | 'svg' | 'gif' | 'webp';
|
|
54
56
|
|
|
55
57
|
export type AnyLinkType = LinkType | 'width' | 'height' | 'x' | 'y';
|
|
56
58
|
|
|
57
59
|
export type AnyGlobalCompositeOperation = GlobalCompositeOperation | 'source-over' | 'source-in' | 'source-out' | 'source-atop' | 'destination-over' | 'destination-in' | 'destination-out' | 'destination-atop' | 'lighter' | 'copy' | 'xor' | 'multiply' | 'screen' | 'overlay' | 'darken' | 'lighten' | 'color-dodge' | 'color-burn' | 'hard-light' | 'soft-light' | 'difference' | 'exclusion' | 'hue' | 'saturation' | 'color' | 'luminosity';
|
|
58
60
|
|
|
61
|
+
export type AnyColorSpace = ColorSpace | 'rgb565' | 'rgba4444' | 'rgba444';
|
|
62
|
+
|
|
59
63
|
export type Point = {
|
|
60
64
|
x: ScaleType;
|
|
61
65
|
y: ScaleType;
|
package/dist/utils/LazyUtil.js
CHANGED
|
@@ -13,10 +13,10 @@ class LazyLog {
|
|
|
13
13
|
static log(type = "none", ...message) {
|
|
14
14
|
switch (type) {
|
|
15
15
|
case "info":
|
|
16
|
-
console.log("[LazyCanvas] [INFO]
|
|
16
|
+
console.log("[LazyCanvas] [INFO]", ...message);
|
|
17
17
|
break;
|
|
18
18
|
case "warn":
|
|
19
|
-
console.warn("[LazyCanvas] [WARN]
|
|
19
|
+
console.warn("[LazyCanvas] [WARN]", ...message);
|
|
20
20
|
break;
|
|
21
21
|
default:
|
|
22
22
|
console.log(...message);
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Gradient } from "../structures/helpers
|
|
4
|
-
import { Canvas, SKRSContext2D } from "@napi-rs/canvas";
|
|
5
|
-
import { Pattern } from "../structures/helpers/Pattern";
|
|
1
|
+
import type { AnyCentring, AnyLayer, AnyTextAlign, ColorType, PointNumber, ScaleType, Transform } from "../types";
|
|
2
|
+
import { LayerType } from "../types";
|
|
3
|
+
import { Gradient, Pattern } from "../structures/helpers";
|
|
4
|
+
import { Canvas, SKRSContext2D, SvgCanvas } from "@napi-rs/canvas";
|
|
6
5
|
import { LayersManager } from "../structures/managers/LayersManager";
|
|
6
|
+
import { Group } from "../structures/components";
|
|
7
7
|
export declare function generateID(type: string): string;
|
|
8
8
|
export declare function isColor(v: ColorType): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
|
|
9
9
|
export declare function parseHex(v: string): string;
|
|
10
|
-
export declare function parseColor(v: ColorType): string |
|
|
11
|
-
export declare function parseToNormal(v: ScaleType, ctx: SKRSContext2D, canvas: Canvas, layer?: {
|
|
10
|
+
export declare function parseColor(v: ColorType): string | Gradient | Pattern;
|
|
11
|
+
export declare function parseToNormal(v: ScaleType, ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, layer?: {
|
|
12
12
|
width: number;
|
|
13
13
|
height: number;
|
|
14
14
|
}, options?: {
|
|
15
15
|
vertical?: boolean;
|
|
16
16
|
layer?: boolean;
|
|
17
17
|
}, manager?: LayersManager): number;
|
|
18
|
-
export declare function parser(ctx: SKRSContext2D, canvas: Canvas, manager?: LayersManager): {
|
|
18
|
+
export declare function parser(ctx: SKRSContext2D, canvas: Canvas | SvgCanvas, manager?: LayersManager): {
|
|
19
19
|
parse(v: ScaleType, layer?: {
|
|
20
20
|
width: number;
|
|
21
21
|
height: number;
|
|
@@ -51,7 +51,6 @@ export declare function transform(ctx: SKRSContext2D, transform: Transform, laye
|
|
|
51
51
|
fontSize: number;
|
|
52
52
|
multiline: boolean;
|
|
53
53
|
}): void;
|
|
54
|
-
export declare function saveFile(buffer: any, extension: SaveFormat, name: string): Promise<void>;
|
|
55
54
|
export declare function generateRandomName(): string;
|
|
56
55
|
export declare function isImageUrlValid(src: string): boolean;
|
|
57
56
|
export declare function centring(centring: AnyCentring, type: LayerType, width: number, height: number, x: number, y: number): {
|
|
@@ -74,3 +73,5 @@ export declare function getBoundingBoxBezier(points: PointNumber[], steps?: numb
|
|
|
74
73
|
width: number;
|
|
75
74
|
height: number;
|
|
76
75
|
};
|
|
76
|
+
export declare function resize(value: ScaleType, ratio: number): number | string;
|
|
77
|
+
export declare function resizeLayers(layers: Array<AnyLayer | Group>, ratio: number): (AnyLayer | Group)[];
|