@leafer-draw/node 1.4.0 → 1.4.2
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.cjs
CHANGED
|
@@ -83,8 +83,8 @@ function useCanvas(canvasType, power) {
|
|
|
83
83
|
core.Platform.origin = {
|
|
84
84
|
createCanvas: (width, height, format) => new Canvas(width, height, format),
|
|
85
85
|
canvasToDataURL: (canvas, type, quality) => canvas.toDataURL(mineType(type), quality),
|
|
86
|
-
canvasToBolb: (canvas, type, quality) => __awaiter(this,
|
|
87
|
-
canvasSaveAs: (canvas, filename, quality) => __awaiter(this,
|
|
86
|
+
canvasToBolb: (canvas, type, quality) => __awaiter(this, void 0, void 0, function* () { return canvas.toBuffer(mineType(type), quality); }),
|
|
87
|
+
canvasSaveAs: (canvas, filename, quality) => __awaiter(this, void 0, void 0, function* () { return fs.writeFileSync(filename, canvas.toBuffer(mineType(fileType(filename)), quality)); }),
|
|
88
88
|
download(_url, _filename) { return undefined; },
|
|
89
89
|
loadImage(src) { return loadImage(core.Platform.image.getRealURL(src)); }
|
|
90
90
|
};
|
|
@@ -359,7 +359,7 @@ class Layouter {
|
|
|
359
359
|
}
|
|
360
360
|
partLayout() {
|
|
361
361
|
var _a;
|
|
362
|
-
if (!((_a = this.__updatedList) === null || _a ===
|
|
362
|
+
if (!((_a = this.__updatedList) === null || _a === void 0 ? void 0 : _a.length))
|
|
363
363
|
return;
|
|
364
364
|
const t = core.Run.start('PartLayout');
|
|
365
365
|
const { target, __updatedList: updateList } = this;
|
|
@@ -1049,7 +1049,7 @@ function getPatternData(paint, box, image) {
|
|
|
1049
1049
|
box = tempBox.set(box).shrink(paint.padding);
|
|
1050
1050
|
if (paint.mode === 'strench')
|
|
1051
1051
|
paint.mode = 'stretch';
|
|
1052
|
-
const { opacity, mode, align, offset, scale, size, rotation, repeat } = paint;
|
|
1052
|
+
const { opacity, mode, align, offset, scale, size, rotation, repeat, filters } = paint;
|
|
1053
1053
|
const sameBox = box.width === width && box.height === height;
|
|
1054
1054
|
const data = { mode };
|
|
1055
1055
|
const swapSize = align !== 'center' && (rotation || 0) % 180 === 90;
|
|
@@ -1112,6 +1112,8 @@ function getPatternData(paint, box, image) {
|
|
|
1112
1112
|
data.height = height;
|
|
1113
1113
|
if (opacity)
|
|
1114
1114
|
data.opacity = opacity;
|
|
1115
|
+
if (filters)
|
|
1116
|
+
data.filters = filters;
|
|
1115
1117
|
if (repeat)
|
|
1116
1118
|
data.repeat = typeof repeat === 'string' ? (repeat === 'x' ? 'repeat-x' : 'repeat-y') : 'repeat';
|
|
1117
1119
|
return data;
|
|
@@ -1214,7 +1216,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1214
1216
|
scaleX = abs$1(scaleX);
|
|
1215
1217
|
scaleY = abs$1(scaleY);
|
|
1216
1218
|
const { image, data } = paint;
|
|
1217
|
-
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy,
|
|
1219
|
+
let imageScale, imageMatrix, { width, height, scaleX: sx, scaleY: sy, transform, repeat } = data;
|
|
1218
1220
|
if (sx) {
|
|
1219
1221
|
imageMatrix = get$1();
|
|
1220
1222
|
copy$1(imageMatrix, transform);
|
|
@@ -1257,7 +1259,7 @@ function createPattern(ui, paint, pixelRatio) {
|
|
|
1257
1259
|
}
|
|
1258
1260
|
scale(imageMatrix, 1 / scaleX, 1 / scaleY);
|
|
1259
1261
|
}
|
|
1260
|
-
const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, opacity);
|
|
1262
|
+
const canvas = image.getCanvas(ceil(width) || 1, ceil(height) || 1, data.opacity, data.filters);
|
|
1261
1263
|
const pattern = image.getPattern(canvas, repeat || (core.Platform.origin.noRepeat || 'no-repeat'), imageMatrix, paint);
|
|
1262
1264
|
paint.style = pattern;
|
|
1263
1265
|
paint.patternId = id;
|
|
@@ -1301,7 +1303,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1301
1303
|
canvas.opacity *= data.opacity;
|
|
1302
1304
|
if (data.transform)
|
|
1303
1305
|
canvas.transform(data.transform);
|
|
1304
|
-
canvas.drawImage(paint.image.
|
|
1306
|
+
canvas.drawImage(paint.image.getFull(data.filters), 0, 0, data.width, data.height);
|
|
1305
1307
|
canvas.restore();
|
|
1306
1308
|
return true;
|
|
1307
1309
|
}
|
|
@@ -1311,7 +1313,7 @@ function checkImage(ui, canvas, paint, allowPaint) {
|
|
|
1311
1313
|
}
|
|
1312
1314
|
else {
|
|
1313
1315
|
if (!paint.patternTask) {
|
|
1314
|
-
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this,
|
|
1316
|
+
paint.patternTask = core.ImageManager.patternTasker.add(() => __awaiter(this, void 0, void 0, function* () {
|
|
1315
1317
|
paint.patternTask = null;
|
|
1316
1318
|
if (canvas.bounds.hit(ui.__nowWorld))
|
|
1317
1319
|
createPattern(ui, paint, pixelRatio);
|
|
@@ -2219,7 +2221,7 @@ const ExportModule = {
|
|
|
2219
2221
|
const { leafer } = leaf;
|
|
2220
2222
|
if (leafer) {
|
|
2221
2223
|
checkLazy(leaf);
|
|
2222
|
-
leafer.waitViewCompleted(() => __awaiter(this,
|
|
2224
|
+
leafer.waitViewCompleted(() => __awaiter(this, void 0, void 0, function* () {
|
|
2223
2225
|
let renderBounds, trimBounds, scaleX = 1, scaleY = 1;
|
|
2224
2226
|
const { worldTransform, isLeafer, isFrame } = leaf;
|
|
2225
2227
|
const { slice, trim, padding, onCanvas } = options;
|
|
@@ -2321,7 +2323,7 @@ function addTask(task) {
|
|
|
2321
2323
|
if (!tasker)
|
|
2322
2324
|
tasker = new draw.TaskProcessor();
|
|
2323
2325
|
return new Promise((resolve) => {
|
|
2324
|
-
tasker.add(() => __awaiter(this,
|
|
2326
|
+
tasker.add(() => __awaiter(this, void 0, void 0, function* () { return yield task(resolve); }), { parallel: false });
|
|
2325
2327
|
});
|
|
2326
2328
|
}
|
|
2327
2329
|
function checkLazy(leaf) {
|