kritzel-stencil 0.0.164 → 0.0.166

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.
Files changed (44) hide show
  1. package/dist/cjs/{default-line-tool.config-DJMYrkSu.js → default-line-tool.config-BNBO4I1t.js} +59 -36
  2. package/dist/cjs/default-line-tool.config-BNBO4I1t.js.map +1 -0
  3. package/dist/cjs/index.cjs.js +1 -1
  4. package/dist/cjs/kritzel-color_22.cjs.entry.js +17 -8
  5. package/dist/collection/classes/core/core.class.js +9 -0
  6. package/dist/collection/classes/core/core.class.js.map +1 -1
  7. package/dist/collection/classes/objects/line.class.js +4 -3
  8. package/dist/collection/classes/objects/line.class.js.map +1 -1
  9. package/dist/collection/classes/objects/selection-group.class.js +4 -1
  10. package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
  11. package/dist/collection/classes/tools/brush-tool.class.js +45 -30
  12. package/dist/collection/classes/tools/brush-tool.class.js.map +1 -1
  13. package/dist/collection/classes/tools/selection-tool.class.js +4 -0
  14. package/dist/collection/classes/tools/selection-tool.class.js.map +1 -1
  15. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js +7 -7
  16. package/dist/collection/components/core/kritzel-engine/kritzel-engine.js.map +1 -1
  17. package/dist/components/index.js +3 -3
  18. package/dist/components/kritzel-controls.js +1 -1
  19. package/dist/components/kritzel-editor.js +3 -3
  20. package/dist/components/kritzel-engine.js +1 -1
  21. package/dist/components/{p-Dz2XHHqa.js → p-Bwv1dxAB.js} +47 -32
  22. package/dist/components/{p-Dz2XHHqa.js.map → p-Bwv1dxAB.js.map} +1 -1
  23. package/dist/components/{p-DzUUppVL.js → p-CIXaR1a8.js} +31 -14
  24. package/dist/components/p-CIXaR1a8.js.map +1 -0
  25. package/dist/components/{p-tp96UZ0l.js → p-CRtmNOp1.js} +3 -3
  26. package/dist/components/{p-tp96UZ0l.js.map → p-CRtmNOp1.js.map} +1 -1
  27. package/dist/esm/{default-line-tool.config-C35P3XfD.js → default-line-tool.config-DJ488kil.js} +59 -36
  28. package/dist/{cjs/default-line-tool.config-DJMYrkSu.js.map → esm/default-line-tool.config-DJ488kil.js.map} +1 -1
  29. package/dist/esm/index.js +2 -2
  30. package/dist/esm/kritzel-color_22.entry.js +17 -8
  31. package/dist/stencil/index.esm.js +1 -1
  32. package/dist/stencil/{p-3e2b5c42.entry.js → p-3df115ed.entry.js} +3 -3
  33. package/dist/stencil/p-3df115ed.entry.js.map +1 -0
  34. package/dist/stencil/p-DJ488kil.js +2 -0
  35. package/dist/stencil/p-DJ488kil.js.map +1 -0
  36. package/dist/stencil/stencil.esm.js +1 -1
  37. package/dist/types/classes/objects/selection-group.class.d.ts +1 -0
  38. package/dist/types/classes/tools/brush-tool.class.d.ts +1 -0
  39. package/package.json +1 -1
  40. package/dist/components/p-DzUUppVL.js.map +0 -1
  41. package/dist/esm/default-line-tool.config-C35P3XfD.js.map +0 -1
  42. package/dist/stencil/p-3e2b5c42.entry.js.map +0 -1
  43. package/dist/stencil/p-C35P3XfD.js +0 -2
  44. package/dist/stencil/p-C35P3XfD.js.map +0 -1
@@ -14768,20 +14768,21 @@ class KritzelLine extends KritzelBaseObject {
14768
14768
  this._core.store.state.objects.update(this);
14769
14769
  }
14770
14770
  hitTest(x, y) {
14771
- const halfStroke = this.strokeWidth / this.scale / 2;
14771
+ const strokeWidth = Math.max(this.strokeWidth, 10);
14772
+ const halfStroke = strokeWidth / this.scale / 2;
14772
14773
  if (this._adjustedPoints === null) {
14773
14774
  this._adjustedPoints = this.computeAdjustedPoints();
14774
14775
  }
14775
14776
  // For curved lines, use distance to the Bezier curve
14776
14777
  if (this.controlX !== undefined && this.controlY !== undefined) {
14777
14778
  const distance = this.pointToBezierDistance(x, y);
14778
- return distance <= halfStroke + 2;
14779
+ return distance <= halfStroke;
14779
14780
  }
14780
14781
  // For straight lines, use distance to line segment
14781
14782
  const p1 = this._adjustedPoints[0];
14782
14783
  const p2 = this._adjustedPoints[1];
14783
14784
  const distance = this.pointToLineSegmentDistance(x, y, p1[0], p1[1], p2[0], p2[1]);
14784
- return distance <= halfStroke + 2; // Add a small tolerance for easier selection
14785
+ return distance <= halfStroke;
14785
14786
  }
14786
14787
  hitTestPolygon(polygon) {
14787
14788
  const halfStroke = this.strokeWidth / this.scale / 2;
@@ -15299,9 +15300,10 @@ class KritzelBrushTool extends KritzelBaseTool {
15299
15300
  color = '#000000';
15300
15301
  size = 6;
15301
15302
  palettes = {
15302
- pen: ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF', '#808080', '#C0C0C0', '#800000', '#008000', '#000080', '#808000', '#800080'],
15303
+ pen: ['#000000', '#FFFFFF', '#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#FF00FF', '#00FFFF', '#808080', '#C0C0C0', '#800000', '#008000', '#000080', '#800080'],
15303
15304
  highlighter: ['#ffff00', '#ffb347', '#b4ffb4'],
15304
15305
  };
15306
+ _currentPathId = null;
15305
15307
  constructor(core) {
15306
15308
  super(core);
15307
15309
  }
@@ -15323,6 +15325,7 @@ class KritzelBrushTool extends KritzelBaseTool {
15323
15325
  strokeWidth: this.size,
15324
15326
  });
15325
15327
  path.isCompleted = false;
15328
+ this._currentPathId = path.id;
15326
15329
  this._core.store.state.objects.insert(path);
15327
15330
  }
15328
15331
  }
@@ -15341,6 +15344,7 @@ class KritzelBrushTool extends KritzelBaseTool {
15341
15344
  strokeWidth: this.size,
15342
15345
  });
15343
15346
  path.isCompleted = false;
15347
+ this._currentPathId = path.id;
15344
15348
  this._core.store.state.objects.insert(path);
15345
15349
  }
15346
15350
  }
@@ -15350,8 +15354,9 @@ class KritzelBrushTool extends KritzelBaseTool {
15350
15354
  event.preventDefault();
15351
15355
  }
15352
15356
  if (event.pointerType === 'mouse') {
15353
- if (this._core.store.state.isDrawing) {
15354
- const currentPath = this._core.store.currentPath;
15357
+ if (this._core.store.state.isDrawing && this._currentPathId) {
15358
+ const matchingObjects = this._core.store.state.objects.filter(o => o.id === this._currentPathId);
15359
+ const currentPath = matchingObjects.length > 0 ? matchingObjects[0] : null;
15355
15360
  if (currentPath) {
15356
15361
  const x = event.clientX - this._core.store.offsetX;
15357
15362
  const y = event.clientY - this._core.store.offsetY;
@@ -15374,23 +15379,26 @@ class KritzelBrushTool extends KritzelBaseTool {
15374
15379
  if (event.pointerType === 'touch') {
15375
15380
  const activePointers = Array.from(this._core.store.state.pointers.values());
15376
15381
  if (activePointers.length === 1) {
15377
- const currentPath = this._core.store.currentPath;
15378
- if (currentPath) {
15379
- const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
15380
- const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
15381
- const updatedPath = KritzelPath.create(this._core, {
15382
- points: [...currentPath.points, [x, y]],
15383
- translateX: -this._core.store.state.translateX,
15384
- translateY: -this._core.store.state.translateY,
15385
- scale: this._core.store.state.scale,
15386
- fill: this.color,
15387
- strokeWidth: this.size,
15388
- });
15389
- updatedPath.id = currentPath.id;
15390
- updatedPath.workspaceId = currentPath.workspaceId;
15391
- updatedPath.zIndex = currentPath.zIndex;
15392
- updatedPath.isCompleted = false;
15393
- this._core.store.state.objects.update(updatedPath);
15382
+ if (this._currentPathId) {
15383
+ const matchingObjects = this._core.store.state.objects.filter(o => o.id === this._currentPathId);
15384
+ const currentPath = matchingObjects.length > 0 ? matchingObjects[0] : null;
15385
+ if (currentPath) {
15386
+ const x = Math.round(activePointers[0].clientX - this._core.store.offsetX);
15387
+ const y = Math.round(activePointers[0].clientY - this._core.store.offsetY);
15388
+ const updatedPath = KritzelPath.create(this._core, {
15389
+ points: [...currentPath.points, [x, y]],
15390
+ translateX: -this._core.store.state.translateX,
15391
+ translateY: -this._core.store.state.translateY,
15392
+ scale: this._core.store.state.scale,
15393
+ fill: this.color,
15394
+ strokeWidth: this.size,
15395
+ });
15396
+ updatedPath.id = currentPath.id;
15397
+ updatedPath.workspaceId = currentPath.workspaceId;
15398
+ updatedPath.zIndex = currentPath.zIndex;
15399
+ updatedPath.isCompleted = false;
15400
+ this._core.store.state.objects.update(updatedPath);
15401
+ }
15394
15402
  }
15395
15403
  }
15396
15404
  }
@@ -15402,22 +15410,30 @@ class KritzelBrushTool extends KritzelBaseTool {
15402
15410
  if (event.pointerType === 'mouse') {
15403
15411
  if (this._core.store.state.isDrawing) {
15404
15412
  this._core.store.state.isDrawing = false;
15405
- const currentPath = this._core.store.currentPath;
15406
- if (currentPath) {
15407
- currentPath.isCompleted = true;
15408
- this._core.store.state.objects.update(currentPath);
15409
- this._core.engine.emitObjectsChange();
15413
+ if (this._currentPathId) {
15414
+ const matchingObjects = this._core.store.state.objects.filter(o => o.id === this._currentPathId);
15415
+ const currentPath = matchingObjects.length > 0 ? matchingObjects[0] : null;
15416
+ if (currentPath) {
15417
+ currentPath.isCompleted = true;
15418
+ this._core.store.state.objects.update(currentPath);
15419
+ this._core.engine.emitObjectsChange();
15420
+ }
15421
+ this._currentPathId = null;
15410
15422
  }
15411
15423
  }
15412
15424
  }
15413
15425
  if (event.pointerType === 'touch') {
15414
15426
  if (this._core.store.state.isDrawing) {
15415
15427
  this._core.store.state.isDrawing = false;
15416
- const currentPath = this._core.store.currentPath;
15417
- if (currentPath) {
15418
- currentPath.isCompleted = true;
15419
- this._core.store.state.objects.update(currentPath);
15420
- this._core.engine.emitObjectsChange();
15428
+ if (this._currentPathId) {
15429
+ const matchingObjects = this._core.store.state.objects.filter(o => o.id === this._currentPathId);
15430
+ const currentPath = matchingObjects.length > 0 ? matchingObjects[0] : null;
15431
+ if (currentPath) {
15432
+ currentPath.isCompleted = true;
15433
+ this._core.store.state.objects.update(currentPath);
15434
+ this._core.engine.emitObjectsChange();
15435
+ }
15436
+ this._currentPathId = null;
15421
15437
  }
15422
15438
  }
15423
15439
  }
@@ -15490,7 +15506,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
15490
15506
  const deltaX = snapshot.translateX - this.translateX;
15491
15507
  const deltaY = snapshot.translateY - this.translateY;
15492
15508
  snapshot.translateX = x + deltaX;
15493
- snapshot.translateY = x + deltaY;
15509
+ snapshot.translateY = y + deltaY;
15494
15510
  });
15495
15511
  this.translateX = x;
15496
15512
  this.translateY = y;
@@ -15726,6 +15742,9 @@ class KritzelSelectionGroup extends KritzelBaseObject {
15726
15742
  const groupCenterY = this.translateY + this.totalHeight / this.scale / 2;
15727
15743
  return objCenterY - groupCenterY;
15728
15744
  }
15745
+ hitTest(x, y) {
15746
+ return this.objects.some(obj => obj.hitTest(x, y));
15747
+ }
15729
15748
  }
15730
15749
 
15731
15750
  class KritzelLineTool extends KritzelBaseTool {
@@ -17561,6 +17580,10 @@ class KritzelSelectionTool extends KritzelBaseTool {
17561
17580
  if (!object) {
17562
17581
  return null;
17563
17582
  }
17583
+ const { x, y } = this._core.getCanvasPoint(event);
17584
+ if (!object.hitTest(x, y)) {
17585
+ return null;
17586
+ }
17564
17587
  if (object instanceof KritzelSelectionGroup) {
17565
17588
  return object;
17566
17589
  }
@@ -33909,6 +33932,6 @@ exports.varStorage = varStorage;
33909
33932
  exports.writeVarString = writeVarString$2;
33910
33933
  exports.writeVarUint = writeVarUint$2;
33911
33934
  exports.writeVarUint8Array = writeVarUint8Array$2;
33912
- //# sourceMappingURL=default-line-tool.config-DJMYrkSu.js.map
33935
+ //# sourceMappingURL=default-line-tool.config-BNBO4I1t.js.map
33913
33936
 
33914
- //# sourceMappingURL=default-line-tool.config-DJMYrkSu.js.map
33937
+ //# sourceMappingURL=default-line-tool.config-BNBO4I1t.js.map