@nmmty/lazycanvas 0.6.0-dev.1a1f37 → 0.6.0-dev.1d5786
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/Utlis.d.ts +28 -0
- package/dist/helpers/Utlis.js +78 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -1
- package/dist/structures/components/BaseLayer.d.ts +3 -2
- package/dist/structures/components/BaseLayer.js +15 -10
- package/dist/structures/components/BezierLayer.d.ts +6 -0
- package/dist/structures/components/BezierLayer.js +23 -4
- package/dist/structures/components/ClearLayer.d.ts +1 -0
- package/dist/structures/components/ClearLayer.js +14 -8
- package/dist/structures/components/ImageLayer.d.ts +6 -0
- package/dist/structures/components/ImageLayer.js +21 -5
- package/dist/structures/components/LineLayer.d.ts +6 -0
- package/dist/structures/components/LineLayer.js +27 -6
- package/dist/structures/components/MorphLayer.d.ts +6 -6
- package/dist/structures/components/MorphLayer.js +26 -15
- package/dist/structures/components/Path2DLayer.d.ts +6 -6
- package/dist/structures/components/Path2DLayer.js +24 -10
- package/dist/structures/components/QuadraticLayer.d.ts +6 -0
- package/dist/structures/components/QuadraticLayer.js +23 -4
- package/dist/structures/components/TextLayer.d.ts +11 -11
- package/dist/structures/components/TextLayer.js +36 -32
- package/dist/structures/helpers/Gradient.d.ts +48 -11
- package/dist/structures/helpers/Gradient.js +133 -8
- package/dist/structures/helpers/index.d.ts +1 -0
- package/dist/structures/helpers/index.js +1 -0
- package/dist/structures/helpers/readers/JSONReader.js +3 -3
- package/dist/structures/helpers/readers/YAMLReader.d.ts +22 -0
- package/dist/structures/helpers/readers/YAMLReader.js +73 -0
- package/dist/utils/utils.d.ts +13 -3
- package/dist/utils/utils.js +10 -9
- package/package.json +4 -3
package/dist/utils/utils.js
CHANGED
|
@@ -13,7 +13,7 @@ exports.generateID = generateID;
|
|
|
13
13
|
let percentReg = /^(\d+)%$/;
|
|
14
14
|
let pxReg = /^(\d+)px$/;
|
|
15
15
|
let canvasReg = /^(vw|vh|vmin|vmax)$/;
|
|
16
|
-
let linkReg = /^(link-w|link-h|link-x|link-y)-([A-Za-z0-9_]+)-(\d+)$/;
|
|
16
|
+
let linkReg = /^(link-w|link-h|link-x|link-y)-([A-Za-z0-9_]+)-(\d+(.\d+)?)$/;
|
|
17
17
|
let hexReg = /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
18
18
|
let rgbReg = /^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/;
|
|
19
19
|
let rgbaReg = /^rgba\((\d+),\s*(\d+),\s*(\d+),\s*(0|0?\.\d+|1(\.0)?)\)$/;
|
|
@@ -122,7 +122,7 @@ function drawShadow(ctx, shadow) {
|
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
124
|
exports.drawShadow = drawShadow;
|
|
125
|
-
function opacity(ctx, opacity) {
|
|
125
|
+
function opacity(ctx, opacity = 1) {
|
|
126
126
|
if (opacity < 1) {
|
|
127
127
|
ctx.globalAlpha = opacity;
|
|
128
128
|
}
|
|
@@ -134,13 +134,13 @@ function filters(ctx, filters) {
|
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
136
|
exports.filters = filters;
|
|
137
|
-
function parseFillStyle(ctx, color) {
|
|
137
|
+
function parseFillStyle(ctx, color, opts) {
|
|
138
138
|
if (!ctx)
|
|
139
139
|
throw new LazyUtil_1.LazyError('The context is not defined');
|
|
140
140
|
if (!color)
|
|
141
141
|
throw new LazyUtil_1.LazyError('The color is not defined');
|
|
142
142
|
if (color instanceof helpers_1.Gradient || color instanceof helpers_1.Pattern) {
|
|
143
|
-
return color.draw(ctx);
|
|
143
|
+
return color.draw(ctx, opts);
|
|
144
144
|
}
|
|
145
145
|
return color;
|
|
146
146
|
}
|
|
@@ -232,6 +232,7 @@ function centring(centring, type, width, height, x, y) {
|
|
|
232
232
|
case types_1.LayerType.Morph:
|
|
233
233
|
case types_1.LayerType.Clear:
|
|
234
234
|
x -= width / 2;
|
|
235
|
+
y -= height;
|
|
235
236
|
break;
|
|
236
237
|
}
|
|
237
238
|
return { x, y };
|
|
@@ -258,9 +259,6 @@ function centring(centring, type, width, height, x, y) {
|
|
|
258
259
|
return { x, y };
|
|
259
260
|
case types_1.Centring.StartBottom:
|
|
260
261
|
case "start-bottom":
|
|
261
|
-
return { x, y };
|
|
262
|
-
case types_1.Centring.StartTop:
|
|
263
|
-
case "start-top":
|
|
264
262
|
switch (type) {
|
|
265
263
|
case types_1.LayerType.Image:
|
|
266
264
|
case types_1.LayerType.Morph:
|
|
@@ -269,6 +267,9 @@ function centring(centring, type, width, height, x, y) {
|
|
|
269
267
|
break;
|
|
270
268
|
}
|
|
271
269
|
return { x, y };
|
|
270
|
+
case types_1.Centring.StartTop:
|
|
271
|
+
case "start-top":
|
|
272
|
+
return { x, y };
|
|
272
273
|
case types_1.Centring.End:
|
|
273
274
|
case "end":
|
|
274
275
|
switch (type) {
|
|
@@ -287,6 +288,7 @@ function centring(centring, type, width, height, x, y) {
|
|
|
287
288
|
case types_1.LayerType.Morph:
|
|
288
289
|
case types_1.LayerType.Clear:
|
|
289
290
|
x -= width;
|
|
291
|
+
y -= height;
|
|
290
292
|
break;
|
|
291
293
|
}
|
|
292
294
|
return { x, y };
|
|
@@ -297,7 +299,6 @@ function centring(centring, type, width, height, x, y) {
|
|
|
297
299
|
case types_1.LayerType.Morph:
|
|
298
300
|
case types_1.LayerType.Clear:
|
|
299
301
|
x -= width;
|
|
300
|
-
y -= height;
|
|
301
302
|
break;
|
|
302
303
|
}
|
|
303
304
|
return { x, y };
|
|
@@ -375,7 +376,7 @@ function resizeLayers(layers, ratio) {
|
|
|
375
376
|
}
|
|
376
377
|
}
|
|
377
378
|
}
|
|
378
|
-
if ('stroke' in layer.props) {
|
|
379
|
+
if ('stroke' in layer.props && layer.props.stroke) {
|
|
379
380
|
layer.props.stroke.width = resize(layer.props.stroke.width, ratio);
|
|
380
381
|
}
|
|
381
382
|
if ('endPoint' in layer.props) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nmmty/lazycanvas",
|
|
3
|
-
"version": "0.6.0-dev.
|
|
3
|
+
"version": "0.6.0-dev.1d5786",
|
|
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",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"iotest": "tsc ./test/iotest.ts && node ./test/iotest.js",
|
|
14
14
|
"gradient": "tsc ./test/gradient.ts && node ./test/gradient.js",
|
|
15
15
|
"doc": "tsx docgen.ts",
|
|
16
|
-
"font": "
|
|
17
|
-
"build": "tsc"
|
|
16
|
+
"font": "tsx ./scripts/font-gen.ts",
|
|
17
|
+
"build": "tsc && tsx ./scripts/post-build.ts"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"@hitomihiumi/micro-docgen": "^0.3.0",
|
|
46
46
|
"@types/js-yaml": "^4.0.9",
|
|
47
47
|
"@types/node": "^22.10.2",
|
|
48
|
+
"@typescript-eslint/utils": "^8.39.1",
|
|
48
49
|
"ava": "^6.2.0",
|
|
49
50
|
"eslint": "^9.23.0",
|
|
50
51
|
"eslint-config-neon": "^0.2.7",
|