@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.
Files changed (68) hide show
  1. package/dist/helpers/Filters.d.ts +10 -10
  2. package/dist/helpers/Fonts.d.ts +1 -1
  3. package/dist/helpers/FontsList.d.ts +1 -1
  4. package/dist/helpers/FontsList.js +19 -19
  5. package/dist/index.d.ts +11 -20
  6. package/dist/index.js +40 -45
  7. package/dist/structures/LazyCanvas.d.ts +126 -17
  8. package/dist/structures/LazyCanvas.js +101 -33
  9. package/dist/structures/components/BaseLayer.d.ts +188 -38
  10. package/dist/structures/components/BaseLayer.js +88 -41
  11. package/dist/structures/components/BezierLayer.d.ts +108 -21
  12. package/dist/structures/components/BezierLayer.js +73 -24
  13. package/dist/structures/components/ClearLayer.d.ts +142 -0
  14. package/dist/structures/components/ClearLayer.js +152 -0
  15. package/dist/structures/components/Group.d.ts +86 -18
  16. package/dist/structures/components/Group.js +69 -29
  17. package/dist/structures/components/ImageLayer.d.ts +85 -12
  18. package/dist/structures/components/ImageLayer.js +55 -42
  19. package/dist/structures/components/LineLayer.d.ts +111 -18
  20. package/dist/structures/components/LineLayer.js +58 -21
  21. package/dist/structures/components/MorphLayer.d.ts +109 -21
  22. package/dist/structures/components/MorphLayer.js +55 -27
  23. package/dist/structures/components/Path2DLayer.d.ts +191 -0
  24. package/dist/structures/components/Path2DLayer.js +318 -0
  25. package/dist/structures/components/QuadraticLayer.d.ts +108 -22
  26. package/dist/structures/components/QuadraticLayer.js +65 -30
  27. package/dist/structures/components/TextLayer.d.ts +201 -40
  28. package/dist/structures/components/TextLayer.js +101 -49
  29. package/dist/structures/components/index.d.ts +10 -0
  30. package/dist/structures/components/index.js +26 -0
  31. package/dist/structures/helpers/Exporter.d.ts +52 -0
  32. package/dist/structures/helpers/Exporter.js +168 -0
  33. package/dist/structures/helpers/Font.d.ts +64 -10
  34. package/dist/structures/helpers/Font.js +38 -11
  35. package/dist/structures/helpers/Gradient.d.ts +96 -9
  36. package/dist/structures/helpers/Gradient.js +48 -17
  37. package/dist/structures/helpers/Link.d.ts +52 -8
  38. package/dist/structures/helpers/Link.js +42 -11
  39. package/dist/structures/helpers/Pattern.d.ts +52 -7
  40. package/dist/structures/helpers/Pattern.js +45 -40
  41. package/dist/structures/helpers/index.d.ts +6 -0
  42. package/dist/structures/helpers/index.js +22 -0
  43. package/dist/structures/helpers/readers/JSONReader.d.ts +49 -0
  44. package/dist/structures/helpers/readers/JSONReader.js +172 -0
  45. package/dist/structures/helpers/readers/SVGReader.d.ts +20 -0
  46. package/dist/structures/helpers/readers/SVGReader.js +577 -0
  47. package/dist/structures/helpers/readers/YAMLReader.d.ts +0 -0
  48. package/dist/structures/helpers/readers/YAMLReader.js +1 -0
  49. package/dist/structures/managers/AnimationManager.d.ts +120 -0
  50. package/dist/structures/managers/AnimationManager.js +99 -0
  51. package/dist/structures/managers/FontsManager.d.ts +76 -32
  52. package/dist/structures/managers/FontsManager.js +70 -45
  53. package/dist/structures/managers/LayersManager.d.ts +84 -32
  54. package/dist/structures/managers/LayersManager.js +67 -29
  55. package/dist/structures/managers/RenderManager.d.ts +63 -6
  56. package/dist/structures/managers/RenderManager.js +162 -33
  57. package/dist/types/LazyCanvas.d.ts +2 -0
  58. package/dist/types/components/ClearLayer.d.ts +19 -0
  59. package/dist/types/enum.d.ts +20 -7
  60. package/dist/types/enum.js +24 -10
  61. package/dist/types/index.d.ts +2 -17
  62. package/dist/types/index.js +17 -0
  63. package/dist/types/managers/AnimationManager.d.ts +14 -0
  64. package/dist/types/types.d.ts +7 -3
  65. package/dist/utils/LazyUtil.js +2 -2
  66. package/dist/utils/utils.d.ts +10 -9
  67. package/dist/utils/utils.js +159 -164
  68. package/package.json +9 -5
@@ -7,19 +7,19 @@ export declare const Filters: {
7
7
  * @param radius {number} - The `radius` of the blur.
8
8
  * @returns {string}
9
9
  */
10
- blur(radius: number): string;
10
+ blur(radius: number): `blur(${number}px)`;
11
11
  /**
12
12
  * @description Adjusts the brightness of the input image. A value of `0%` will create an image that is completely black, while a value of `100%` leaves the input unchanged. If no value is specified, it defaults to `100%`.
13
13
  * @param amount {number} - The `amount` of the brightness.
14
14
  * @returns {string}
15
15
  */
16
- brightness(amount: number): string;
16
+ brightness(amount: number): `brightness(${number}%)`;
17
17
  /**
18
18
  * @description Adjusts the contrast of the input image. A value of `0%` will create an image that is completely black, while a value of `100%` leaves the input unchanged. If no value is specified, it defaults to `100%`.
19
19
  * @param amount {number} - The `amount` of the contrast.
20
20
  * @returns {string}
21
21
  */
22
- contrast(amount: number): string;
22
+ contrast(amount: number): `contrast(${number}%)`;
23
23
  /**
24
24
  * @description Applies a drop shadow effect to the input image. The value of `color` is the color of the shadow. The `offsetX` and `offsetY` values are the horizontal and vertical distances of the shadow, and the `blurRadius` is the amount of blur. If no value is specified, it defaults to `0`.
25
25
  * @param color {string} - The `color` of the shadow.
@@ -28,41 +28,41 @@ export declare const Filters: {
28
28
  * @param blurRadius {number} - The `blurRadius` of the shadow.
29
29
  * @returns {string}
30
30
  */
31
- dropShadow(color: string, offsetX: number, offsetY: number, blurRadius: number): string;
31
+ dropShadow(color: string, offsetX: number, offsetY: number, blurRadius: number): `drop-shadow(${number}px ${number}px ${number}px ${string})`;
32
32
  /**
33
33
  * @description Converts the input image to grayscale. A value of `0%` is completely unmodified, while a value of `100%` will make the image completely grayscale.
34
34
  * @param amount {number} - The `amount` of the grayscale.
35
35
  * @returns {string}
36
36
  */
37
- grayscale(amount: number): string;
37
+ grayscale(amount: number): `grayscale(${number}%)`;
38
38
  /**
39
39
  * @description Applies a hue rotation to the input image. The value of `angle` defines the number of degrees around the color circle the input samples will be adjusted. A value of `0deg` leaves the input unchanged.
40
40
  * @param angle {number} - The `angle` of the hue rotation.
41
41
  * @returns {string}
42
42
  */
43
- hueRotate(angle: number): string;
43
+ hueRotate(angle: number): `hue-rotate(${number}deg)`;
44
44
  /**
45
45
  * @description Inverts the samples in the input image. A value of `0%` leaves the input unchanged, while a value of `100%` is completely inverted.
46
46
  * @param amount {number} - The `amount` of the invert.
47
47
  * @returns {string}
48
48
  */
49
- invert(amount: number): string;
49
+ invert(amount: number): `invert(${number}%)`;
50
50
  /**
51
51
  * @description Sets the opacity of the input image. A value of `0%` is completely transparent, while a value of `100%` is completely opaque.
52
52
  * @param amount {number} - The `amount` of the opacity.
53
53
  * @returns {string}
54
54
  */
55
- opacity(amount: number): string;
55
+ opacity(amount: number): `opacity(${number}%)`;
56
56
  /**
57
57
  * @description Saturates the input image. A value of `0%` is completely unmodified, while a value of `100%` is completely saturated.
58
58
  * @param amount {number} - The `amount` of the saturation.
59
59
  * @returns {string}
60
60
  */
61
- saturate(amount: number): string;
61
+ saturate(amount: number): `saturate(${number}%)`;
62
62
  /**
63
63
  * @description Converts the input image to sepia. A value of `0%` is completely unmodified, while a value of `100%` is completely sepia.
64
64
  * @param amount {number} - The `amount` of the sepia.
65
65
  * @returns {string}
66
66
  */
67
- sepia(amount: number): string;
67
+ sepia(amount: number): `sepia(${number}%)`;
68
68
  };
@@ -1,4 +1,4 @@
1
- import { IFonts } from "../types/helpers/Font";
1
+ import { IFonts } from "../structures/helpers";
2
2
  /**
3
3
  * The bundled fonts in this package.
4
4
  * Used fonts:
@@ -1,4 +1,4 @@
1
- import { FontWeight } from "../types/enum";
1
+ import { FontWeight } from "../types";
2
2
  /**
3
3
  * The bundled fonts in this package.
4
4
  * Used fonts:
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FontsList = void 0;
4
- const enum_1 = require("../types/enum");
4
+ const types_1 = require("../types");
5
5
  /**
6
6
  * The bundled fonts in this package.
7
7
  * Used fonts:
@@ -9,57 +9,57 @@ const enum_1 = require("../types/enum");
9
9
  */
10
10
  exports.FontsList = {
11
11
  Geist_Thin(size) {
12
- return { family: 'Geist', size, weight: enum_1.FontWeight.Thin };
12
+ return { family: 'Geist', size, weight: types_1.FontWeight.Thin };
13
13
  },
14
14
  Geist_ExtraLight(size) {
15
- return { family: 'Geist', size, weight: enum_1.FontWeight.ExtraLight };
15
+ return { family: 'Geist', size, weight: types_1.FontWeight.ExtraLight };
16
16
  },
17
17
  Geist_Light(size) {
18
- return { family: 'Geist', size, weight: enum_1.FontWeight.Light };
18
+ return { family: 'Geist', size, weight: types_1.FontWeight.Light };
19
19
  },
20
20
  Geist_Regular(size) {
21
- return { family: 'Geist', size, weight: enum_1.FontWeight.Regular };
21
+ return { family: 'Geist', size, weight: types_1.FontWeight.Regular };
22
22
  },
23
23
  Geist_Medium(size) {
24
- return { family: 'Geist', size, weight: enum_1.FontWeight.Medium };
24
+ return { family: 'Geist', size, weight: types_1.FontWeight.Medium };
25
25
  },
26
26
  Geist_SemiBold(size) {
27
- return { family: 'Geist', size, weight: enum_1.FontWeight.SemiBold };
27
+ return { family: 'Geist', size, weight: types_1.FontWeight.SemiBold };
28
28
  },
29
29
  Geist_Bold(size) {
30
- return { family: 'Geist', size, weight: enum_1.FontWeight.Bold };
30
+ return { family: 'Geist', size, weight: types_1.FontWeight.Bold };
31
31
  },
32
32
  Geist_ExtraBold(size) {
33
- return { family: 'Geist', size, weight: enum_1.FontWeight.ExtraBold };
33
+ return { family: 'Geist', size, weight: types_1.FontWeight.ExtraBold };
34
34
  },
35
35
  Geist_Black(size) {
36
- return { family: 'Geist', size, weight: enum_1.FontWeight.Black };
36
+ return { family: 'Geist', size, weight: types_1.FontWeight.Black };
37
37
  },
38
38
  GeistMono_Thin(size) {
39
- return { family: 'GeistMono', size, weight: enum_1.FontWeight.Thin };
39
+ return { family: 'GeistMono', size, weight: types_1.FontWeight.Thin };
40
40
  },
41
41
  GeistMono_ExtraLight(size) {
42
- return { family: 'GeistMono', size, weight: enum_1.FontWeight.ExtraLight };
42
+ return { family: 'GeistMono', size, weight: types_1.FontWeight.ExtraLight };
43
43
  },
44
44
  GeistMono_Light(size) {
45
- return { family: 'GeistMono', size, weight: enum_1.FontWeight.Light };
45
+ return { family: 'GeistMono', size, weight: types_1.FontWeight.Light };
46
46
  },
47
47
  GeistMono_Regular(size) {
48
- return { family: 'GeistMono', size, weight: enum_1.FontWeight.Regular };
48
+ return { family: 'GeistMono', size, weight: types_1.FontWeight.Regular };
49
49
  },
50
50
  GeistMono_Medium(size) {
51
- return { family: 'GeistMono', size, weight: enum_1.FontWeight.Medium };
51
+ return { family: 'GeistMono', size, weight: types_1.FontWeight.Medium };
52
52
  },
53
53
  GeistMono_SemiBold(size) {
54
- return { family: 'GeistMono', size, weight: enum_1.FontWeight.SemiBold };
54
+ return { family: 'GeistMono', size, weight: types_1.FontWeight.SemiBold };
55
55
  },
56
56
  GeistMono_Bold(size) {
57
- return { family: 'GeistMono', size, weight: enum_1.FontWeight.Bold };
57
+ return { family: 'GeistMono', size, weight: types_1.FontWeight.Bold };
58
58
  },
59
59
  GeistMono_Black(size) {
60
- return { family: 'GeistMono', size, weight: enum_1.FontWeight.Black };
60
+ return { family: 'GeistMono', size, weight: types_1.FontWeight.Black };
61
61
  },
62
62
  GeistMono_ExtraBlack(size) {
63
- return { family: 'GeistMono', size, weight: enum_1.FontWeight.ExtraBlack };
63
+ return { family: 'GeistMono', size, weight: types_1.FontWeight.ExtraBlack };
64
64
  },
65
65
  };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,11 @@
1
- import { LazyCanvas } from "./structures/LazyCanvas";
2
- import { ImageLayer } from "./structures/components/ImageLayer";
3
- import { MorphLayer } from "./structures/components/MorphLayer";
4
- import { TextLayer } from "./structures/components/TextLayer";
5
- import { BezierLayer } from "./structures/components/BezierLayer";
6
- import { QuadraticLayer } from "./structures/components/QuadraticLayer";
7
- import { LineLayer } from "./structures/components/LineLayer";
8
- import { BaseLayer } from "./structures/components/BaseLayer";
9
- import { Group } from "./structures/components/Group";
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";
12
- import { Font } from "./structures/helpers/Font";
13
- import { Gradient } from "./structures/helpers/Gradient";
14
- import { Pattern } from "./structures/helpers/Pattern";
15
- import { Link } from "./structures/helpers/Link";
16
- import { saveFile } from "./utils/utils";
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 };
1
+ export { LazyCanvas, ILazyCanvas, ILazyCanvasOptions, IOLazyCanvas, } from "./structures/LazyCanvas";
2
+ export { IFontsManager } from "./structures/managers/FontsManager";
3
+ export { IAnimationManager, IAnimationOptions } from "./structures/managers/AnimationManager";
4
+ export { IRenderManager } from "./structures/managers/RenderManager";
5
+ export { ILayersManager } from "./structures/managers/LayersManager";
6
+ export * from "./structures/components";
7
+ export { LayerType, LayerScaleType, LineCap, LineJoin, TextAlign, TextDirection, TextBaseline, FontWeight, Export, Centring, PatternType, GradientType, LinkType } from "./types";
8
+ export { Font, IFont, IFonts, Gradient, IGradient, GradientPoint, GradientColorStop, Pattern, IPattern, Link, ILink, Exporter, JSONReader } from "./structures/helpers";
9
+ export { Filters } from "./helpers/Filters";
10
+ export { FontsList } from "./helpers/FontsList";
11
+ export type { AnyLayer, AnyCentring, AnyPatternType, AnyGradientType, AnyTextAlign, AnyTextDirection, AnyTextBaseline, AnyWeight, AnyLineCap, AnyLineJoin, AnyExport, AnyLinkType, AnyGlobalCompositeOperation, AnyColorSpace, ScaleType, ColorType, Point, PointNumber, Transform, Extensions } from "./types";
package/dist/index.js CHANGED
@@ -1,50 +1,45 @@
1
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
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
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
- const LazyCanvas_1 = require("./structures/LazyCanvas");
17
+ exports.FontsList = exports.Filters = exports.JSONReader = exports.Exporter = exports.Link = exports.Pattern = exports.Gradient = exports.Font = exports.LinkType = exports.GradientType = exports.PatternType = exports.Centring = exports.Export = exports.FontWeight = exports.TextBaseline = exports.TextDirection = exports.TextAlign = exports.LineJoin = exports.LineCap = exports.LayerScaleType = exports.LayerType = exports.LazyCanvas = void 0;
18
+ var LazyCanvas_1 = require("./structures/LazyCanvas");
5
19
  Object.defineProperty(exports, "LazyCanvas", { enumerable: true, get: function () { return LazyCanvas_1.LazyCanvas; } });
6
- const ImageLayer_1 = require("./structures/components/ImageLayer");
7
- Object.defineProperty(exports, "ImageLayer", { enumerable: true, get: function () { return ImageLayer_1.ImageLayer; } });
8
- const MorphLayer_1 = require("./structures/components/MorphLayer");
9
- Object.defineProperty(exports, "MorphLayer", { enumerable: true, get: function () { return MorphLayer_1.MorphLayer; } });
10
- const TextLayer_1 = require("./structures/components/TextLayer");
11
- Object.defineProperty(exports, "TextLayer", { enumerable: true, get: function () { return TextLayer_1.TextLayer; } });
12
- const BezierLayer_1 = require("./structures/components/BezierLayer");
13
- Object.defineProperty(exports, "BezierLayer", { enumerable: true, get: function () { return BezierLayer_1.BezierLayer; } });
14
- const QuadraticLayer_1 = require("./structures/components/QuadraticLayer");
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; } });
18
- const BaseLayer_1 = require("./structures/components/BaseLayer");
19
- Object.defineProperty(exports, "BaseLayer", { enumerable: true, get: function () { return BaseLayer_1.BaseLayer; } });
20
- const Group_1 = require("./structures/components/Group");
21
- Object.defineProperty(exports, "Group", { enumerable: true, get: function () { return Group_1.Group; } });
22
- const enum_1 = require("./types/enum");
23
- Object.defineProperty(exports, "LayerType", { enumerable: true, get: function () { return enum_1.LayerType; } });
24
- Object.defineProperty(exports, "LayerScaleType", { enumerable: true, get: function () { return enum_1.LayerScaleType; } });
25
- Object.defineProperty(exports, "LineCap", { enumerable: true, get: function () { return enum_1.LineCap; } });
26
- Object.defineProperty(exports, "LineJoin", { enumerable: true, get: function () { return enum_1.LineJoin; } });
27
- Object.defineProperty(exports, "TextAlign", { enumerable: true, get: function () { return enum_1.TextAlign; } });
28
- Object.defineProperty(exports, "TextDirection", { enumerable: true, get: function () { return enum_1.TextDirection; } });
29
- Object.defineProperty(exports, "TextBaseline", { enumerable: true, get: function () { return enum_1.TextBaseline; } });
30
- Object.defineProperty(exports, "FontWeight", { enumerable: true, get: function () { return enum_1.FontWeight; } });
31
- Object.defineProperty(exports, "Export", { enumerable: true, get: function () { return enum_1.Export; } });
32
- Object.defineProperty(exports, "Centring", { enumerable: true, get: function () { return enum_1.Centring; } });
33
- Object.defineProperty(exports, "PatternType", { enumerable: true, get: function () { return enum_1.PatternType; } });
34
- Object.defineProperty(exports, "SaveFormat", { enumerable: true, get: function () { return enum_1.SaveFormat; } });
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; } });
37
- const Font_1 = require("./structures/helpers/Font");
38
- Object.defineProperty(exports, "Font", { enumerable: true, get: function () { return Font_1.Font; } });
39
- const Gradient_1 = require("./structures/helpers/Gradient");
40
- Object.defineProperty(exports, "Gradient", { enumerable: true, get: function () { return Gradient_1.Gradient; } });
41
- const Pattern_1 = require("./structures/helpers/Pattern");
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; } });
45
- const utils_1 = require("./utils/utils");
46
- Object.defineProperty(exports, "saveFile", { enumerable: true, get: function () { return utils_1.saveFile; } });
47
- const Filters_1 = require("./helpers/Filters");
20
+ __exportStar(require("./structures/components"), exports);
21
+ var types_1 = require("./types");
22
+ Object.defineProperty(exports, "LayerType", { enumerable: true, get: function () { return types_1.LayerType; } });
23
+ Object.defineProperty(exports, "LayerScaleType", { enumerable: true, get: function () { return types_1.LayerScaleType; } });
24
+ Object.defineProperty(exports, "LineCap", { enumerable: true, get: function () { return types_1.LineCap; } });
25
+ Object.defineProperty(exports, "LineJoin", { enumerable: true, get: function () { return types_1.LineJoin; } });
26
+ Object.defineProperty(exports, "TextAlign", { enumerable: true, get: function () { return types_1.TextAlign; } });
27
+ Object.defineProperty(exports, "TextDirection", { enumerable: true, get: function () { return types_1.TextDirection; } });
28
+ Object.defineProperty(exports, "TextBaseline", { enumerable: true, get: function () { return types_1.TextBaseline; } });
29
+ Object.defineProperty(exports, "FontWeight", { enumerable: true, get: function () { return types_1.FontWeight; } });
30
+ Object.defineProperty(exports, "Export", { enumerable: true, get: function () { return types_1.Export; } });
31
+ Object.defineProperty(exports, "Centring", { enumerable: true, get: function () { return types_1.Centring; } });
32
+ Object.defineProperty(exports, "PatternType", { enumerable: true, get: function () { return types_1.PatternType; } });
33
+ Object.defineProperty(exports, "GradientType", { enumerable: true, get: function () { return types_1.GradientType; } });
34
+ Object.defineProperty(exports, "LinkType", { enumerable: true, get: function () { return types_1.LinkType; } });
35
+ var helpers_1 = require("./structures/helpers");
36
+ Object.defineProperty(exports, "Font", { enumerable: true, get: function () { return helpers_1.Font; } });
37
+ Object.defineProperty(exports, "Gradient", { enumerable: true, get: function () { return helpers_1.Gradient; } });
38
+ Object.defineProperty(exports, "Pattern", { enumerable: true, get: function () { return helpers_1.Pattern; } });
39
+ Object.defineProperty(exports, "Link", { enumerable: true, get: function () { return helpers_1.Link; } });
40
+ Object.defineProperty(exports, "Exporter", { enumerable: true, get: function () { return helpers_1.Exporter; } });
41
+ Object.defineProperty(exports, "JSONReader", { enumerable: true, get: function () { return helpers_1.JSONReader; } });
42
+ var Filters_1 = require("./helpers/Filters");
48
43
  Object.defineProperty(exports, "Filters", { enumerable: true, get: function () { return Filters_1.Filters; } });
49
- const FontsList_1 = require("./helpers/FontsList");
44
+ var FontsList_1 = require("./helpers/FontsList");
50
45
  Object.defineProperty(exports, "FontsList", { enumerable: true, get: function () { return FontsList_1.FontsList; } });
@@ -1,32 +1,141 @@
1
- import { AnyExport, ILazyCanvas } from "../types";
2
- import { Canvas, SKRSContext2D, SvgExportFlag } from "@napi-rs/canvas";
1
+ import { AnyExport, JSONLayer } from "../types";
2
+ import { Canvas, SKRSContext2D, SvgCanvas, SvgExportFlag } from "@napi-rs/canvas";
3
3
  import { LayersManager } from "./managers/LayersManager";
4
4
  import { RenderManager } from "./managers/RenderManager";
5
5
  import { FontsManager } from "./managers/FontsManager";
6
- export declare class LazyCanvas implements ILazyCanvas {
7
- width: number | 0;
8
- height: number | 0;
9
- canvas: Canvas;
6
+ import { AnimationManager, IAnimationOptions } from "./managers/AnimationManager";
7
+ import { Group } from "./components";
8
+ /**
9
+ * Interface representing the LazyCanvas structure.
10
+ */
11
+ export interface ILazyCanvas {
12
+ /**
13
+ * The canvas instance, which can be either a Canvas or SvgCanvas.
14
+ */
15
+ canvas: Canvas | SvgCanvas;
16
+ /**
17
+ * The 2D rendering context of the canvas.
18
+ */
10
19
  ctx: SKRSContext2D;
11
- layers: LayersManager;
12
- render: RenderManager;
13
- fonts: FontsManager;
20
+ /**
21
+ * The manager object containing various managers for layers, rendering, fonts, and animation.
22
+ */
23
+ manager: {
24
+ layers: LayersManager;
25
+ render: RenderManager;
26
+ fonts: FontsManager;
27
+ animation: AnimationManager;
28
+ };
29
+ /**
30
+ * The options for configuring the LazyCanvas instance.
31
+ */
32
+ options: ILazyCanvasOptions;
33
+ }
34
+ /**
35
+ * Interface representing the options for LazyCanvas.
36
+ */
37
+ export interface ILazyCanvasOptions {
38
+ /**
39
+ * The width of the canvas.
40
+ */
41
+ width: number;
42
+ /**
43
+ * The height of the canvas.
44
+ */
45
+ height: number;
46
+ /**
47
+ * Whether the canvas is animated.
48
+ */
49
+ animated: boolean;
50
+ /**
51
+ * The export type for the canvas (e.g., buffer, SVG, etc.).
52
+ */
14
53
  exportType: AnyExport;
15
- constructor(debug?: boolean);
16
54
  /**
17
- * Set the export type
18
- * @param type {AnyExport} - The `export` type
55
+ * The SVG export flag for encoding paths.
56
+ */
57
+ flag: SvgExportFlag;
58
+ }
59
+ /**
60
+ * Interface representing the input options for LazyCanvas.
61
+ */
62
+ export interface IOLazyCanvas {
63
+ /**
64
+ * The options for configuring the LazyCanvas instance.
65
+ */
66
+ options: ILazyCanvasOptions;
67
+ /**
68
+ * The animation options for the LazyCanvas instance.
69
+ */
70
+ animation: IAnimationOptions;
71
+ /**
72
+ * The layers to be added to the LazyCanvas instance.
73
+ */
74
+ layers: Array<JSONLayer | Group>;
75
+ }
76
+ /**
77
+ * Class representing a LazyCanvas, which provides a structured way to manage canvas rendering.
78
+ */
79
+ export declare class LazyCanvas implements ILazyCanvas {
80
+ /**
81
+ * The canvas instance, which can be either a Canvas or SvgCanvas.
82
+ */
83
+ canvas: Canvas | SvgCanvas;
84
+ /**
85
+ * The 2D rendering context of the canvas.
86
+ */
87
+ ctx: SKRSContext2D;
88
+ /**
89
+ * The manager object containing various managers for layers, rendering, fonts, and animation.
90
+ */
91
+ manager: {
92
+ layers: LayersManager;
93
+ render: RenderManager;
94
+ fonts: FontsManager;
95
+ animation: AnimationManager;
96
+ };
97
+ /**
98
+ * The options for configuring the LazyCanvas instance.
99
+ */
100
+ options: ILazyCanvasOptions;
101
+ /**
102
+ * Constructs a new LazyCanvas instance.
103
+ * @param opts {Object} - Optional settings for the LazyCanvas instance.
104
+ * @param opts.debug {boolean} - Whether debugging is enabled.
105
+ * @param opts.settings {IOLazyCanvas} - The input settings for the LazyCanvas instance.
106
+ */
107
+ constructor(opts?: {
108
+ debug?: boolean;
109
+ settings?: IOLazyCanvas;
110
+ });
111
+ /**
112
+ * Sets the export type for the canvas.
113
+ * @param type {AnyExport} - The export type (e.g., buffer, SVG, etc.).
114
+ * @returns {this} The current instance for chaining.
19
115
  */
20
116
  setExportType(type: AnyExport): this;
21
117
  /**
22
- * Set the SVG export flag. This method should be called after `setExportType` method.
23
- * @param flag {SvgExportFlag} - The `flag` of the SVG export
118
+ * Sets the SVG export flag. This method should be called after `setExportType`.
119
+ * @param flag {SvgExportFlag} - The SVG export flag.
120
+ * @returns {this} The current instance for chaining.
24
121
  */
25
122
  setSvgExportFlag(flag: SvgExportFlag): this;
26
123
  /**
27
- * Create a new canvas. This method should be called before any other methods.
28
- * @param width {number} - The `width` of the canvas
29
- * @param height {number} - The `height` of the canvas
124
+ * Enables animation for the canvas.
125
+ * @returns {this} The current instance for chaining.
126
+ */
127
+ animated(): this;
128
+ /**
129
+ * Resizes the canvas to the specified dimensions.
130
+ * @param ratio {number} - The ratio to resize the canvas.
131
+ * @returns {this} The current instance for chaining.
132
+ */
133
+ resize(ratio: number): this;
134
+ /**
135
+ * Creates a new canvas with the specified dimensions.
136
+ * @param width {number} - The width of the canvas.
137
+ * @param height {number} - The height of the canvas.
138
+ * @returns {this} The current instance for chaining.
30
139
  */
31
140
  create(width: number, height: number): this;
32
141
  }
@@ -1,72 +1,140 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.LazyCanvas = void 0;
4
- const enum_1 = require("../types/enum");
4
+ const types_1 = require("../types");
5
5
  const canvas_1 = require("@napi-rs/canvas");
6
6
  const LayersManager_1 = require("./managers/LayersManager");
7
7
  const RenderManager_1 = require("./managers/RenderManager");
8
8
  const FontsManager_1 = require("./managers/FontsManager");
9
+ const AnimationManager_1 = require("./managers/AnimationManager");
10
+ const LazyUtil_1 = require("../utils/LazyUtil");
11
+ const utils_1 = require("../utils/utils");
12
+ /**
13
+ * Class representing a LazyCanvas, which provides a structured way to manage canvas rendering.
14
+ */
9
15
  class LazyCanvas {
10
- width;
11
- height;
16
+ /**
17
+ * The canvas instance, which can be either a Canvas or SvgCanvas.
18
+ */
12
19
  canvas;
20
+ /**
21
+ * The 2D rendering context of the canvas.
22
+ */
13
23
  ctx;
14
- layers;
15
- render;
16
- fonts;
17
- exportType;
18
- constructor(debug = false) {
19
- this.width = 0;
20
- this.height = 0;
24
+ /**
25
+ * The manager object containing various managers for layers, rendering, fonts, and animation.
26
+ */
27
+ manager;
28
+ /**
29
+ * The options for configuring the LazyCanvas instance.
30
+ */
31
+ options;
32
+ /**
33
+ * Constructs a new LazyCanvas instance.
34
+ * @param opts {Object} - Optional settings for the LazyCanvas instance.
35
+ * @param opts.debug {boolean} - Whether debugging is enabled.
36
+ * @param opts.settings {IOLazyCanvas} - The input settings for the LazyCanvas instance.
37
+ */
38
+ constructor(opts) {
21
39
  this.canvas = new canvas_1.Canvas(0, 0);
22
40
  this.ctx = this.canvas.getContext('2d');
23
- this.layers = new LayersManager_1.LayersManager(debug);
24
- this.render = new RenderManager_1.RenderManager(this, debug);
25
- this.fonts = new FontsManager_1.FontsManager(debug);
26
- this.exportType = enum_1.Export.Buffer;
41
+ this.manager = {
42
+ layers: new LayersManager_1.LayersManager({ debug: opts?.debug }),
43
+ render: new RenderManager_1.RenderManager(this, { debug: opts?.debug }),
44
+ fonts: new FontsManager_1.FontsManager({ debug: opts?.debug }),
45
+ animation: new AnimationManager_1.AnimationManager({ debug: opts?.debug, settings: { options: opts?.settings?.animation } })
46
+ };
47
+ this.options = {
48
+ width: opts?.settings?.options.width || 0,
49
+ height: opts?.settings?.options.height || 0,
50
+ animated: opts?.settings?.options.animated || false,
51
+ exportType: opts?.settings?.options.exportType || types_1.Export.BUFFER,
52
+ flag: opts?.settings?.options.flag || canvas_1.SvgExportFlag.RelativePathEncoding
53
+ };
54
+ if (opts?.debug)
55
+ LazyUtil_1.LazyLog.log('info', 'LazyCanvas initialized with settings:', opts.settings);
27
56
  }
28
57
  /**
29
- * Set the export type
30
- * @param type {AnyExport} - The `export` type
58
+ * Sets the export type for the canvas.
59
+ * @param type {AnyExport} - The export type (e.g., buffer, SVG, etc.).
60
+ * @returns {this} The current instance for chaining.
31
61
  */
32
62
  setExportType(type) {
33
- this.exportType = type;
63
+ this.options.exportType = type;
34
64
  switch (type) {
35
- case enum_1.Export.Buffer:
36
- this.canvas = new canvas_1.Canvas(this.width, this.height);
65
+ case types_1.Export.BUFFER:
66
+ this.canvas = new canvas_1.Canvas(this.options.width, this.options.height);
37
67
  this.ctx = this.canvas.getContext('2d');
38
68
  break;
39
- case enum_1.Export.CTX:
69
+ case types_1.Export.CTX:
40
70
  break;
41
- case enum_1.Export.SVG:
42
- this.canvas = new canvas_1.Canvas(this.width, this.height, canvas_1.SvgExportFlag.RelativePathEncoding);
71
+ case types_1.Export.SVG:
72
+ this.canvas = new canvas_1.Canvas(this.options.width, this.options.height, this.options.flag || canvas_1.SvgExportFlag.RelativePathEncoding);
43
73
  this.ctx = this.canvas.getContext('2d');
44
74
  break;
45
75
  }
46
76
  return this;
47
77
  }
48
78
  /**
49
- * Set the SVG export flag. This method should be called after `setExportType` method.
50
- * @param flag {SvgExportFlag} - The `flag` of the SVG export
79
+ * Sets the SVG export flag. This method should be called after `setExportType`.
80
+ * @param flag {SvgExportFlag} - The SVG export flag.
81
+ * @returns {this} The current instance for chaining.
51
82
  */
52
83
  setSvgExportFlag(flag) {
53
- if (this.exportType === enum_1.Export.SVG) {
54
- this.canvas = new canvas_1.Canvas(this.width, this.height, flag);
84
+ if (this.options.exportType === types_1.Export.SVG) {
85
+ this.canvas = new canvas_1.Canvas(this.options.width, this.options.height, flag);
55
86
  this.ctx = this.canvas.getContext('2d');
87
+ this.options.flag = flag;
88
+ }
89
+ return this;
90
+ }
91
+ /**
92
+ * Enables animation for the canvas.
93
+ * @returns {this} The current instance for chaining.
94
+ */
95
+ animated() {
96
+ this.options.animated = true;
97
+ return this;
98
+ }
99
+ /**
100
+ * Resizes the canvas to the specified dimensions.
101
+ * @param ratio {number} - The ratio to resize the canvas.
102
+ * @returns {this} The current instance for chaining.
103
+ */
104
+ resize(ratio) {
105
+ if (this.options.width <= 0 || this.options.height <= 0) {
106
+ throw new Error('Canvas dimensions are not set.');
107
+ }
108
+ this.options.width = (0, utils_1.resize)(this.options.width, ratio);
109
+ this.options.height = (0, utils_1.resize)(this.options.height, ratio);
110
+ if (this.options.exportType === types_1.Export.SVG) {
111
+ this.canvas = new canvas_1.Canvas(this.options.width, this.options.height, this.options.flag || canvas_1.SvgExportFlag.RelativePathEncoding);
112
+ }
113
+ else {
114
+ this.canvas = new canvas_1.Canvas(this.options.width, this.options.height);
56
115
  }
116
+ this.ctx = this.canvas.getContext('2d');
117
+ const layers = (0, utils_1.resizeLayers)(this.manager.layers.toArray(), ratio);
118
+ this.manager.layers.fromArray(layers);
57
119
  return this;
58
120
  }
59
121
  /**
60
- * Create a new canvas. This method should be called before any other methods.
61
- * @param width {number} - The `width` of the canvas
62
- * @param height {number} - The `height` of the canvas
122
+ * Creates a new canvas with the specified dimensions.
123
+ * @param width {number} - The width of the canvas.
124
+ * @param height {number} - The height of the canvas.
125
+ * @returns {this} The current instance for chaining.
63
126
  */
64
127
  create(width, height) {
65
- this.width = width;
66
- this.height = height;
67
- this.canvas = new canvas_1.Canvas(width, height);
128
+ this.options.width = width;
129
+ this.options.height = height;
130
+ if (this.options.exportType === types_1.Export.SVG) {
131
+ this.canvas = new canvas_1.Canvas(width, height, this.options.flag || canvas_1.SvgExportFlag.RelativePathEncoding);
132
+ }
133
+ else {
134
+ this.canvas = new canvas_1.Canvas(width, height);
135
+ }
68
136
  this.ctx = this.canvas.getContext('2d');
69
- this.layers = new LayersManager_1.LayersManager();
137
+ this.manager.layers = new LayersManager_1.LayersManager();
70
138
  return this;
71
139
  }
72
140
  }