@leafer-draw/node 1.4.0 → 1.4.1
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/node.cjs +12 -10
- package/dist/node.cjs.map +1 -1
- package/dist/node.esm.js +14 -12
- package/dist/node.esm.js.map +1 -1
- package/dist/node.esm.min.js +1 -1
- package/dist/node.esm.min.js.map +1 -1
- package/dist/node.min.cjs +1 -1
- package/dist/node.min.cjs.map +1 -1
- package/package.json +8 -8
package/dist/node.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { LeaferCanvasBase, Platform, canvasPatch, Creator, LeaferImage, defineKey,
|
|
1
|
+
import { LeaferCanvasBase, Platform, canvasPatch, FileHelper, Creator, LeaferImage, defineKey, LeafList, DataHelper, RenderEvent, ChildEvent, WatchEvent, PropertyEvent, LeafHelper, BranchHelper, LeafBoundsHelper, Bounds, Debug, LeafLevelList, LayoutEvent, Run, ImageManager, ResizeEvent, BoundsHelper, MatrixHelper, MathHelper, AlignHelper, ImageEvent, AroundHelper, PointHelper, Direction4 } from '@leafer/core';
|
|
2
2
|
export * from '@leafer/core';
|
|
3
3
|
export { LeaferImage } from '@leafer/core';
|
|
4
4
|
import { writeFileSync } from 'fs';
|
|
5
|
-
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect, Bounds as Bounds$1,
|
|
5
|
+
import { PaintImage, ColorConvert, PaintGradient, Export, Group, TextConvert, Paint, Effect, TwoPointBoundsHelper, Bounds as Bounds$1, FileHelper as FileHelper$1, TaskProcessor, Platform as Platform$1, Matrix, MathHelper as MathHelper$1, Creator as Creator$1, LeaferCanvasBase as LeaferCanvasBase$1, Debug as Debug$1, Plugin, UI } from '@leafer-ui/draw';
|
|
6
6
|
export * from '@leafer-ui/draw';
|
|
7
7
|
|
|
8
8
|
/******************************************************************************
|
|
@@ -84,8 +84,8 @@ function useCanvas(canvasType, power) {
|
|
|
84
84
|
Platform.origin = {
|
|
85
85
|
createCanvas: (width, height, format) => new Canvas(width, height, format),
|
|
86
86
|
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
|
|
87
|
-
canvasToBolb: (canvas, type, quality) => __awaiter(this,
|
|
88
|
-
canvasSaveAs: (canvas, filename, quality) => __awaiter(this,
|
|
87
|
+
canvasToBolb: (canvas, type, quality) => __awaiter(this, void 0, void 0, function* () { return canvas.toBuffer(mineType(type), quality); }),
|
|
88
|
+
canvasSaveAs: (canvas, filename, quality) => __awaiter(this, void 0, void 0, function* () { return writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality)); }),
|
|
89
89
|
download(_url, _filename) { return undefined; },
|
|
90
90
|
loadImage(src) { return loadImage(Platform.image.getRealURL(src)); }
|
|
91
91
|
};
|
|
@@ -360,7 +360,7 @@ class Layouter {
|
|
|
360
360
|
}
|
|
361
361
|
partLayout() {
|
|
362
362
|
var _a;
|
|
363
|
-
if (!((_a = this.__updatedList) === null || _a ===
|
|
363
|
+
if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length))
|
|
364
364
|
return;
|
|
365
365
|
const t = Run.start('PartLayout');
|
|
366
366
|
const { target, __updatedList: updateList } = this;
|
|
@@ -1050,7 +1050,7 @@ function getPatternData(paint, box, image) {
|
|
|
1050
1050
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1051
1051
|
if (paint.mode === 'strench')
|
|
1052
1052
|
paint.mode = 'stretch';
|
|
1053
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
1053
|
+
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1054
1054
|
const sameBox = box.width === width && box.height === height;
|
|
1055
1055
|
const data = { mode };
|
|
1056
1056
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1113,6 +1113,8 @@ function getPatternData(paint, box, image) {
|
|
|
1113
1113
|
data.height = height;
|
|
1114
1114
|
if (opacity)
|
|
1115
1115
|
data.opacity = opacity;
|
|
1116
|
+
if (filters)
|
|
1117
|
+
data.filters = filters;
|
|
1116
1118
|
if (repeat)
|
|
1117
1119
|
data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
|
|
1118
1120
|
return data;
|
|
@@ -1215,7 +1217,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1215
1217
|
scaleX = abs$1(scaleX);
|
|
1216
1218
|
scaleY = abs$1(scaleY);
|
|
1217
1219
|
const { image, data } = paint;
|
|
1218
|
-
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy,
|
|
1220
|
+
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1219
1221
|
if (sx) {
|
|
1220
1222
|
imageMatrix = get$1();
|
|
1221
1223
|
copy$1(imageMatrix, transform);
|
|
@@ -1258,7 +1260,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1258
1260
|
}
|
|
1259
1261
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
1260
1262
|
}
|
|
1261
|
-
const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, opacity);
|
|
1263
|
+
const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, data.opacity, data.filters);
|
|
1262
1264
|
const pattern = image.getPattern(canvas, repeat || (Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
|
|
1263
1265
|
paint.style = pattern;
|
|
1264
1266
|
paint.patternId = id;
|
|
@@ -1302,7 +1304,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1302
1304
|
canvas.opacity *= data.opacity;
|
|
1303
1305
|
if (data.transform)
|
|
1304
1306
|
canvas.transform(data.transform);
|
|
1305
|
-
canvas.drawImage(paint.image.
|
|
1307
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1306
1308
|
canvas.restore();
|
|
1307
1309
|
return true;
|
|
1308
1310
|
}
|
|
@@ -1312,7 +1314,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1312
1314
|
}
|
|
1313
1315
|
else {
|
|
1314
1316
|
if (!paint.patternTask) {
|
|
1315
|
-
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this,
|
|
1317
|
+
paint.patternTask = ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
1316
1318
|
paint.patternTask = null;
|
|
1317
1319
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1318
1320
|
createPattern(ui, paint, pixelRatio);
|
|
@@ -2220,7 +2222,7 @@ const ExportModule = {
|
|
|
2220
2222
|
const { leafer } = leaf;
|
|
2221
2223
|
if (leafer) {
|
|
2222
2224
|
checkLazy(leaf);
|
|
2223
|
-
leafer.waitViewCompleted(() => __awaiter(this,
|
|
2225
|
+
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
2224
2226
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2225
2227
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
2226
2228
|
const { slice, trim, padding, onCanvas } = options;
|
|
@@ -2322,7 +2324,7 @@ function addTask(task) {
|
|
|
2322
2324
|
if (!tasker)
|
|
2323
2325
|
tasker = new TaskProcessor();
|
|
2324
2326
|
return new Promise((resolve) => {
|
|
2325
|
-
tasker.add(() => __awaiter(this,
|
|
2327
|
+
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
2326
2328
|
});
|
|
2327
2329
|
}
|
|
2328
2330
|
function checkLazy(leaf) {
|