labellife-design-tool 2.5.2 → 2.5.3
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/canvas/workspace.js.map +1 -1
- package/dist/cjs/index.js +42 -8
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/store.js.map +1 -1
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/cjs/side-panel/side-panel.js.map +1 -1
- package/dist/cjs/toolbar/toolbar.js +42 -8
- package/dist/cjs/toolbar/toolbar.js.map +1 -1
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/index.js +42 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/store.js.map +1 -1
- package/dist/esm/side-panel/index.js.map +1 -1
- package/dist/esm/side-panel/side-panel.js.map +1 -1
- package/dist/esm/toolbar/toolbar.js +42 -8
- package/dist/esm/toolbar/toolbar.js.map +1 -1
- package/package.json +1 -1
package/dist/esm/index.js
CHANGED
|
@@ -651,6 +651,35 @@ function coverFitSize(boxWidth, boxHeight, naturalWidth, naturalHeight) {
|
|
|
651
651
|
};
|
|
652
652
|
}
|
|
653
653
|
|
|
654
|
+
// Minimum axis-aligned (pre-rotation) box size that, once rotated by rotationDeg around
|
|
655
|
+
// its own center, still fully covers a boxWidth x boxHeight area. Used so "Fit to page"
|
|
656
|
+
// can keep an image's existing rotation instead of resetting it — the unrotated image is
|
|
657
|
+
// sized against this larger box instead of the page itself.
|
|
658
|
+
function rotatedCoverBox(boxWidth, boxHeight, rotationDeg) {
|
|
659
|
+
var rad = rotationDeg * Math.PI / 180;
|
|
660
|
+
var cos = Math.abs(Math.cos(rad));
|
|
661
|
+
var sin = Math.abs(Math.sin(rad));
|
|
662
|
+
return {
|
|
663
|
+
width: boxWidth * cos + boxHeight * sin,
|
|
664
|
+
height: boxWidth * sin + boxHeight * cos
|
|
665
|
+
};
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// Top-left (x, y) position such that a width x height rect, rotated by rotationDeg using
|
|
669
|
+
// Konva's convention (rotation pivots around (x, y), i.e. the rect's own pre-rotation
|
|
670
|
+
// top-left corner, not its center), ends up centered within a boxWidth x boxHeight area.
|
|
671
|
+
function centerRotatedPosition(boxWidth, boxHeight, width, height, rotationDeg) {
|
|
672
|
+
var rad = rotationDeg * Math.PI / 180;
|
|
673
|
+
var cos = Math.cos(rad);
|
|
674
|
+
var sin = Math.sin(rad);
|
|
675
|
+
var halfWidth = width / 2;
|
|
676
|
+
var halfHeight = height / 2;
|
|
677
|
+
return {
|
|
678
|
+
x: boxWidth / 2 - (halfWidth * cos - halfHeight * sin),
|
|
679
|
+
y: boxHeight / 2 - (halfWidth * sin + halfHeight * cos)
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
|
|
654
683
|
// Cover-fit crop fractions (centered) for a box of given size over an image of natural size.
|
|
655
684
|
// Mirrors the existing auto-crop calculation in canvas/image-element.js.
|
|
656
685
|
function coverFitCrop(boxWidth, boxHeight, naturalWidth, naturalHeight) {
|
|
@@ -9389,27 +9418,32 @@ var ImageToolbar = observer(function (_ref5) {
|
|
|
9389
9418
|
// smallest size that fully covers the page, centered. No crop is applied — if the
|
|
9390
9419
|
// aspect ratio doesn't match the page, the image simply overflows the page bounds
|
|
9391
9420
|
// on two sides (same as manually resizing it to cover), rather than permanently
|
|
9392
|
-
// cropping away image data.
|
|
9421
|
+
// cropping away image data. Existing rotation is kept as-is (not reset) — the fit is
|
|
9422
|
+
// computed against the larger box a rotated rect needs to still cover the (unrotated)
|
|
9423
|
+
// page, so a rotated image stays rotated and centered instead of flying off-canvas.
|
|
9424
|
+
var rotation = element.rotation || 0;
|
|
9393
9425
|
var updates = {
|
|
9394
9426
|
cropX: 0,
|
|
9395
9427
|
cropY: 0,
|
|
9396
9428
|
cropWidth: 1,
|
|
9397
9429
|
cropHeight: 1
|
|
9398
9430
|
};
|
|
9431
|
+
var required = rotatedCoverBox(store.width, store.height, rotation);
|
|
9399
9432
|
if (element._naturalWidth && element._naturalHeight) {
|
|
9400
|
-
var _coverFitSize = coverFitSize(
|
|
9433
|
+
var _coverFitSize = coverFitSize(required.width, required.height, element._naturalWidth, element._naturalHeight),
|
|
9401
9434
|
width = _coverFitSize.width,
|
|
9402
9435
|
height = _coverFitSize.height;
|
|
9403
9436
|
updates.width = width;
|
|
9404
9437
|
updates.height = height;
|
|
9405
|
-
updates.x = (store.width - width) / 2;
|
|
9406
|
-
updates.y = (store.height - height) / 2;
|
|
9407
9438
|
} else {
|
|
9408
|
-
updates.
|
|
9409
|
-
updates.
|
|
9410
|
-
updates.width = store.width;
|
|
9411
|
-
updates.height = store.height;
|
|
9439
|
+
updates.width = required.width;
|
|
9440
|
+
updates.height = required.height;
|
|
9412
9441
|
}
|
|
9442
|
+
var _centerRotatedPositio = centerRotatedPosition(store.width, store.height, updates.width, updates.height, rotation),
|
|
9443
|
+
x = _centerRotatedPositio.x,
|
|
9444
|
+
y = _centerRotatedPositio.y;
|
|
9445
|
+
updates.x = x;
|
|
9446
|
+
updates.y = y;
|
|
9413
9447
|
element.set(updates);
|
|
9414
9448
|
store.history.addUndoState();
|
|
9415
9449
|
};
|