kritzel-stencil 0.0.159 → 0.0.160
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/cjs/{default-text-tool.config-BySzvIox.js → default-text-tool.config-D10FksvZ.js} +139 -50
- package/dist/cjs/default-text-tool.config-D10FksvZ.js.map +1 -0
- package/dist/cjs/index.cjs.js +1 -1
- package/dist/cjs/kritzel-color_22.cjs.entry.js +1 -1
- package/dist/collection/classes/handlers/resize.handler.js +46 -32
- package/dist/collection/classes/handlers/resize.handler.js.map +1 -1
- package/dist/collection/classes/objects/selection-group.class.js +91 -16
- package/dist/collection/classes/objects/selection-group.class.js.map +1 -1
- package/dist/components/index.js +2 -2
- package/dist/components/kritzel-editor.js +1 -1
- package/dist/components/kritzel-engine.js +1 -1
- package/dist/components/{p-BAplhrRJ.js → p-DTHqEUDc.js} +139 -50
- package/dist/components/p-DTHqEUDc.js.map +1 -0
- package/dist/esm/{default-text-tool.config-2YFQA3SF.js → default-text-tool.config-DzqpOikl.js} +139 -50
- package/dist/esm/default-text-tool.config-DzqpOikl.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/kritzel-color_22.entry.js +1 -1
- package/dist/stencil/index.esm.js +1 -1
- package/dist/stencil/{p-2e85a4af.entry.js → p-5475442e.entry.js} +3 -3
- package/dist/stencil/{p-2YFQA3SF.js → p-DzqpOikl.js} +2 -2
- package/dist/stencil/p-DzqpOikl.js.map +1 -0
- package/dist/stencil/stencil.esm.js +1 -1
- package/dist/types/classes/objects/selection-group.class.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/default-text-tool.config-BySzvIox.js.map +0 -1
- package/dist/components/p-BAplhrRJ.js.map +0 -1
- package/dist/esm/default-text-tool.config-2YFQA3SF.js.map +0 -1
- package/dist/stencil/p-2YFQA3SF.js.map +0 -1
- /package/dist/stencil/{p-2e85a4af.entry.js.map → p-5475442e.entry.js.map} +0 -0
package/dist/cjs/{default-text-tool.config-BySzvIox.js → default-text-tool.config-D10FksvZ.js}
RENAMED
|
@@ -15188,32 +15188,42 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
15188
15188
|
if (!this.hasResized) {
|
|
15189
15189
|
return;
|
|
15190
15190
|
}
|
|
15191
|
+
const rotation = selectionGroup.rotation;
|
|
15192
|
+
const sin = Math.sin(rotation);
|
|
15193
|
+
const cos = Math.cos(rotation);
|
|
15194
|
+
const activeScale = selectionGroup.scale || this._core.store.state.scale;
|
|
15195
|
+
// Calculate delta in local unrotated space
|
|
15196
|
+
// We rotate the screen delta by -rotation to align with the object's axes
|
|
15197
|
+
const localDx = dx * cos + dy * sin;
|
|
15198
|
+
const localDy = -dx * sin + dy * cos;
|
|
15199
|
+
// Calculate the center of the selection group before resize
|
|
15200
|
+
const initialCenterX = this.initialSize.x + this.initialSize.width / activeScale / 2;
|
|
15201
|
+
const initialCenterY = this.initialSize.y + this.initialSize.height / activeScale / 2;
|
|
15202
|
+
// The center moves by half of the screen delta (scaled)
|
|
15203
|
+
// This is true regardless of rotation because the resize happens symmetrically around the center
|
|
15204
|
+
// relative to the fixed point logic
|
|
15205
|
+
const newCenterX = initialCenterX + dx / activeScale / 2;
|
|
15206
|
+
const newCenterY = initialCenterY + dy / activeScale / 2;
|
|
15191
15207
|
switch (this._core.store.state.resizeHandleType) {
|
|
15192
15208
|
case KritzelHandleType.TopLeft:
|
|
15193
|
-
this.newSize.width = this.initialSize.width -
|
|
15194
|
-
this.newSize.height = this.initialSize.height -
|
|
15195
|
-
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
15196
|
-
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
15209
|
+
this.newSize.width = this.initialSize.width - localDx;
|
|
15210
|
+
this.newSize.height = this.initialSize.height - localDy;
|
|
15197
15211
|
break;
|
|
15198
15212
|
case KritzelHandleType.TopRight:
|
|
15199
|
-
this.newSize.width = this.initialSize.width +
|
|
15200
|
-
this.newSize.height = this.initialSize.height -
|
|
15201
|
-
this.newSize.x = this.initialSize.x;
|
|
15202
|
-
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
15213
|
+
this.newSize.width = this.initialSize.width + localDx;
|
|
15214
|
+
this.newSize.height = this.initialSize.height - localDy;
|
|
15203
15215
|
break;
|
|
15204
15216
|
case KritzelHandleType.BottomLeft:
|
|
15205
|
-
this.newSize.width = this.initialSize.width -
|
|
15206
|
-
this.newSize.height = this.initialSize.height +
|
|
15207
|
-
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
15208
|
-
this.newSize.y = this.initialSize.y;
|
|
15217
|
+
this.newSize.width = this.initialSize.width - localDx;
|
|
15218
|
+
this.newSize.height = this.initialSize.height + localDy;
|
|
15209
15219
|
break;
|
|
15210
15220
|
case KritzelHandleType.BottomRight:
|
|
15211
|
-
this.newSize.width = this.initialSize.width +
|
|
15212
|
-
this.newSize.height = this.initialSize.height +
|
|
15213
|
-
this.newSize.x = this.initialSize.x;
|
|
15214
|
-
this.newSize.y = this.initialSize.y;
|
|
15221
|
+
this.newSize.width = this.initialSize.width + localDx;
|
|
15222
|
+
this.newSize.height = this.initialSize.height + localDy;
|
|
15215
15223
|
break;
|
|
15216
15224
|
}
|
|
15225
|
+
this.newSize.x = newCenterX - this.newSize.width / activeScale / 2;
|
|
15226
|
+
this.newSize.y = newCenterY - this.newSize.height / activeScale / 2;
|
|
15217
15227
|
selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
15218
15228
|
}
|
|
15219
15229
|
}
|
|
@@ -15239,32 +15249,36 @@ class KritzelResizeHandler extends KritzelBaseHandler {
|
|
|
15239
15249
|
if (!this.hasResized) {
|
|
15240
15250
|
return;
|
|
15241
15251
|
}
|
|
15252
|
+
const rotation = selectionGroup.rotation;
|
|
15253
|
+
const sin = Math.sin(rotation);
|
|
15254
|
+
const cos = Math.cos(rotation);
|
|
15255
|
+
const activeScale = selectionGroup.scale || this._core.store.state.scale;
|
|
15256
|
+
const localDx = dx * cos + dy * sin;
|
|
15257
|
+
const localDy = -dx * sin + dy * cos;
|
|
15258
|
+
const initialCenterX = this.initialSize.x + this.initialSize.width / activeScale / 2;
|
|
15259
|
+
const initialCenterY = this.initialSize.y + this.initialSize.height / activeScale / 2;
|
|
15260
|
+
const newCenterX = initialCenterX + dx / activeScale / 2;
|
|
15261
|
+
const newCenterY = initialCenterY + dy / activeScale / 2;
|
|
15242
15262
|
switch (this._core.store.state.resizeHandleType) {
|
|
15243
15263
|
case KritzelHandleType.TopLeft:
|
|
15244
|
-
this.newSize.width = this.initialSize.width -
|
|
15245
|
-
this.newSize.height = this.initialSize.height -
|
|
15246
|
-
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
15247
|
-
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
15264
|
+
this.newSize.width = this.initialSize.width - localDx;
|
|
15265
|
+
this.newSize.height = this.initialSize.height - localDy;
|
|
15248
15266
|
break;
|
|
15249
15267
|
case KritzelHandleType.TopRight:
|
|
15250
|
-
this.newSize.width = this.initialSize.width +
|
|
15251
|
-
this.newSize.height = this.initialSize.height -
|
|
15252
|
-
this.newSize.x = this.initialSize.x;
|
|
15253
|
-
this.newSize.y = dy / this._core.store.state.scale + this.initialSize.y;
|
|
15268
|
+
this.newSize.width = this.initialSize.width + localDx;
|
|
15269
|
+
this.newSize.height = this.initialSize.height - localDy;
|
|
15254
15270
|
break;
|
|
15255
15271
|
case KritzelHandleType.BottomLeft:
|
|
15256
|
-
this.newSize.width = this.initialSize.width -
|
|
15257
|
-
this.newSize.height = this.initialSize.height +
|
|
15258
|
-
this.newSize.x = dx / this._core.store.state.scale + this.initialSize.x;
|
|
15259
|
-
this.newSize.y = this.initialSize.y;
|
|
15272
|
+
this.newSize.width = this.initialSize.width - localDx;
|
|
15273
|
+
this.newSize.height = this.initialSize.height + localDy;
|
|
15260
15274
|
break;
|
|
15261
15275
|
case KritzelHandleType.BottomRight:
|
|
15262
|
-
this.newSize.width = this.initialSize.width +
|
|
15263
|
-
this.newSize.height = this.initialSize.height +
|
|
15264
|
-
this.newSize.x = this.initialSize.x;
|
|
15265
|
-
this.newSize.y = this.initialSize.y;
|
|
15276
|
+
this.newSize.width = this.initialSize.width + localDx;
|
|
15277
|
+
this.newSize.height = this.initialSize.height + localDy;
|
|
15266
15278
|
break;
|
|
15267
15279
|
}
|
|
15280
|
+
this.newSize.x = newCenterX - this.newSize.width / activeScale / 2;
|
|
15281
|
+
this.newSize.y = newCenterY - this.newSize.height / activeScale / 2;
|
|
15268
15282
|
selectionGroup.resize(this.newSize.x, this.newSize.y, this.newSize.width, this.newSize.height);
|
|
15269
15283
|
}
|
|
15270
15284
|
}
|
|
@@ -15434,6 +15448,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
15434
15448
|
objectIds = [];
|
|
15435
15449
|
// Store snapshots of object state for transformations (rotation, resize)
|
|
15436
15450
|
unchangedObjectSnapshots = new Map();
|
|
15451
|
+
snapshotRotation = 0;
|
|
15437
15452
|
minX;
|
|
15438
15453
|
maxX;
|
|
15439
15454
|
minY;
|
|
@@ -15504,6 +15519,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
15504
15519
|
*/
|
|
15505
15520
|
captureUnchangedSnapshots() {
|
|
15506
15521
|
this.unchangedObjectSnapshots.clear();
|
|
15522
|
+
this.snapshotRotation = this.rotation;
|
|
15507
15523
|
this.objects.forEach(obj => {
|
|
15508
15524
|
this.unchangedObjectSnapshots.set(obj.id, {
|
|
15509
15525
|
id: obj.id,
|
|
@@ -15563,14 +15579,56 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
15563
15579
|
resize(x, y, width, height) {
|
|
15564
15580
|
const widthScaleFactor = width / this.width;
|
|
15565
15581
|
const heightScaleFactor = height / this.height;
|
|
15566
|
-
|
|
15567
|
-
const
|
|
15582
|
+
// Calculate old center
|
|
15583
|
+
const oldCenterX = this.translateX + this.totalWidth / 2 / this.scale;
|
|
15584
|
+
const oldCenterY = this.translateY + this.totalHeight / 2 / this.scale;
|
|
15585
|
+
// Calculate new center
|
|
15586
|
+
const newTotalWidth = width + this.padding * 2;
|
|
15587
|
+
const newTotalHeight = height + this.padding * 2;
|
|
15588
|
+
const newCenterX = x + newTotalWidth / 2 / this.scale;
|
|
15589
|
+
const newCenterY = y + newTotalHeight / 2 / this.scale;
|
|
15590
|
+
const rotation = this.rotation;
|
|
15591
|
+
const cos = Math.cos(-rotation);
|
|
15592
|
+
const sin = Math.sin(-rotation);
|
|
15593
|
+
const cosR = Math.cos(rotation);
|
|
15594
|
+
const sinR = Math.sin(rotation);
|
|
15568
15595
|
this._core.store.state.objects.transaction(() => {
|
|
15569
15596
|
this.objects.forEach(child => {
|
|
15570
|
-
|
|
15571
|
-
const
|
|
15572
|
-
const
|
|
15573
|
-
|
|
15597
|
+
// Calculate child center
|
|
15598
|
+
const childCenterX = child.translateX + child.totalWidth / 2 / child.scale;
|
|
15599
|
+
const childCenterY = child.translateY + child.totalHeight / 2 / child.scale;
|
|
15600
|
+
// Vector from old group center to child center
|
|
15601
|
+
const dx = childCenterX - oldCenterX;
|
|
15602
|
+
const dy = childCenterY - oldCenterY;
|
|
15603
|
+
// Rotate to local space (align with group axes)
|
|
15604
|
+
const localX = dx * cos - dy * sin;
|
|
15605
|
+
const localY = dx * sin + dy * cos;
|
|
15606
|
+
// Scale in local space
|
|
15607
|
+
const scaledLocalX = localX * widthScaleFactor;
|
|
15608
|
+
const scaledLocalY = localY * heightScaleFactor;
|
|
15609
|
+
// Rotate back to world space
|
|
15610
|
+
const rotatedX = scaledLocalX * cosR - scaledLocalY * sinR;
|
|
15611
|
+
const rotatedY = scaledLocalX * sinR + scaledLocalY * cosR;
|
|
15612
|
+
// New child center
|
|
15613
|
+
const newChildCenterX = newCenterX + rotatedX;
|
|
15614
|
+
const newChildCenterY = newCenterY + rotatedY;
|
|
15615
|
+
// New child top-left
|
|
15616
|
+
// Calculate relative rotation
|
|
15617
|
+
const relativeRotation = child.rotation - rotation;
|
|
15618
|
+
const cosRel = Math.cos(relativeRotation);
|
|
15619
|
+
const sinRel = Math.sin(relativeRotation);
|
|
15620
|
+
// Project the group's scale factors onto the child's local axes
|
|
15621
|
+
// We use absolute values because scaling is magnitude-based
|
|
15622
|
+
// If the child is aligned (0 deg), cos=1, sin=0 -> scales match
|
|
15623
|
+
// If the child is 90 deg, cos=0, sin=1 -> scales swap
|
|
15624
|
+
const newChildWidthScale = Math.sqrt(Math.pow(widthScaleFactor * cosRel, 2) + Math.pow(heightScaleFactor * sinRel, 2));
|
|
15625
|
+
const newChildHeightScale = Math.sqrt(Math.pow(widthScaleFactor * sinRel, 2) + Math.pow(heightScaleFactor * cosRel, 2));
|
|
15626
|
+
const updatedWidth = child.width * newChildWidthScale;
|
|
15627
|
+
const updatedHeight = child.height * newChildHeightScale;
|
|
15628
|
+
const updatedTotalWidth = updatedWidth + child.padding * 2;
|
|
15629
|
+
const updatedTotalHeight = updatedHeight + child.padding * 2;
|
|
15630
|
+
const updatedX = newChildCenterX - updatedTotalWidth / 2 / child.scale;
|
|
15631
|
+
const updatedY = newChildCenterY - updatedTotalHeight / 2 / child.scale;
|
|
15574
15632
|
child.resize(updatedX, updatedY, updatedWidth, updatedHeight);
|
|
15575
15633
|
});
|
|
15576
15634
|
// Refresh dimensions and update the SelectionGroup to propagate changes to other tabs
|
|
@@ -15583,7 +15641,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
15583
15641
|
this.rotation = value;
|
|
15584
15642
|
const centerX = this.translateX + this.totalWidth / 2 / this.scale;
|
|
15585
15643
|
const centerY = this.translateY + this.totalHeight / 2 / this.scale;
|
|
15586
|
-
const angle = value;
|
|
15644
|
+
const angle = value - this.snapshotRotation;
|
|
15587
15645
|
const cos = Math.cos(angle);
|
|
15588
15646
|
const sin = Math.sin(angle);
|
|
15589
15647
|
this._core.store.state.objects.transaction(() => {
|
|
@@ -15599,7 +15657,7 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
15599
15657
|
const rotatedY = sin * offsetX + cos * offsetY;
|
|
15600
15658
|
child.translateX = centerX + rotatedX - child.totalWidth / 2 / child.scale;
|
|
15601
15659
|
child.translateY = centerY + rotatedY - child.totalHeight / 2 / child.scale;
|
|
15602
|
-
child.rotate(this.objects.length === 1 ? value :
|
|
15660
|
+
child.rotate(this.objects.length === 1 ? value : unchangedSnapshot.rotation + angle);
|
|
15603
15661
|
});
|
|
15604
15662
|
});
|
|
15605
15663
|
}
|
|
@@ -15630,14 +15688,45 @@ class KritzelSelectionGroup extends KritzelBaseObject {
|
|
|
15630
15688
|
this.height = (this.maxY - this.minY - this.padding) * this.scale;
|
|
15631
15689
|
}
|
|
15632
15690
|
else {
|
|
15633
|
-
|
|
15634
|
-
|
|
15635
|
-
|
|
15636
|
-
|
|
15637
|
-
|
|
15638
|
-
|
|
15639
|
-
|
|
15640
|
-
this.
|
|
15691
|
+
const rotation = this.rotation;
|
|
15692
|
+
const cos = Math.cos(-rotation);
|
|
15693
|
+
const sin = Math.sin(-rotation);
|
|
15694
|
+
let minX = Infinity;
|
|
15695
|
+
let maxX = -Infinity;
|
|
15696
|
+
let minY = Infinity;
|
|
15697
|
+
let maxY = -Infinity;
|
|
15698
|
+
this.objects.forEach(obj => {
|
|
15699
|
+
const polygon = obj.rotatedPolygon;
|
|
15700
|
+
const corners = [polygon.topLeft, polygon.topRight, polygon.bottomRight, polygon.bottomLeft];
|
|
15701
|
+
corners.forEach(corner => {
|
|
15702
|
+
// Rotate corner into local space (aligned with group rotation)
|
|
15703
|
+
const rx = corner.x * cos - corner.y * sin;
|
|
15704
|
+
const ry = corner.x * sin + corner.y * cos;
|
|
15705
|
+
if (rx < minX)
|
|
15706
|
+
minX = rx;
|
|
15707
|
+
if (rx > maxX)
|
|
15708
|
+
maxX = rx;
|
|
15709
|
+
if (ry < minY)
|
|
15710
|
+
minY = ry;
|
|
15711
|
+
if (ry > maxY)
|
|
15712
|
+
maxY = ry;
|
|
15713
|
+
});
|
|
15714
|
+
});
|
|
15715
|
+
// Dimensions in world units (unrotated)
|
|
15716
|
+
const worldWidth = maxX - minX;
|
|
15717
|
+
const worldHeight = maxY - minY;
|
|
15718
|
+
this.width = (worldWidth - this.padding) * this.scale;
|
|
15719
|
+
this.height = (worldHeight - this.padding) * this.scale;
|
|
15720
|
+
// Center of the box in rotated space
|
|
15721
|
+
const cRx = (minX + maxX) / 2;
|
|
15722
|
+
const cRy = (minY + maxY) / 2;
|
|
15723
|
+
// Rotate center back to world space
|
|
15724
|
+
const cosR = Math.cos(rotation);
|
|
15725
|
+
const sinR = Math.sin(rotation);
|
|
15726
|
+
const cx = cRx * cosR - cRy * sinR;
|
|
15727
|
+
const cy = cRx * sinR + cRy * cosR;
|
|
15728
|
+
this.translateX = cx - (this.width / this.scale + 2 * this.padding) / 2;
|
|
15729
|
+
this.translateY = cy - (this.height / this.scale + 2 * this.padding) / 2;
|
|
15641
15730
|
}
|
|
15642
15731
|
this._core.store.state.objects.update(this);
|
|
15643
15732
|
}
|
|
@@ -31262,6 +31351,6 @@ exports.varStorage = varStorage;
|
|
|
31262
31351
|
exports.writeVarString = writeVarString$2;
|
|
31263
31352
|
exports.writeVarUint = writeVarUint$2;
|
|
31264
31353
|
exports.writeVarUint8Array = writeVarUint8Array$2;
|
|
31265
|
-
//# sourceMappingURL=default-text-tool.config-
|
|
31354
|
+
//# sourceMappingURL=default-text-tool.config-D10FksvZ.js.map
|
|
31266
31355
|
|
|
31267
|
-
//# sourceMappingURL=default-text-tool.config-
|
|
31356
|
+
//# sourceMappingURL=default-text-tool.config-D10FksvZ.js.map
|