@sequent-org/moodboard 1.2.115 → 1.2.116
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/package.json
CHANGED
|
@@ -322,6 +322,12 @@ export class DrawingTool extends BaseTool {
|
|
|
322
322
|
return { x: local.x, y: local.y };
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
_worldToGlobal(x, y) {
|
|
326
|
+
if (!this.world || typeof this.world.toGlobal !== 'function') return { x, y };
|
|
327
|
+
const global = this.world.toGlobal(new PIXI.Point(x, y));
|
|
328
|
+
return { x: global.x, y: global.y };
|
|
329
|
+
}
|
|
330
|
+
|
|
325
331
|
_getWorldLayer() {
|
|
326
332
|
if (!this.app || !this.app.stage) return null;
|
|
327
333
|
const world = this.app.stage.getChildByName && this.app.stage.getChildByName('worldLayer');
|
|
@@ -333,12 +339,14 @@ export class DrawingTool extends BaseTool {
|
|
|
333
339
|
const req = { objects: [] };
|
|
334
340
|
this.emit('get:all:objects', req);
|
|
335
341
|
const objects = req.objects || [];
|
|
342
|
+
const prevGlobal = this._worldToGlobal(prev.x, prev.y);
|
|
343
|
+
const currGlobal = this._worldToGlobal(p.x, p.y);
|
|
336
344
|
// Радиус воздействия ластика (связан с отображаемой толщиной)
|
|
337
345
|
const radius = 8;
|
|
338
|
-
const segMinX = Math.min(
|
|
339
|
-
const segMaxX = Math.max(
|
|
340
|
-
const segMinY = Math.min(
|
|
341
|
-
const segMaxY = Math.max(
|
|
346
|
+
const segMinX = Math.min(prevGlobal.x, currGlobal.x) - radius;
|
|
347
|
+
const segMaxX = Math.max(prevGlobal.x, currGlobal.x) + radius;
|
|
348
|
+
const segMinY = Math.min(prevGlobal.y, currGlobal.y) - radius;
|
|
349
|
+
const segMaxY = Math.max(prevGlobal.y, currGlobal.y) + radius;
|
|
342
350
|
|
|
343
351
|
for (const item of objects) {
|
|
344
352
|
const id = item.id;
|
|
@@ -368,8 +376,8 @@ export class DrawingTool extends BaseTool {
|
|
|
368
376
|
const scaleY = baseH ? (b.height / baseH) : 1;
|
|
369
377
|
const eraserThresh = Math.max(6, (props.strokeWidth || 2) / 2 + radius);
|
|
370
378
|
// трансформируем сегмент ластика в локальные координаты фигуры
|
|
371
|
-
const localPrev = pixi.toLocal(new PIXI.Point(
|
|
372
|
-
const localCurr = pixi.toLocal(new PIXI.Point(
|
|
379
|
+
const localPrev = pixi.toLocal(new PIXI.Point(prevGlobal.x, prevGlobal.y));
|
|
380
|
+
const localCurr = pixi.toLocal(new PIXI.Point(currGlobal.x, currGlobal.y));
|
|
373
381
|
// Проверяем пересечение с каждым отрезком рисунка
|
|
374
382
|
for (let i = 0; i < pts.length - 1 && !intersects; i++) {
|
|
375
383
|
const ax = pts[i].x * scaleX;
|