@nmmty/lazycanvas 0.3.2 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/helpers/FontsList.d.ts +98 -0
  2. package/dist/helpers/FontsList.js +65 -0
  3. package/dist/index.d.ts +8 -4
  4. package/dist/index.js +10 -3
  5. package/dist/structures/LazyCanvas.d.ts +4 -5
  6. package/dist/structures/LazyCanvas.js +1 -1
  7. package/dist/structures/components/BaseLayer.d.ts +4 -4
  8. package/dist/structures/components/BaseLayer.js +1 -1
  9. package/dist/structures/components/BezierLayer.d.ts +16 -0
  10. package/dist/structures/components/BezierLayer.js +26 -8
  11. package/dist/structures/components/ImageLayer.js +8 -5
  12. package/dist/structures/components/LineLayer.d.ts +8 -0
  13. package/dist/structures/components/LineLayer.js +21 -4
  14. package/dist/structures/components/MorphLayer.js +8 -5
  15. package/dist/structures/components/QuadraticLayer.d.ts +16 -0
  16. package/dist/structures/components/QuadraticLayer.js +22 -6
  17. package/dist/structures/components/TextLayer.d.ts +15 -11
  18. package/dist/structures/components/TextLayer.js +41 -27
  19. package/dist/structures/helpers/Font.d.ts +4 -4
  20. package/dist/structures/helpers/Font.js +2 -2
  21. package/dist/structures/helpers/Gradient.d.ts +4 -5
  22. package/dist/structures/helpers/Gradient.js +4 -1
  23. package/dist/structures/helpers/Link.d.ts +22 -0
  24. package/dist/structures/helpers/Link.js +39 -0
  25. package/dist/structures/helpers/Pattern.d.ts +4 -5
  26. package/dist/structures/helpers/Pattern.js +1 -1
  27. package/dist/structures/managers/FontsManager.d.ts +1 -1
  28. package/dist/structures/managers/FontsManager.js +1 -2
  29. package/dist/structures/managers/RenderManager.js +3 -0
  30. package/dist/types/LazyCanvas.d.ts +2 -2
  31. package/dist/types/components/BaseLayer.d.ts +3 -3
  32. package/dist/types/components/Group.d.ts +3 -1
  33. package/dist/types/components/MorphLayer.d.ts +1 -1
  34. package/dist/types/components/TextLayer.d.ts +8 -7
  35. package/dist/types/enum.d.ts +7 -1
  36. package/dist/types/enum.js +9 -2
  37. package/dist/types/helpers/Font.d.ts +2 -2
  38. package/dist/types/helpers/Gradient.d.ts +2 -2
  39. package/dist/types/helpers/Link.d.ts +7 -0
  40. package/dist/types/helpers/Pattern.d.ts +2 -2
  41. package/dist/types/index.d.ts +17 -16
  42. package/dist/types/types.d.ts +42 -2
  43. package/dist/utils/LazyUtil.d.ts +10 -0
  44. package/dist/utils/LazyUtil.js +9 -1
  45. package/dist/utils/utils.d.ts +24 -4
  46. package/dist/utils/utils.js +152 -28
  47. package/package.json +4 -2
  48. package/example.png +0 -0
  49. /package/dist/helpers/{filters.d.ts → Filters.d.ts} +0 -0
  50. /package/dist/helpers/{filters.js → Filters.js} +0 -0
@@ -16,15 +16,17 @@ class TextLayer extends BaseLayer_1.BaseLayer {
16
16
  this.props.font = {
17
17
  family: 'Geist',
18
18
  size: 16,
19
- weight: enum_1.FontWeight.Normal,
19
+ weight: enum_1.FontWeight.Regular,
20
20
  };
21
21
  this.props.fillStyle = '#ffffff';
22
22
  this.props.filled = true;
23
23
  this.props.multiline = {
24
24
  enabled: false,
25
+ spacing: 1.1,
26
+ };
27
+ this.props.size = {
25
28
  width: 'vw',
26
29
  height: 0,
27
- spacing: 1.1,
28
30
  };
29
31
  this.props.centring = enum_1.Centring.Center;
30
32
  }
@@ -38,22 +40,29 @@ class TextLayer extends BaseLayer_1.BaseLayer {
38
40
  }
39
41
  /**
40
42
  * @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 family {string} - The `family` of the font.
43
+ * @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
44
  * @param size {number} - The `size` of the font.
43
- * @param weight {FontWeight} - The `weight` of the font.
45
+ * @param weight {AnyWeight} - The `weight` of the font.
44
46
  */
45
- setFont(family, size, weight) {
46
- if (!family)
47
- throw new LazyUtil_1.LazyError('The family of the font must be provided');
48
- if (!size)
49
- throw new LazyUtil_1.LazyError('The size of the font must be provided');
50
- if (!weight)
51
- throw new LazyUtil_1.LazyError('The weight of the font must be provided');
52
- this.props.font = {
53
- family: family,
54
- size: size,
55
- weight: weight,
56
- };
47
+ setFont(familyOrConfig, size, weight) {
48
+ if (typeof familyOrConfig === "string") {
49
+ if (!size)
50
+ throw new LazyUtil_1.LazyError('The size of the font must be provided');
51
+ if (!weight)
52
+ throw new LazyUtil_1.LazyError('The weight of the font must be provided');
53
+ this.props.font = {
54
+ family: familyOrConfig,
55
+ size,
56
+ weight,
57
+ };
58
+ }
59
+ else {
60
+ this.props.font = {
61
+ family: familyOrConfig.family,
62
+ size: familyOrConfig.size,
63
+ weight: familyOrConfig.weight,
64
+ };
65
+ }
57
66
  return this;
58
67
  }
59
68
  /**
@@ -66,10 +75,12 @@ class TextLayer extends BaseLayer_1.BaseLayer {
66
75
  setMultiline(enabled, width, height, spacing) {
67
76
  this.props.multiline = {
68
77
  enabled: enabled,
69
- width: width,
70
- height: height,
71
78
  spacing: spacing || 1.1,
72
79
  };
80
+ this.props.size = {
81
+ width,
82
+ height,
83
+ };
73
84
  return this;
74
85
  }
75
86
  /**
@@ -94,7 +105,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
94
105
  }
95
106
  /**
96
107
  * @description Set the align of the text layer.
97
- * @param align {TextAlign} - The `align` of the text layer.
108
+ * @param align {AnyTextAlign} - The `align` of the text layer.
98
109
  */
99
110
  setAlign(align) {
100
111
  this.props.align = align;
@@ -102,7 +113,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
102
113
  }
103
114
  /**
104
115
  * @description Set the baseline of the text layer.
105
- * @param baseline {TextBaseline} - The `baseline` of the text layer.
116
+ * @param baseline {AnyTextBaseline} - The `baseline` of the text layer.
106
117
  */
107
118
  setBaseline(baseline) {
108
119
  this.props.baseline = baseline;
@@ -110,7 +121,7 @@ class TextLayer extends BaseLayer_1.BaseLayer {
110
121
  }
111
122
  /**
112
123
  * @description Set the direction of the text layer.
113
- * @param direction {TextDirection} - The `direction` of the text layer.
124
+ * @param direction {AnyTextDirection} - The `direction` of the text layer.
114
125
  */
115
126
  setDirection(direction) {
116
127
  this.props.direction = direction;
@@ -145,8 +156,8 @@ class TextLayer extends BaseLayer_1.BaseLayer {
145
156
  return this;
146
157
  }
147
158
  measureText(ctx, canvas) {
148
- const w = (0, utils_1.parseToNormal)(this.props.multiline?.width, ctx, canvas);
149
- const h = (0, utils_1.parseToNormal)(this.props.multiline?.height, ctx, canvas, { width: w, height: 0 }, { vertical: true });
159
+ const w = (0, utils_1.parseToNormal)(this.props.size?.width, ctx, canvas);
160
+ const h = (0, utils_1.parseToNormal)(this.props.size?.height, ctx, canvas, { width: w, height: 0 }, { vertical: true });
150
161
  if (this.props.multiline.enabled) {
151
162
  return { width: w, height: h };
152
163
  }
@@ -157,10 +168,13 @@ class TextLayer extends BaseLayer_1.BaseLayer {
157
168
  }
158
169
  }
159
170
  async draw(ctx, canvas, manager, debug) {
160
- const x = (0, utils_1.parseToNormal)(this.props.x, ctx, canvas);
161
- const y = (0, utils_1.parseToNormal)(this.props.y, ctx, canvas, { width: 0, height: 0 }, { vertical: true });
162
- const w = (0, utils_1.parseToNormal)(this.props.multiline?.width, ctx, canvas);
163
- const h = (0, utils_1.parseToNormal)(this.props.multiline?.height, ctx, canvas, { width: w, height: 0 }, { vertical: true });
171
+ const parcer = (0, utils_1.parser)(ctx, canvas, manager);
172
+ const { x, y, w, h } = parcer.parseBatch({
173
+ x: { v: this.props.x },
174
+ y: { v: this.props.y, options: LazyUtil_1.defaultArg.vl(true) },
175
+ w: { v: this.props.size?.width },
176
+ h: { v: this.props.size?.height, options: LazyUtil_1.defaultArg.vl(true) },
177
+ });
164
178
  if (debug)
165
179
  LazyUtil_1.LazyLog.log('none', `TextLayer:`, { x, y, w, h });
166
180
  ctx.save();
@@ -1,10 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  /// <reference types="node" />
3
- import { FontWeight } from "../../types/enum";
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: FontWeight;
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 {FontWeight} - The `weight` of the font
18
+ * @param weight {AnyWeight} - The `weight` of the font
19
19
  */
20
- setWeight(weight: FontWeight): this;
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.Normal;
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 {FontWeight} - The `weight` of the font
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 { GradientType } from "../../types/enum";
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: GradientType;
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 {GradientType} - The `type` of the gradient. Can be `linear`, `radial`, or `conic`
10
+ * @param type {AnyGradientType} - The `type` of the gradient. Can be `linear`, `radial`, or `conic`
12
11
  */
13
- setType(type: GradientType): this;
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 {GradientType} - The `type` of the gradient. Can be `linear`, `radial`, or `conic`
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:
@@ -0,0 +1,22 @@
1
+ import { AnyLinkType, ILink, ScaleType } from "../../types";
2
+ export declare class Link {
3
+ source: string;
4
+ type: AnyLinkType;
5
+ additionalSpacing: ScaleType;
6
+ constructor(props?: ILink);
7
+ /**
8
+ * @description Sets the source of the link.
9
+ * @param source {string} - The `id` of the layer to link.
10
+ */
11
+ setSource(source: string): this;
12
+ /**
13
+ * @description Sets the type of the link.
14
+ * @param type {AnyLinkType} - The `type` of the link.
15
+ */
16
+ setType(type: AnyLinkType): this;
17
+ /**
18
+ * @description Sets the additional spacing of the link.
19
+ * @param additionalSpacing {ScaleType} - The `additionalSpacing` of the link.
20
+ */
21
+ setSpacing(additionalSpacing: ScaleType): this;
22
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Link = void 0;
4
+ const enum_1 = require("../../types/enum");
5
+ class Link {
6
+ source;
7
+ type;
8
+ additionalSpacing;
9
+ constructor(props) {
10
+ this.source = props?.source || '';
11
+ this.type = props?.type || enum_1.LinkType.Width;
12
+ this.additionalSpacing = props?.additionalSpacing || 0;
13
+ }
14
+ /**
15
+ * @description Sets the source of the link.
16
+ * @param source {string} - The `id` of the layer to link.
17
+ */
18
+ setSource(source) {
19
+ this.source = source;
20
+ return this;
21
+ }
22
+ /**
23
+ * @description Sets the type of the link.
24
+ * @param type {AnyLinkType} - The `type` of the link.
25
+ */
26
+ setType(type) {
27
+ this.type = type;
28
+ return this;
29
+ }
30
+ /**
31
+ * @description Sets the additional spacing of the link.
32
+ * @param additionalSpacing {ScaleType} - The `additionalSpacing` of the link.
33
+ */
34
+ setSpacing(additionalSpacing) {
35
+ this.additionalSpacing = additionalSpacing;
36
+ return this;
37
+ }
38
+ }
39
+ exports.Link = Link;
@@ -1,16 +1,15 @@
1
- import { PatternType } from "../../types/enum";
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: PatternType;
5
+ type: AnyPatternType;
7
6
  src: string | LazyCanvas;
8
7
  constructor();
9
8
  /**
10
9
  * Set the type of the pattern
11
- * @param type {PatternType} - The `type` of the pattern
10
+ * @param type {AnyPatternType} - The `type` of the pattern
12
11
  */
13
- setType(type: PatternType): this;
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
@@ -37,7 +37,7 @@ class Pattern {
37
37
  }
38
38
  /**
39
39
  * Set the type of the pattern
40
- * @param type {PatternType} - The `type` of the pattern
40
+ * @param type {AnyPatternType} - The `type` of the pattern
41
41
  */
42
42
  setType(type) {
43
43
  this.type = type;
@@ -1,4 +1,4 @@
1
- import { IFontsManager, IFonts } from "../../types";
1
+ import { IFonts, IFontsManager } from "../../types";
2
2
  import { Font } from "../helpers/Font";
3
3
  export declare class FontsManager implements IFontsManager {
4
4
  map: Map<string, Font>;
@@ -11,8 +11,7 @@ class FontsManager {
11
11
  constructor(debug = false) {
12
12
  this.debug = debug;
13
13
  this.map = new Map();
14
- let fontList = Fonts_1.Fonts;
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 { Export } from "./enum";
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: Export;
15
+ exportType: AnyExport;
16
16
  }
@@ -1,5 +1,5 @@
1
- import { ColorType, ScaleType } from "../";
2
- import { Centring, LayerType } from "../enum";
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: Centring;
15
+ centring: AnyCentring;
16
16
  filter: string;
17
17
  opacity: number;
18
18
  filled: boolean;
@@ -1,6 +1,8 @@
1
+ import { AnyLayer } from "../";
2
+
1
3
  export interface IGroup {
2
4
  id: string;
3
5
  visible: boolean;
4
6
  zIndex: number;
5
- components: Array<any>;
7
+ components: Array<AnyLayer>;
6
8
  }
@@ -1,5 +1,5 @@
1
1
  import { IBaseLayer, IBaseLayerProps } from "./BaseLayer";
2
- import {ColorType, ScaleType} from "../";
2
+ import { ScaleType } from "../";
3
3
 
4
4
  export interface IMorphLayer extends IBaseLayer {
5
5
  props: IMorphLayerProps;
@@ -1,6 +1,5 @@
1
- import { ColorType, ScaleType } from "../";
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,15 +10,17 @@ export interface ITextLayerProps extends IBaseLayerProps {
11
10
  font: {
12
11
  family: string;
13
12
  size: number;
14
- weight: FontWeight;
13
+ weight: AnyWeight;
15
14
  };
16
15
  multiline: {
17
16
  enabled: boolean;
17
+ spacing?: number;
18
+ };
19
+ size: {
18
20
  width: ScaleType;
19
21
  height: ScaleType;
20
- spacing?: number;
21
22
  };
22
- align: TextAlign;
23
- baseline: TextBaseline;
24
- direction: TextDirection;
23
+ align: AnyTextAlign;
24
+ baseline: AnyTextBaseline;
25
+ direction: AnyTextDirection;
25
26
  }
@@ -27,7 +27,7 @@ export declare enum FontWeight {
27
27
  Thin = 100,
28
28
  ExtraLight = 200,
29
29
  Light = 300,
30
- Normal = 400,
30
+ Regular = 400,
31
31
  Medium = 500,
32
32
  SemiBold = 600,
33
33
  Bold = 700,
@@ -94,3 +94,9 @@ export declare enum PatternType {
94
94
  RepeatY = "repeat-y",
95
95
  NoRepeat = "no-repeat"
96
96
  }
97
+ export declare enum LinkType {
98
+ Width = "width",
99
+ Height = "height",
100
+ X = "x",
101
+ Y = "y"
102
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PatternType = exports.Centring = exports.SaveFormat = exports.Export = exports.LineJoin = exports.LineCap = exports.TextDirection = exports.TextBaseline = exports.TextAlign = exports.FontWeight = exports.GradientType = exports.LayerScaleType = exports.LayerType = void 0;
3
+ exports.LinkType = exports.PatternType = exports.Centring = exports.SaveFormat = 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";
@@ -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["Normal"] = 400] = "Normal";
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";
@@ -110,3 +110,10 @@ var PatternType;
110
110
  PatternType["RepeatY"] = "repeat-y";
111
111
  PatternType["NoRepeat"] = "no-repeat";
112
112
  })(PatternType || (exports.PatternType = PatternType = {}));
113
+ var LinkType;
114
+ (function (LinkType) {
115
+ LinkType["Width"] = "width";
116
+ LinkType["Height"] = "height";
117
+ LinkType["X"] = "x";
118
+ LinkType["Y"] = "y";
119
+ })(LinkType || (exports.LinkType = LinkType = {}));
@@ -1,8 +1,8 @@
1
- import { FontWeight } from "../enum";
1
+ import { AnyWeight } from "../";
2
2
 
3
3
  export interface IFont {
4
4
  family: string;
5
- weight: FontWeight;
5
+ weight: AnyWeight;
6
6
  path?: string;
7
7
  base64?: Buffer;
8
8
  }
@@ -1,7 +1,7 @@
1
- import { GradientType } from "../enum";
1
+ import { AnyGradientType } from "../";
2
2
 
3
3
  export interface IGradient {
4
- type: GradientType;
4
+ type: AnyGradientType;
5
5
  points: Array<GradientPoint>;
6
6
  stops: Array<GradientColorStop>;
7
7
  }
@@ -0,0 +1,7 @@
1
+ import { AnyLinkType, ScaleType } from "../types";
2
+
3
+ export interface ILink {
4
+ source: string;
5
+ type: AnyLinkType;
6
+ additionalSpacing: ScaleType;
7
+ }
@@ -1,7 +1,7 @@
1
1
  import { LazyCanvas } from '../../';
2
- import { PatternType } from '../enum';
2
+ import { AnyPatternType } from "../";
3
3
 
4
4
  export interface IPattern {
5
- type: PatternType;
5
+ type: AnyPatternType;
6
6
  src: string | LazyCanvas;
7
7
  }
@@ -1,16 +1,17 @@
1
- export * from "./types";
2
- export * from "./components/BaseLayer";
3
- export * from "./components/TextLayer";
4
- export * from "./components/ImageLayer";
5
- export * from "./components/MorphLayer";
6
- export * from "./components/BezierLayer";
7
- export * from "./components/QuadraticLayer";
8
- export * from "./components/LineLayer";
9
- export * from "./components/Group";
10
- export * from "./helpers/Font";
11
- export * from "./helpers/Gradient";
12
- export * from "./helpers/Pattern";
13
- export * from "./managers/LayersManager";
14
- export * from "./managers/RenderManager";
15
- export * from "./managers/FontsManager";
16
- export * from "./LazyCanvas";
1
+ export type * from "./types";
2
+ export type * from "./components/BaseLayer";
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";
@@ -5,13 +5,53 @@ 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 { Link } from "../structures/helpers/Link";
11
+ import {
12
+ FontWeight,
13
+ GradientType,
14
+ TextAlign,
15
+ TextBaseline,
16
+ TextDirection,
17
+ LineCap,
18
+ LineJoin,
19
+ Export,
20
+ Centring,
21
+ PatternType,
22
+ SaveFormat,
23
+ LinkType
24
+ } from "./enum";
9
25
 
10
- export type ScaleType = string | number | 'vw' | 'vh' | 'vmin' | 'vmax';
26
+ export type ScaleType = string | number | 'vw' | 'vh' | 'vmin' | 'vmax' | Link;
11
27
 
12
28
  export type ColorType = string | Gradient | Pattern;
13
29
 
14
- export type AnyLayer = MorphLayer | ImageLayer | TextLayer | BezierLayer | QuadraticLayer | Group;
30
+ export type AnyLayer = MorphLayer | ImageLayer | TextLayer | BezierLayer | QuadraticLayer | LineLayer | Group;
31
+
32
+ export type AnyWeight = FontWeight | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
33
+
34
+ export type AnyGradientType = GradientType | 'linear' | 'radial' | 'conic';
35
+
36
+ export type AnyTextAlign = TextAlign | 'left' | 'right' | 'center' | 'start' | 'end';
37
+
38
+ export type AnyTextBaseline = TextBaseline | 'top' | 'hanging' | 'middle' | 'alphabetic' | 'ideographic' | 'bottom';
39
+
40
+ export type AnyTextDirection = TextDirection | 'ltr' | 'rtl' | 'inherit';
41
+
42
+ export type AnyLineCap = LineCap | 'butt' | 'round' | 'square';
43
+
44
+ export type AnyLineJoin = LineJoin | 'bevel' | 'round' | 'miter';
45
+
46
+ export type AnyExport = Export | 'buffer' | 'svg' | 'ctx';
47
+
48
+ export type AnyCentring = Centring | 'start' | 'start-top' | 'start-bottom' | 'center' | 'center-top' | 'center-bottom' | 'end' | 'end-top' | 'end-bottom' | 'none';
49
+
50
+ export type AnyPatternType = PatternType | 'repeat' | 'repeat-x' | 'repeat-y' | 'no-repeat';
51
+
52
+ export type AnySaveFormat = SaveFormat | 'png' | 'jpeg' | 'jpg' | 'svg';
53
+
54
+ export type AnyLinkType = LinkType | 'width' | 'height' | 'x' | 'y';
15
55
 
16
56
  export type Point = {
17
57
  x: ScaleType;
@@ -5,3 +5,13 @@ export declare class LazyError extends Error {
5
5
  export declare class LazyLog {
6
6
  static log(type?: string, ...message: any): void;
7
7
  }
8
+ export declare const defaultArg: {
9
+ wh(w?: number, h?: number): {
10
+ width: number;
11
+ height: number;
12
+ };
13
+ vl(vertical?: boolean, layer?: boolean): {
14
+ vertical: boolean;
15
+ layer: boolean;
16
+ };
17
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LazyLog = exports.LazyError = void 0;
3
+ exports.defaultArg = exports.LazyLog = exports.LazyError = void 0;
4
4
  class LazyError extends Error {
5
5
  message;
6
6
  constructor(message) {
@@ -25,3 +25,11 @@ class LazyLog {
25
25
  }
26
26
  }
27
27
  exports.LazyLog = LazyLog;
28
+ exports.defaultArg = {
29
+ wh(w, h) {
30
+ return { width: w || 0, height: h || 0 };
31
+ },
32
+ vl(vertical, layer) {
33
+ return { vertical: vertical || false, layer: layer || false };
34
+ }
35
+ };