canvas-editor-engine 2.3.15 → 2.3.16
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/index.mjs +18 -34
- package/dist/services/draw.service.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
@@ -2181,7 +2181,7 @@ var DrawAccumulator = function() {
|
|
2181
2181
|
}
|
2182
2182
|
DrawAccumulator.prototype.add = function(layerId, drawType, options, initialSize) {
|
2183
2183
|
return __awaiter(this, void 0, void 0, (function() {
|
2184
|
-
var id, painter
|
2184
|
+
var id, painter;
|
2185
2185
|
return __generator(this, (function(_a) {
|
2186
2186
|
id = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
|
2187
2187
|
painter = {
|
@@ -2196,8 +2196,7 @@ var DrawAccumulator = function() {
|
|
2196
2196
|
update: this.update.bind(this)
|
2197
2197
|
});
|
2198
2198
|
this.drawLayersService.addToLayer(layerId, painter);
|
2199
|
-
|
2200
|
-
this.invokePainter(drawType, painter.drawService, inStore);
|
2199
|
+
this.invokePainter(drawType, painter.drawService);
|
2201
2200
|
return [ 2 ];
|
2202
2201
|
}));
|
2203
2202
|
}));
|
@@ -2247,6 +2246,7 @@ var DrawAccumulator = function() {
|
|
2247
2246
|
DrawAccumulator.prototype.clearCanvas = function() {
|
2248
2247
|
var ctx = this.appConfig.canvas.getContext("2d");
|
2249
2248
|
ctx.clearRect(0, 0, this.appConfig.CANVAS_SIZE.width, this.appConfig.CANVAS_SIZE.height);
|
2249
|
+
ctx.save();
|
2250
2250
|
};
|
2251
2251
|
DrawAccumulator.prototype.invokePaintersOnLayers = function() {
|
2252
2252
|
var _this = this;
|
@@ -2264,37 +2264,25 @@ var DrawAccumulator = function() {
|
|
2264
2264
|
}));
|
2265
2265
|
}));
|
2266
2266
|
};
|
2267
|
-
DrawAccumulator.prototype.invokePainter = function(
|
2268
|
-
return __awaiter(this,
|
2269
|
-
|
2270
|
-
|
2271
|
-
inStore = false;
|
2272
|
-
}
|
2273
|
-
return __generator(this, (function(_c) {
|
2274
|
-
switch (_c.label) {
|
2267
|
+
DrawAccumulator.prototype.invokePainter = function(drawType, painter) {
|
2268
|
+
return __awaiter(this, void 0, void 0, (function() {
|
2269
|
+
return __generator(this, (function(_a) {
|
2270
|
+
switch (_a.label) {
|
2275
2271
|
case 0:
|
2276
2272
|
if (!(drawType === "image")) return [ 3, 2 ];
|
2277
|
-
return [ 4, painter.drawImage(
|
2273
|
+
return [ 4, painter.drawImage() ];
|
2278
2274
|
|
2279
2275
|
case 1:
|
2280
|
-
_a
|
2281
|
-
isAddToStore = !!reduceData && !!message && inStore;
|
2282
|
-
if (isAddToStore) {
|
2283
|
-
this.appStoreRepository.store.imageState.reduce(reduceData, message);
|
2284
|
-
}
|
2276
|
+
_a.sent();
|
2285
2277
|
return [ 3, 4 ];
|
2286
2278
|
|
2287
2279
|
case 2:
|
2288
2280
|
if (!(drawType === "project")) return [ 3, 4 ];
|
2289
|
-
return [ 4, painter.drawProject(
|
2281
|
+
return [ 4, painter.drawProject() ];
|
2290
2282
|
|
2291
2283
|
case 3:
|
2292
|
-
|
2293
|
-
|
2294
|
-
if (isAddToStore) {
|
2295
|
-
this.appStoreRepository.store.imageState.reduce(reduceData, message);
|
2296
|
-
}
|
2297
|
-
_c.label = 4;
|
2284
|
+
_a.sent();
|
2285
|
+
_a.label = 4;
|
2298
2286
|
|
2299
2287
|
case 4:
|
2300
2288
|
return [ 2 ];
|
@@ -2312,8 +2300,10 @@ var DrawAccumulator = function() {
|
|
2312
2300
|
x = painter.options.image.drawImageArgs.position.x;
|
2313
2301
|
y = painter.options.image.drawImageArgs.position.y;
|
2314
2302
|
ctx.putImageData(imageData, x, y);
|
2303
|
+
ctx.save();
|
2315
2304
|
} else if (drawType === "project") {
|
2316
2305
|
ctx.putImageData(imageData, 0, 0);
|
2306
|
+
ctx.save();
|
2317
2307
|
}
|
2318
2308
|
return [ 2 ];
|
2319
2309
|
}));
|
@@ -2338,12 +2328,9 @@ var DrawService = function() {
|
|
2338
2328
|
this.options[drawType] = options;
|
2339
2329
|
};
|
2340
2330
|
DrawService.prototype.drawImage = function() {
|
2341
|
-
return __awaiter(this,
|
2331
|
+
return __awaiter(this, void 0, void 0, (function() {
|
2342
2332
|
var _a, src, drawImageArgs, ctx;
|
2343
2333
|
var _this = this;
|
2344
|
-
if (isReturnReduceData === void 0) {
|
2345
|
-
isReturnReduceData = false;
|
2346
|
-
}
|
2347
2334
|
return __generator(this, (function(_b) {
|
2348
2335
|
switch (_b.label) {
|
2349
2336
|
case 0:
|
@@ -2355,7 +2342,6 @@ var DrawService = function() {
|
|
2355
2342
|
reduceData: null,
|
2356
2343
|
message: null
|
2357
2344
|
};
|
2358
|
-
if (!isReturnReduceData) return responseData;
|
2359
2345
|
var zeroPosition = {
|
2360
2346
|
x: 0,
|
2361
2347
|
y: 0
|
@@ -2368,6 +2354,7 @@ var DrawService = function() {
|
|
2368
2354
|
size: _this.appConfig.CANVAS_SIZE
|
2369
2355
|
};
|
2370
2356
|
responseData.message = "Image loaded";
|
2357
|
+
_this.appStoreRepository.store.imageState.reduce(responseData.reduceData, responseData.message);
|
2371
2358
|
return responseData;
|
2372
2359
|
})) ];
|
2373
2360
|
|
@@ -2378,12 +2365,9 @@ var DrawService = function() {
|
|
2378
2365
|
}));
|
2379
2366
|
};
|
2380
2367
|
DrawService.prototype.drawProject = function() {
|
2381
|
-
return __awaiter(this,
|
2368
|
+
return __awaiter(this, void 0, void 0, (function() {
|
2382
2369
|
var project, ctx, imageData, position, size;
|
2383
2370
|
var _this = this;
|
2384
|
-
if (isReturnReduceData === void 0) {
|
2385
|
-
isReturnReduceData = false;
|
2386
|
-
}
|
2387
2371
|
return __generator(this, (function(_a) {
|
2388
2372
|
project = this.options.project;
|
2389
2373
|
ctx = this.tempCanvas.ctx;
|
@@ -2399,13 +2383,13 @@ var DrawService = function() {
|
|
2399
2383
|
reduceData: null,
|
2400
2384
|
message: null
|
2401
2385
|
};
|
2402
|
-
if (!isReturnReduceData) return responseData;
|
2403
2386
|
responseData.reduceData = {
|
2404
2387
|
tempImageData: imageData,
|
2405
2388
|
position,
|
2406
2389
|
size
|
2407
2390
|
};
|
2408
2391
|
responseData.message = "Project loaded";
|
2392
|
+
_this.appStoreRepository.store.imageState.reduce(responseData.reduceData, responseData.message);
|
2409
2393
|
return responseData;
|
2410
2394
|
})) ];
|
2411
2395
|
}));
|
@@ -41,11 +41,11 @@ export default class DrawService {
|
|
41
41
|
tempCanvas: TempCanvas;
|
42
42
|
constructor(appConfig: AppConfig, appStoreRepository: AppStoreRepository, eventService: EventService);
|
43
43
|
bindOptions<DrawType extends TDrawType>(drawType: DrawType, options: DrawService['options'][DrawType]): void;
|
44
|
-
drawImage(
|
44
|
+
drawImage(): Promise<{
|
45
45
|
reduceData: IImageStateReduce | null;
|
46
46
|
message: string | null;
|
47
47
|
}>;
|
48
|
-
drawProject(
|
48
|
+
drawProject(): Promise<{
|
49
49
|
reduceData: IImageStateReduce | null;
|
50
50
|
message: string | null;
|
51
51
|
}>;
|