microboard-temp 0.6.0 → 0.6.2
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/browser.js +308 -391
- package/dist/cjs/index.js +308 -391
- package/dist/cjs/node.js +308 -391
- package/dist/esm/browser.js +308 -391
- package/dist/esm/index.js +308 -391
- package/dist/esm/node.js +308 -391
- package/dist/types/Items/BaseItem/BaseItem.d.ts +1 -0
- package/dist/types/Items/Transformation/Transformation.d.ts +42 -31
- package/dist/types/Items/Transformation/TransformationOperations.d.ts +4 -0
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -7367,13 +7367,6 @@ class TransformationCommand {
|
|
|
7367
7367
|
};
|
|
7368
7368
|
});
|
|
7369
7369
|
}
|
|
7370
|
-
case "rotateTo":
|
|
7371
|
-
return mapItemsByOperation(this.transformation, (transformation) => {
|
|
7372
|
-
return {
|
|
7373
|
-
...this.operation,
|
|
7374
|
-
degree: transformation.getRotation()
|
|
7375
|
-
};
|
|
7376
|
-
});
|
|
7377
7370
|
case "scaleByTranslateBy": {
|
|
7378
7371
|
const op2 = this.operation;
|
|
7379
7372
|
const scaleTransformation = mapItemsByOperation(this.transformation, () => {
|
|
@@ -7395,6 +7388,13 @@ class TransformationCommand {
|
|
|
7395
7388
|
});
|
|
7396
7389
|
return scaleTransformation;
|
|
7397
7390
|
}
|
|
7391
|
+
case "rotateTo":
|
|
7392
|
+
return mapItemsByOperation(this.transformation, (transformation) => {
|
|
7393
|
+
return {
|
|
7394
|
+
...this.operation,
|
|
7395
|
+
degree: transformation.getRotation()
|
|
7396
|
+
};
|
|
7397
|
+
});
|
|
7398
7398
|
case "rotateBy": {
|
|
7399
7399
|
const op2 = this.operation;
|
|
7400
7400
|
return mapItemsByOperation(this.transformation, () => {
|
|
@@ -7484,7 +7484,7 @@ class Transformation {
|
|
|
7484
7484
|
id;
|
|
7485
7485
|
events;
|
|
7486
7486
|
subject = new SubjectOperation;
|
|
7487
|
-
|
|
7487
|
+
_matrix = new Matrix2;
|
|
7488
7488
|
previous = new Matrix2;
|
|
7489
7489
|
rotate = defaultData.rotate;
|
|
7490
7490
|
isLocked = false;
|
|
@@ -7492,29 +7492,73 @@ class Transformation {
|
|
|
7492
7492
|
this.id = id;
|
|
7493
7493
|
this.events = events;
|
|
7494
7494
|
}
|
|
7495
|
+
getMatrixData() {
|
|
7496
|
+
const { translateX, translateY, scaleX, scaleY, shearX, shearY } = this._matrix;
|
|
7497
|
+
return { translateX, translateY, scaleX, scaleY, shearX, shearY };
|
|
7498
|
+
}
|
|
7499
|
+
toMatrix() {
|
|
7500
|
+
return this._matrix.copy();
|
|
7501
|
+
}
|
|
7502
|
+
applyToContext(ctx) {
|
|
7503
|
+
this._matrix.applyToContext(ctx);
|
|
7504
|
+
}
|
|
7505
|
+
getTranslation() {
|
|
7506
|
+
return { x: this._matrix.translateX, y: this._matrix.translateY };
|
|
7507
|
+
}
|
|
7508
|
+
getScale() {
|
|
7509
|
+
return { x: this._matrix.scaleX, y: this._matrix.scaleY };
|
|
7510
|
+
}
|
|
7511
|
+
getRotation() {
|
|
7512
|
+
return this.rotate;
|
|
7513
|
+
}
|
|
7514
|
+
setLocal(xOrData, y, scaleX, scaleY) {
|
|
7515
|
+
this.previous = this._matrix.copy();
|
|
7516
|
+
if (typeof xOrData === "object") {
|
|
7517
|
+
if (xOrData.translateX !== undefined)
|
|
7518
|
+
this._matrix.translateX = xOrData.translateX;
|
|
7519
|
+
if (xOrData.translateY !== undefined)
|
|
7520
|
+
this._matrix.translateY = xOrData.translateY;
|
|
7521
|
+
if (xOrData.scaleX !== undefined)
|
|
7522
|
+
this._matrix.scaleX = xOrData.scaleX;
|
|
7523
|
+
if (xOrData.scaleY !== undefined)
|
|
7524
|
+
this._matrix.scaleY = xOrData.scaleY;
|
|
7525
|
+
} else {
|
|
7526
|
+
this._matrix.translateX = xOrData;
|
|
7527
|
+
this._matrix.translateY = y;
|
|
7528
|
+
if (scaleX !== undefined)
|
|
7529
|
+
this._matrix.scaleX = scaleX;
|
|
7530
|
+
if (scaleY !== undefined)
|
|
7531
|
+
this._matrix.scaleY = scaleY;
|
|
7532
|
+
}
|
|
7533
|
+
this.subject.publish(this, {
|
|
7534
|
+
class: "Transformation",
|
|
7535
|
+
method: "applyMatrix",
|
|
7536
|
+
items: [{ id: this.id, matrix: this.getMatrixData() }]
|
|
7537
|
+
});
|
|
7538
|
+
}
|
|
7495
7539
|
serialize() {
|
|
7496
7540
|
return {
|
|
7497
|
-
translateX: this.
|
|
7498
|
-
translateY: this.
|
|
7499
|
-
scaleX: this.
|
|
7500
|
-
scaleY: this.
|
|
7541
|
+
translateX: this._matrix.translateX,
|
|
7542
|
+
translateY: this._matrix.translateY,
|
|
7543
|
+
scaleX: this._matrix.scaleX,
|
|
7544
|
+
scaleY: this._matrix.scaleY,
|
|
7501
7545
|
rotate: this.rotate,
|
|
7502
7546
|
isLocked: this.isLocked
|
|
7503
7547
|
};
|
|
7504
7548
|
}
|
|
7505
7549
|
deserialize(data) {
|
|
7506
|
-
this.previous = this.
|
|
7550
|
+
this.previous = this._matrix.copy();
|
|
7507
7551
|
if (data.translateX) {
|
|
7508
|
-
this.
|
|
7552
|
+
this._matrix.translateX = data.translateX;
|
|
7509
7553
|
}
|
|
7510
7554
|
if (data.translateY) {
|
|
7511
|
-
this.
|
|
7555
|
+
this._matrix.translateY = data.translateY;
|
|
7512
7556
|
}
|
|
7513
7557
|
if (data.scaleX) {
|
|
7514
|
-
this.
|
|
7558
|
+
this._matrix.scaleX = data.scaleX;
|
|
7515
7559
|
}
|
|
7516
7560
|
if (data.scaleY) {
|
|
7517
|
-
this.
|
|
7561
|
+
this._matrix.scaleY = data.scaleY;
|
|
7518
7562
|
}
|
|
7519
7563
|
if (data.isLocked) {
|
|
7520
7564
|
this.isLocked = data.isLocked;
|
|
@@ -7531,7 +7575,7 @@ class Transformation {
|
|
|
7531
7575
|
return this;
|
|
7532
7576
|
}
|
|
7533
7577
|
copy(id) {
|
|
7534
|
-
const { translateX, translateY, scaleX, scaleY } = this.
|
|
7578
|
+
const { translateX, translateY, scaleX, scaleY } = this._matrix;
|
|
7535
7579
|
const { rotate } = this;
|
|
7536
7580
|
return new Transformation(id || "", this.events).deserialize({
|
|
7537
7581
|
translateX,
|
|
@@ -7542,6 +7586,17 @@ class Transformation {
|
|
|
7542
7586
|
isLocked: false
|
|
7543
7587
|
});
|
|
7544
7588
|
}
|
|
7589
|
+
getInverse() {
|
|
7590
|
+
const copy2 = this.copy();
|
|
7591
|
+
copy2._matrix.invert();
|
|
7592
|
+
return copy2;
|
|
7593
|
+
}
|
|
7594
|
+
getId() {
|
|
7595
|
+
return this.id;
|
|
7596
|
+
}
|
|
7597
|
+
setId(id) {
|
|
7598
|
+
this.id = id;
|
|
7599
|
+
}
|
|
7545
7600
|
emit(operation) {
|
|
7546
7601
|
if (this.events) {
|
|
7547
7602
|
const command = new TransformationCommand([this], operation);
|
|
@@ -7551,150 +7606,6 @@ class Transformation {
|
|
|
7551
7606
|
this.apply(operation);
|
|
7552
7607
|
}
|
|
7553
7608
|
}
|
|
7554
|
-
setId(id) {
|
|
7555
|
-
this.id = id;
|
|
7556
|
-
}
|
|
7557
|
-
apply(op) {
|
|
7558
|
-
this.previous = this.matrix.copy();
|
|
7559
|
-
switch (op.method) {
|
|
7560
|
-
case "applyMatrix": {
|
|
7561
|
-
const itemOp = op.items.find((i) => i.id === this.id);
|
|
7562
|
-
if (itemOp) {
|
|
7563
|
-
this.matrix.scale(itemOp.matrix.scaleX, itemOp.matrix.scaleY);
|
|
7564
|
-
this.matrix.translate(itemOp.matrix.translateX, itemOp.matrix.translateY);
|
|
7565
|
-
}
|
|
7566
|
-
break;
|
|
7567
|
-
}
|
|
7568
|
-
case "translateTo":
|
|
7569
|
-
this.applyTranslateTo(op.x, op.y);
|
|
7570
|
-
break;
|
|
7571
|
-
case "translateBy":
|
|
7572
|
-
this.applyTranslateBy(op.x, op.y);
|
|
7573
|
-
break;
|
|
7574
|
-
case "scaleTo":
|
|
7575
|
-
this.applyScaleTo(op.x, op.y);
|
|
7576
|
-
break;
|
|
7577
|
-
case "scaleBy":
|
|
7578
|
-
this.applyScaleBy(op.x, op.y);
|
|
7579
|
-
break;
|
|
7580
|
-
case "scaleToRelativeTo":
|
|
7581
|
-
this.applyScaleToRelativeTo(op.x, op.y, op.point);
|
|
7582
|
-
break;
|
|
7583
|
-
case "scaleByRelativeTo":
|
|
7584
|
-
this.applyScaleByRelativeTo(op.x, op.y, op.point);
|
|
7585
|
-
break;
|
|
7586
|
-
case "rotateTo":
|
|
7587
|
-
this.applyRotateTo(op.degree);
|
|
7588
|
-
break;
|
|
7589
|
-
case "rotateBy":
|
|
7590
|
-
this.applyRotateBy(op.degree);
|
|
7591
|
-
break;
|
|
7592
|
-
case "scaleByTranslateBy":
|
|
7593
|
-
this.applyScaleByTranslateBy(op.scale, op.translate);
|
|
7594
|
-
break;
|
|
7595
|
-
case "transformMany":
|
|
7596
|
-
this.applyTransformMany(op.items[this.id]);
|
|
7597
|
-
break;
|
|
7598
|
-
case "locked":
|
|
7599
|
-
this.applyLocked(op.locked);
|
|
7600
|
-
break;
|
|
7601
|
-
case "unlocked":
|
|
7602
|
-
this.applyUnlocked(op.locked);
|
|
7603
|
-
break;
|
|
7604
|
-
default:
|
|
7605
|
-
return;
|
|
7606
|
-
}
|
|
7607
|
-
this.subject.publish(this, op);
|
|
7608
|
-
}
|
|
7609
|
-
applyTranslateTo(x, y) {
|
|
7610
|
-
this.matrix.translateX = x;
|
|
7611
|
-
this.matrix.translateY = y;
|
|
7612
|
-
}
|
|
7613
|
-
applyTranslateBy(x, y) {
|
|
7614
|
-
this.matrix.translate(x, y);
|
|
7615
|
-
}
|
|
7616
|
-
applyScaleTo(x, y) {
|
|
7617
|
-
this.matrix.scaleX = x;
|
|
7618
|
-
this.matrix.scaleY = y;
|
|
7619
|
-
}
|
|
7620
|
-
applyScaleBy(x, y) {
|
|
7621
|
-
this.matrix.scale(x, y);
|
|
7622
|
-
}
|
|
7623
|
-
applyScaleByTranslateBy(scale, translate) {
|
|
7624
|
-
this.matrix.scale(scale.x, scale.y);
|
|
7625
|
-
this.matrix.translate(translate.x, translate.y);
|
|
7626
|
-
}
|
|
7627
|
-
applyTransformMany(op) {
|
|
7628
|
-
if (op.method === "applyMatrix") {
|
|
7629
|
-
this.matrix.scale(op.matrix.scaleX, op.matrix.scaleY);
|
|
7630
|
-
this.matrix.translate(op.matrix.translateX, op.matrix.translateY);
|
|
7631
|
-
} else if (op.method === "scaleByTranslateBy") {
|
|
7632
|
-
this.applyScaleByTranslateBy(op.scale, op.translate);
|
|
7633
|
-
} else if (op.method === "scaleBy") {
|
|
7634
|
-
this.applyScaleBy(op.x, op.y);
|
|
7635
|
-
} else if (op.method === "translateBy") {
|
|
7636
|
-
this.applyTranslateBy(op.x, op.y);
|
|
7637
|
-
} else if (op.method === "translateTo") {
|
|
7638
|
-
this.applyTranslateTo(op.x, op.y);
|
|
7639
|
-
}
|
|
7640
|
-
}
|
|
7641
|
-
applyScaleByRelativeTo(x, y, point) {
|
|
7642
|
-
const scaleX = this.matrix.scaleX * x;
|
|
7643
|
-
const scaleY = this.matrix.scaleY * y;
|
|
7644
|
-
this.matrix.translateX = -point.x * scaleX + point.x;
|
|
7645
|
-
this.matrix.translateY = -point.y * scaleY + point.y;
|
|
7646
|
-
this.matrix.scaleX = scaleX;
|
|
7647
|
-
this.matrix.scaleY = scaleY;
|
|
7648
|
-
}
|
|
7649
|
-
applyScaleToRelativeTo(x, y, point) {
|
|
7650
|
-
this.applyTranslateBy(-point.x, -point.y);
|
|
7651
|
-
this.applyScaleTo(x, y);
|
|
7652
|
-
this.applyTranslateBy(point.x, point.y);
|
|
7653
|
-
}
|
|
7654
|
-
applyRotateTo(degree) {
|
|
7655
|
-
if (degree > 0) {
|
|
7656
|
-
while (degree > 360) {
|
|
7657
|
-
degree -= 360;
|
|
7658
|
-
}
|
|
7659
|
-
if (degree === 360) {
|
|
7660
|
-
degree = 0;
|
|
7661
|
-
}
|
|
7662
|
-
} else {
|
|
7663
|
-
while (degree < -360) {
|
|
7664
|
-
degree += 360;
|
|
7665
|
-
}
|
|
7666
|
-
if (degree === -360) {
|
|
7667
|
-
degree = 0;
|
|
7668
|
-
}
|
|
7669
|
-
}
|
|
7670
|
-
this.rotate = degree;
|
|
7671
|
-
}
|
|
7672
|
-
applyRotateBy(degree) {
|
|
7673
|
-
this.applyRotateTo(this.rotate + degree);
|
|
7674
|
-
}
|
|
7675
|
-
applyLocked(locked) {
|
|
7676
|
-
this.isLocked = locked;
|
|
7677
|
-
}
|
|
7678
|
-
applyUnlocked(locked) {
|
|
7679
|
-
this.isLocked = locked;
|
|
7680
|
-
}
|
|
7681
|
-
getTranslation() {
|
|
7682
|
-
return { x: this.matrix.translateX, y: this.matrix.translateY };
|
|
7683
|
-
}
|
|
7684
|
-
getScale() {
|
|
7685
|
-
return { x: this.matrix.scaleX, y: this.matrix.scaleY };
|
|
7686
|
-
}
|
|
7687
|
-
getRotation() {
|
|
7688
|
-
return this.rotate;
|
|
7689
|
-
}
|
|
7690
|
-
getInverse() {
|
|
7691
|
-
const copy2 = this.copy();
|
|
7692
|
-
copy2.matrix.invert();
|
|
7693
|
-
return copy2;
|
|
7694
|
-
}
|
|
7695
|
-
getId() {
|
|
7696
|
-
return this.id;
|
|
7697
|
-
}
|
|
7698
7609
|
emitMatrix(matrix, timeStamp) {
|
|
7699
7610
|
this.emit({
|
|
7700
7611
|
class: "Transformation",
|
|
@@ -7706,8 +7617,8 @@ class Transformation {
|
|
|
7706
7617
|
translateTo(x, y, timeStamp) {
|
|
7707
7618
|
if (!this.id) {}
|
|
7708
7619
|
this.emitMatrix({
|
|
7709
|
-
translateX: x - this.
|
|
7710
|
-
translateY: y - this.
|
|
7620
|
+
translateX: x - this._matrix.translateX,
|
|
7621
|
+
translateY: y - this._matrix.translateY,
|
|
7711
7622
|
scaleX: 1,
|
|
7712
7623
|
scaleY: 1,
|
|
7713
7624
|
shearX: 0,
|
|
@@ -7732,8 +7643,8 @@ class Transformation {
|
|
|
7732
7643
|
this.emitMatrix({
|
|
7733
7644
|
translateX: 0,
|
|
7734
7645
|
translateY: 0,
|
|
7735
|
-
scaleX: x / this.
|
|
7736
|
-
scaleY: y / this.
|
|
7646
|
+
scaleX: x / this._matrix.scaleX,
|
|
7647
|
+
scaleY: y / this._matrix.scaleY,
|
|
7737
7648
|
shearX: 0,
|
|
7738
7649
|
shearY: 0
|
|
7739
7650
|
}, timeStamp);
|
|
@@ -7786,14 +7697,14 @@ class Transformation {
|
|
|
7786
7697
|
this.emitMatrix({
|
|
7787
7698
|
translateX: 0,
|
|
7788
7699
|
translateY: 0,
|
|
7789
|
-
scaleX: x / this.
|
|
7790
|
-
scaleY: y / this.
|
|
7700
|
+
scaleX: x / this._matrix.scaleX,
|
|
7701
|
+
scaleY: y / this._matrix.scaleY,
|
|
7791
7702
|
shearX: 0,
|
|
7792
7703
|
shearY: 0
|
|
7793
7704
|
}, timeStamp);
|
|
7794
7705
|
}
|
|
7795
7706
|
scaleByRelativeTo(x, y, point, timeStamp) {
|
|
7796
|
-
const { scaleX: sx0, scaleY: sy0, translateX: tx0, translateY: ty0 } = this.
|
|
7707
|
+
const { scaleX: sx0, scaleY: sy0, translateX: tx0, translateY: ty0 } = this._matrix;
|
|
7797
7708
|
const newSx = sx0 * x;
|
|
7798
7709
|
const newSy = sy0 * y;
|
|
7799
7710
|
this.emitMatrix({
|
|
@@ -7824,6 +7735,130 @@ class Transformation {
|
|
|
7824
7735
|
});
|
|
7825
7736
|
}
|
|
7826
7737
|
}
|
|
7738
|
+
apply(op) {
|
|
7739
|
+
this.previous = this._matrix.copy();
|
|
7740
|
+
switch (op.method) {
|
|
7741
|
+
case "applyMatrix": {
|
|
7742
|
+
const itemOp = op.items.find((i) => i.id === this.id);
|
|
7743
|
+
if (itemOp) {
|
|
7744
|
+
this._matrix.scale(itemOp.matrix.scaleX, itemOp.matrix.scaleY);
|
|
7745
|
+
this._matrix.translate(itemOp.matrix.translateX, itemOp.matrix.translateY);
|
|
7746
|
+
}
|
|
7747
|
+
break;
|
|
7748
|
+
}
|
|
7749
|
+
case "translateTo":
|
|
7750
|
+
this.applyTranslateTo(op.x, op.y);
|
|
7751
|
+
break;
|
|
7752
|
+
case "translateBy":
|
|
7753
|
+
this.applyTranslateBy(op.x, op.y);
|
|
7754
|
+
break;
|
|
7755
|
+
case "scaleTo":
|
|
7756
|
+
this.applyScaleTo(op.x, op.y);
|
|
7757
|
+
break;
|
|
7758
|
+
case "scaleBy":
|
|
7759
|
+
this.applyScaleBy(op.x, op.y);
|
|
7760
|
+
break;
|
|
7761
|
+
case "scaleToRelativeTo":
|
|
7762
|
+
this.applyScaleToRelativeTo(op.x, op.y, op.point);
|
|
7763
|
+
break;
|
|
7764
|
+
case "scaleByRelativeTo":
|
|
7765
|
+
this.applyScaleByRelativeTo(op.x, op.y, op.point);
|
|
7766
|
+
break;
|
|
7767
|
+
case "scaleByTranslateBy":
|
|
7768
|
+
this.applyScaleByTranslateBy(op.scale, op.translate);
|
|
7769
|
+
break;
|
|
7770
|
+
case "rotateTo":
|
|
7771
|
+
this.applyRotateTo(op.degree);
|
|
7772
|
+
break;
|
|
7773
|
+
case "rotateBy":
|
|
7774
|
+
this.applyRotateBy(op.degree);
|
|
7775
|
+
break;
|
|
7776
|
+
case "transformMany":
|
|
7777
|
+
this.applyTransformMany(op.items[this.id]);
|
|
7778
|
+
break;
|
|
7779
|
+
case "locked":
|
|
7780
|
+
this.applyLocked(op.locked);
|
|
7781
|
+
break;
|
|
7782
|
+
case "unlocked":
|
|
7783
|
+
this.applyUnlocked(op.locked);
|
|
7784
|
+
break;
|
|
7785
|
+
default:
|
|
7786
|
+
return;
|
|
7787
|
+
}
|
|
7788
|
+
this.subject.publish(this, op);
|
|
7789
|
+
}
|
|
7790
|
+
applyTranslateTo(x, y) {
|
|
7791
|
+
this._matrix.translateX = x;
|
|
7792
|
+
this._matrix.translateY = y;
|
|
7793
|
+
}
|
|
7794
|
+
applyTranslateBy(x, y) {
|
|
7795
|
+
this._matrix.translate(x, y);
|
|
7796
|
+
}
|
|
7797
|
+
applyScaleTo(x, y) {
|
|
7798
|
+
this._matrix.scaleX = x;
|
|
7799
|
+
this._matrix.scaleY = y;
|
|
7800
|
+
}
|
|
7801
|
+
applyScaleBy(x, y) {
|
|
7802
|
+
this._matrix.scale(x, y);
|
|
7803
|
+
}
|
|
7804
|
+
applyScaleByTranslateBy(scale, translate) {
|
|
7805
|
+
this._matrix.scale(scale.x, scale.y);
|
|
7806
|
+
this._matrix.translate(translate.x, translate.y);
|
|
7807
|
+
}
|
|
7808
|
+
applyTransformMany(op) {
|
|
7809
|
+
if (op.method === "applyMatrix") {
|
|
7810
|
+
this._matrix.scale(op.matrix.scaleX, op.matrix.scaleY);
|
|
7811
|
+
this._matrix.translate(op.matrix.translateX, op.matrix.translateY);
|
|
7812
|
+
} else if (op.method === "scaleByTranslateBy") {
|
|
7813
|
+
this.applyScaleByTranslateBy(op.scale, op.translate);
|
|
7814
|
+
} else if (op.method === "scaleBy") {
|
|
7815
|
+
this.applyScaleBy(op.x, op.y);
|
|
7816
|
+
} else if (op.method === "translateBy") {
|
|
7817
|
+
this.applyTranslateBy(op.x, op.y);
|
|
7818
|
+
} else if (op.method === "translateTo") {
|
|
7819
|
+
this.applyTranslateTo(op.x, op.y);
|
|
7820
|
+
}
|
|
7821
|
+
}
|
|
7822
|
+
applyScaleByRelativeTo(x, y, point) {
|
|
7823
|
+
const scaleX = this._matrix.scaleX * x;
|
|
7824
|
+
const scaleY = this._matrix.scaleY * y;
|
|
7825
|
+
this._matrix.translateX = -point.x * scaleX + point.x;
|
|
7826
|
+
this._matrix.translateY = -point.y * scaleY + point.y;
|
|
7827
|
+
this._matrix.scaleX = scaleX;
|
|
7828
|
+
this._matrix.scaleY = scaleY;
|
|
7829
|
+
}
|
|
7830
|
+
applyScaleToRelativeTo(x, y, point) {
|
|
7831
|
+
this.applyTranslateBy(-point.x, -point.y);
|
|
7832
|
+
this.applyScaleTo(x, y);
|
|
7833
|
+
this.applyTranslateBy(point.x, point.y);
|
|
7834
|
+
}
|
|
7835
|
+
applyRotateTo(degree) {
|
|
7836
|
+
if (degree > 0) {
|
|
7837
|
+
while (degree > 360) {
|
|
7838
|
+
degree -= 360;
|
|
7839
|
+
}
|
|
7840
|
+
if (degree === 360) {
|
|
7841
|
+
degree = 0;
|
|
7842
|
+
}
|
|
7843
|
+
} else {
|
|
7844
|
+
while (degree < -360) {
|
|
7845
|
+
degree += 360;
|
|
7846
|
+
}
|
|
7847
|
+
if (degree === -360) {
|
|
7848
|
+
degree = 0;
|
|
7849
|
+
}
|
|
7850
|
+
}
|
|
7851
|
+
this.rotate = degree;
|
|
7852
|
+
}
|
|
7853
|
+
applyRotateBy(degree) {
|
|
7854
|
+
this.applyRotateTo(this.rotate + degree);
|
|
7855
|
+
}
|
|
7856
|
+
applyLocked(locked) {
|
|
7857
|
+
this.isLocked = locked;
|
|
7858
|
+
}
|
|
7859
|
+
applyUnlocked(locked) {
|
|
7860
|
+
this.isLocked = locked;
|
|
7861
|
+
}
|
|
7827
7862
|
}
|
|
7828
7863
|
// src/Items/DrawingContext.ts
|
|
7829
7864
|
class DrawingContext {
|
|
@@ -19252,12 +19287,11 @@ class Comment {
|
|
|
19252
19287
|
});
|
|
19253
19288
|
}
|
|
19254
19289
|
transform() {
|
|
19255
|
-
const
|
|
19256
|
-
if (
|
|
19257
|
-
this.anchor = new Point(
|
|
19290
|
+
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
19291
|
+
if (translateX && translateY) {
|
|
19292
|
+
this.anchor = new Point(translateX, translateY);
|
|
19258
19293
|
} else {
|
|
19259
|
-
|
|
19260
|
-
matrix.translateY = this.anchor.y;
|
|
19294
|
+
this.transformation.setLocal(this.anchor.x, this.anchor.y);
|
|
19261
19295
|
}
|
|
19262
19296
|
}
|
|
19263
19297
|
getUnreadMessages(userId = ANONYMOUS_ID) {
|
|
@@ -19366,7 +19400,7 @@ class Comment {
|
|
|
19366
19400
|
render(context) {}
|
|
19367
19401
|
renderHTML(documentFactory) {
|
|
19368
19402
|
const div = documentFactory.createElement("comment-item");
|
|
19369
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
19403
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
19370
19404
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
19371
19405
|
div.style.transformOrigin = "top left";
|
|
19372
19406
|
div.style.transform = transform;
|
|
@@ -21310,6 +21344,9 @@ class Items {
|
|
|
21310
21344
|
item.render(context);
|
|
21311
21345
|
}
|
|
21312
21346
|
});
|
|
21347
|
+
items.forEach((item) => {
|
|
21348
|
+
item.renderHoverHighlight(context);
|
|
21349
|
+
});
|
|
21313
21350
|
}
|
|
21314
21351
|
renderHTML(documentFactory) {
|
|
21315
21352
|
const items = this.getItemsInView();
|
|
@@ -21873,20 +21910,23 @@ class BaseItem extends Mbr {
|
|
|
21873
21910
|
this.isHoverHighlighted = false;
|
|
21874
21911
|
this.subject.publish(this);
|
|
21875
21912
|
}
|
|
21913
|
+
renderHoverHighlight(context) {
|
|
21914
|
+
if (!this.isHoverHighlighted) {
|
|
21915
|
+
return;
|
|
21916
|
+
}
|
|
21917
|
+
const mbr = this.getMbr();
|
|
21918
|
+
mbr.strokeWidth = 2 / context.matrix.scaleX;
|
|
21919
|
+
mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
|
|
21920
|
+
mbr.render(context);
|
|
21921
|
+
}
|
|
21876
21922
|
render(context) {
|
|
21877
21923
|
if (this.index) {
|
|
21878
21924
|
this.index.render(context);
|
|
21879
21925
|
}
|
|
21880
|
-
if (this.isHoverHighlighted) {
|
|
21881
|
-
const mbr = this.getMbr();
|
|
21882
|
-
mbr.strokeWidth = 2 / context.matrix.scaleX;
|
|
21883
|
-
mbr.borderColor = BaseItem.HOVER_HIGHLIGHT_COLOR;
|
|
21884
|
-
mbr.render(context);
|
|
21885
|
-
}
|
|
21886
21926
|
}
|
|
21887
21927
|
renderHTML(documentFactory) {
|
|
21888
21928
|
const div = documentFactory.createElement("base-item");
|
|
21889
|
-
const { translateX, translateY } = this.transformation.
|
|
21929
|
+
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
21890
21930
|
const transform = `translate(${translateX}px, ${translateY}px) scale(1, 1)`;
|
|
21891
21931
|
div.style.backgroundColor = "#b2b0c3";
|
|
21892
21932
|
div.id = this.getId();
|
|
@@ -22028,7 +22068,7 @@ class RichText extends BaseItem {
|
|
|
22028
22068
|
mbr.right += 20;
|
|
22029
22069
|
mbr.bottom += 20;
|
|
22030
22070
|
}
|
|
22031
|
-
const linkMbr = mbr.getTransformed(this.transformation.
|
|
22071
|
+
const linkMbr = mbr.getTransformed(this.transformation.toMatrix());
|
|
22032
22072
|
if (linkMbr.isUnderPoint(point3)) {
|
|
22033
22073
|
return { hyperLink, linkMbr };
|
|
22034
22074
|
}
|
|
@@ -22225,12 +22265,13 @@ class RichText extends BaseItem {
|
|
|
22225
22265
|
return this.shrinkWidth;
|
|
22226
22266
|
}
|
|
22227
22267
|
getTransformedContainer() {
|
|
22228
|
-
let matrix = this.transformation.matrix;
|
|
22229
22268
|
if (this.insideOf === "Frame") {
|
|
22269
|
+
const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
|
|
22230
22270
|
const scaleY = this.getMbr().getHeight() * 2 / 10;
|
|
22231
|
-
matrix = new Matrix2(
|
|
22271
|
+
const matrix = new Matrix2(translateX, translateY, scaleX, scaleY);
|
|
22272
|
+
return this.container.getTransformed(matrix);
|
|
22232
22273
|
}
|
|
22233
|
-
return this.container.getTransformed(
|
|
22274
|
+
return this.container.getTransformed(this.transformation.toMatrix());
|
|
22234
22275
|
}
|
|
22235
22276
|
emitWithoutApplying = (op) => {
|
|
22236
22277
|
if (this.board.events) {
|
|
@@ -22591,7 +22632,7 @@ class RichText extends BaseItem {
|
|
|
22591
22632
|
ctx.translate(this.left, this.top);
|
|
22592
22633
|
const shouldScale = !this.isInShape && !this.autoSize;
|
|
22593
22634
|
if (shouldScale) {
|
|
22594
|
-
const { scaleX, scaleY } = this.transformation.
|
|
22635
|
+
const { scaleX, scaleY } = this.transformation.getMatrixData();
|
|
22595
22636
|
ctx.scale(scaleX, scaleY);
|
|
22596
22637
|
}
|
|
22597
22638
|
const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
|
|
@@ -22724,7 +22765,7 @@ class RichText extends BaseItem {
|
|
|
22724
22765
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
22725
22766
|
};
|
|
22726
22767
|
const elements = this.editor.editor.children.map(renderNode);
|
|
22727
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
22768
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
22728
22769
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
22729
22770
|
const transformedWidth = this.getTransformedContainer().getWidth();
|
|
22730
22771
|
const transformedHeight = this.getTransformedContainer().getHeight();
|
|
@@ -35956,17 +35997,17 @@ class AINode extends BaseItem {
|
|
|
35956
35997
|
}
|
|
35957
35998
|
transformPath() {
|
|
35958
35999
|
const { left, right, top, bottom } = this.text.getTransformedContainer();
|
|
35959
|
-
const { scaleX, scaleY } = this.transformation.
|
|
36000
|
+
const { scaleX, scaleY, translateX: nodeTranslateX, translateY: nodeTranslateY } = this.transformation.getMatrixData();
|
|
35960
36001
|
const minScale = Math.min(scaleX, scaleY);
|
|
35961
36002
|
const leftOffset = 20 * minScale;
|
|
35962
36003
|
const topOffset = 20 * minScale;
|
|
35963
36004
|
const nodeRight = right + 80 * minScale;
|
|
35964
36005
|
const nodeBottom = bottom + (bottom - top > 400 ? 60 : 40) * minScale;
|
|
35965
36006
|
if (!this.path || this.text.left < this.path.getMbr().left + leftOffset && this.text.top < this.path.getMbr().top + topOffset) {
|
|
35966
|
-
this.text.left =
|
|
35967
|
-
this.text.top =
|
|
36007
|
+
this.text.left = nodeTranslateX + leftOffset;
|
|
36008
|
+
this.text.top = nodeTranslateY + topOffset;
|
|
35968
36009
|
}
|
|
35969
|
-
this.path = createNodePath(new Mbr(left, top, nodeRight, nodeBottom), this.transformation.
|
|
36010
|
+
this.path = createNodePath(new Mbr(left, top, nodeRight, nodeBottom), this.transformation.toMatrix());
|
|
35970
36011
|
const scaledSize = BUTTON_SIZE * minScale;
|
|
35971
36012
|
this.buttonMbr = new Mbr(nodeRight - scaledSize * 2, nodeBottom - scaledSize * 2, nodeRight - scaledSize, nodeBottom - scaledSize);
|
|
35972
36013
|
}
|
|
@@ -36127,7 +36168,7 @@ class AINode extends BaseItem {
|
|
|
36127
36168
|
}
|
|
36128
36169
|
renderHTML(documentFactory) {
|
|
36129
36170
|
const div = documentFactory.createElement("ainode-item");
|
|
36130
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
36171
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
36131
36172
|
const mbr = this.getMbr();
|
|
36132
36173
|
const width = mbr.getWidth();
|
|
36133
36174
|
const height = mbr.getHeight();
|
|
@@ -37600,7 +37641,7 @@ class Connector2 extends BaseItem {
|
|
|
37600
37641
|
}
|
|
37601
37642
|
renderHTML(documentFactory) {
|
|
37602
37643
|
const div = documentFactory.createElement("connector-item");
|
|
37603
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
37644
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
37604
37645
|
const mbr = this.getMbr();
|
|
37605
37646
|
const width = mbr.getWidth();
|
|
37606
37647
|
const height = mbr.getHeight();
|
|
@@ -37665,7 +37706,7 @@ class Connector2 extends BaseItem {
|
|
|
37665
37706
|
return div;
|
|
37666
37707
|
}
|
|
37667
37708
|
renderPathHTML(documentFactory, path2) {
|
|
37668
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
37709
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
37669
37710
|
const pathElement = path2.renderHTML(documentFactory);
|
|
37670
37711
|
const paths = Array.isArray(pathElement) ? pathElement : [pathElement];
|
|
37671
37712
|
paths.forEach((element4) => {
|
|
@@ -37687,8 +37728,7 @@ class Connector2 extends BaseItem {
|
|
|
37687
37728
|
text5.transformation = undefined;
|
|
37688
37729
|
const mbr = this.getMbr();
|
|
37689
37730
|
const transformation = new Transformation;
|
|
37690
|
-
transformation.
|
|
37691
|
-
transformation.matrix.translateY = mbr.top;
|
|
37731
|
+
transformation.setLocal(mbr.left, mbr.top);
|
|
37692
37732
|
return {
|
|
37693
37733
|
itemType: "Connector",
|
|
37694
37734
|
transformation: transformation.serialize(),
|
|
@@ -37768,7 +37808,7 @@ class Connector2 extends BaseItem {
|
|
|
37768
37808
|
previous2.translateX = 0;
|
|
37769
37809
|
previous2.translateY = 0;
|
|
37770
37810
|
previous2.invert();
|
|
37771
|
-
const currUnscaled = this.transformation.
|
|
37811
|
+
const currUnscaled = this.transformation.toMatrix();
|
|
37772
37812
|
currUnscaled.translateX = 0;
|
|
37773
37813
|
currUnscaled.translateY = 0;
|
|
37774
37814
|
const delta = previous2.multiplyByMatrix(currUnscaled);
|
|
@@ -37795,7 +37835,7 @@ class Connector2 extends BaseItem {
|
|
|
37795
37835
|
previous2.scaleX = 1;
|
|
37796
37836
|
previous2.scaleY = 1;
|
|
37797
37837
|
previous2.invert();
|
|
37798
|
-
const currUnscaled = this.transformation.
|
|
37838
|
+
const currUnscaled = this.transformation.toMatrix();
|
|
37799
37839
|
currUnscaled.scaleX = 1;
|
|
37800
37840
|
currUnscaled.scaleY = 1;
|
|
37801
37841
|
const delta = previous2.multiplyByMatrix(currUnscaled);
|
|
@@ -39762,7 +39802,7 @@ class Shape extends BaseItem {
|
|
|
39762
39802
|
}
|
|
39763
39803
|
renderHTML(documentFactory) {
|
|
39764
39804
|
const div = documentFactory.createElement("shape-item");
|
|
39765
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
39805
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
39766
39806
|
const mbr = this.getMbr();
|
|
39767
39807
|
const width = mbr.getWidth();
|
|
39768
39808
|
const height = mbr.getHeight();
|
|
@@ -39851,8 +39891,8 @@ class Shape extends BaseItem {
|
|
|
39851
39891
|
this.path = Shapes[this.shapeType].createPath(this.mbr);
|
|
39852
39892
|
this.textContainer = Shapes[this.shapeType].textBounds.copy();
|
|
39853
39893
|
this.text.setContainer(this.textContainer.copy());
|
|
39854
|
-
this.textContainer.transform(this.transformation.
|
|
39855
|
-
this.path.transform(this.transformation.
|
|
39894
|
+
this.textContainer.transform(this.transformation.toMatrix());
|
|
39895
|
+
this.path.transform(this.transformation.toMatrix());
|
|
39856
39896
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
39857
39897
|
this.path.setBackgroundOpacity(this.backgroundOpacity);
|
|
39858
39898
|
this.path.setBorderColor(this.borderColor);
|
|
@@ -39867,7 +39907,7 @@ class Shape extends BaseItem {
|
|
|
39867
39907
|
const anchorPoints = Shapes[this.shapeType].anchorPoints;
|
|
39868
39908
|
const points = [];
|
|
39869
39909
|
for (const anchorPoint of anchorPoints) {
|
|
39870
|
-
points.push(anchorPoint.getTransformed(this.transformation.
|
|
39910
|
+
points.push(anchorPoint.getTransformed(this.transformation.toMatrix()));
|
|
39871
39911
|
}
|
|
39872
39912
|
return points;
|
|
39873
39913
|
}
|
|
@@ -40037,10 +40077,9 @@ class Sticker extends BaseItem {
|
|
|
40037
40077
|
}
|
|
40038
40078
|
this.stickerPath = StickerShape.stickerPath.copy();
|
|
40039
40079
|
this.textContainer = StickerShape.textBounds.copy();
|
|
40040
|
-
|
|
40041
|
-
this.stickerPath.transform(matrix);
|
|
40080
|
+
this.stickerPath.transform(this.transformation.toMatrix());
|
|
40042
40081
|
this.text.setContainer(this.textContainer.copy());
|
|
40043
|
-
this.textContainer.transform(this.transformation.
|
|
40082
|
+
this.textContainer.transform(this.transformation.toMatrix());
|
|
40044
40083
|
this.stickerPath.setBackgroundColor(this.backgroundColor);
|
|
40045
40084
|
this.saveStickerData();
|
|
40046
40085
|
}
|
|
@@ -40141,7 +40180,7 @@ class Sticker extends BaseItem {
|
|
|
40141
40180
|
}
|
|
40142
40181
|
renderHTML(documentFactory) {
|
|
40143
40182
|
const div = documentFactory.createElement("sticker-item");
|
|
40144
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
40183
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
40145
40184
|
const transform = `translate(${Math.round(translateX)}px, ${Math.round(translateY)}px) scale(${scaleX}, ${scaleY})`;
|
|
40146
40185
|
const itemMbr = this.getMbr();
|
|
40147
40186
|
const height2 = itemMbr.getHeight();
|
|
@@ -40222,7 +40261,7 @@ class Sticker extends BaseItem {
|
|
|
40222
40261
|
const anchorPoints = StickerShape.anchorPoints;
|
|
40223
40262
|
const points = [];
|
|
40224
40263
|
for (const anchorPoint of anchorPoints) {
|
|
40225
|
-
points.push(anchorPoint.getTransformed(this.transformation.
|
|
40264
|
+
points.push(anchorPoint.getTransformed(this.transformation.toMatrix()));
|
|
40226
40265
|
}
|
|
40227
40266
|
return points;
|
|
40228
40267
|
}
|
|
@@ -40236,20 +40275,7 @@ class Sticker extends BaseItem {
|
|
|
40236
40275
|
if (line.end.y < line.start.y) {
|
|
40237
40276
|
y -= l * height;
|
|
40238
40277
|
}
|
|
40239
|
-
this.transformation.
|
|
40240
|
-
class: "Transformation",
|
|
40241
|
-
method: "translateTo",
|
|
40242
|
-
item: [this.id],
|
|
40243
|
-
x,
|
|
40244
|
-
y
|
|
40245
|
-
});
|
|
40246
|
-
this.transformation.apply({
|
|
40247
|
-
class: "Transformation",
|
|
40248
|
-
method: "scaleTo",
|
|
40249
|
-
item: [this.id],
|
|
40250
|
-
x: l,
|
|
40251
|
-
y: l
|
|
40252
|
-
});
|
|
40278
|
+
this.transformation.setLocal(x, y, l, l);
|
|
40253
40279
|
this.saveStickerData();
|
|
40254
40280
|
}
|
|
40255
40281
|
applyTransformToCenter(pt, newWidth) {
|
|
@@ -40257,35 +40283,9 @@ class Sticker extends BaseItem {
|
|
|
40257
40283
|
const scale = newWidth / width;
|
|
40258
40284
|
const w = width * scale;
|
|
40259
40285
|
const h2 = height * scale;
|
|
40260
|
-
this.transformation.
|
|
40261
|
-
class: "Transformation",
|
|
40262
|
-
method: "translateTo",
|
|
40263
|
-
item: [this.id],
|
|
40264
|
-
x: pt.x - w / 2,
|
|
40265
|
-
y: pt.y - h2 / 2
|
|
40266
|
-
});
|
|
40267
|
-
this.transformation.apply({
|
|
40268
|
-
class: "Transformation",
|
|
40269
|
-
method: "scaleTo",
|
|
40270
|
-
item: [this.id],
|
|
40271
|
-
x: scale,
|
|
40272
|
-
y: scale
|
|
40273
|
-
});
|
|
40286
|
+
this.transformation.setLocal(pt.x - w / 2, pt.y - h2 / 2, scale, scale);
|
|
40274
40287
|
} else {
|
|
40275
|
-
this.transformation.
|
|
40276
|
-
class: "Transformation",
|
|
40277
|
-
method: "translateTo",
|
|
40278
|
-
item: [this.id],
|
|
40279
|
-
x: pt.x - width / 2,
|
|
40280
|
-
y: pt.y - height / 2
|
|
40281
|
-
});
|
|
40282
|
-
this.transformation.apply({
|
|
40283
|
-
class: "Transformation",
|
|
40284
|
-
method: "scaleTo",
|
|
40285
|
-
item: [this.id],
|
|
40286
|
-
x: 1,
|
|
40287
|
-
y: 1
|
|
40288
|
-
});
|
|
40288
|
+
this.transformation.setLocal(pt.x - width / 2, pt.y - height / 2, 1, 1);
|
|
40289
40289
|
}
|
|
40290
40290
|
}
|
|
40291
40291
|
doResize(resizeType, pointer, mbr, opposite, startMbr, timeStamp) {
|
|
@@ -40591,7 +40591,7 @@ class Frame2 extends BaseItem {
|
|
|
40591
40591
|
const res = this.getCanChangeRatio() ? getResize(resizeType, pointer, mbr, opposite) : getProportionalResize(resizeType, pointer, mbr, opposite);
|
|
40592
40592
|
if (!res) {
|
|
40593
40593
|
return {
|
|
40594
|
-
matrix: this.transformation.
|
|
40594
|
+
matrix: this.transformation.toMatrix(),
|
|
40595
40595
|
mbr: this.getMbr()
|
|
40596
40596
|
};
|
|
40597
40597
|
}
|
|
@@ -40690,8 +40690,9 @@ class Frame2 extends BaseItem {
|
|
|
40690
40690
|
return this;
|
|
40691
40691
|
}
|
|
40692
40692
|
getSavedProportionsMatrix() {
|
|
40693
|
-
const
|
|
40694
|
-
const
|
|
40693
|
+
const { scaleX, scaleY } = this.transformation.getMatrixData();
|
|
40694
|
+
const newScale = Math.min(scaleX, scaleY);
|
|
40695
|
+
const newMatrix = this.transformation.toMatrix();
|
|
40695
40696
|
newMatrix.scaleX = newScale;
|
|
40696
40697
|
newMatrix.scaleY = newScale;
|
|
40697
40698
|
return newMatrix;
|
|
@@ -40705,8 +40706,8 @@ class Frame2 extends BaseItem {
|
|
|
40705
40706
|
this.textContainer.transform(newMatrix);
|
|
40706
40707
|
this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
|
|
40707
40708
|
} else {
|
|
40708
|
-
this.path.transform(this.transformation.
|
|
40709
|
-
this.textContainer.transform(this.transformation.
|
|
40709
|
+
this.path.transform(this.transformation.toMatrix());
|
|
40710
|
+
this.textContainer.transform(this.transformation.toMatrix());
|
|
40710
40711
|
}
|
|
40711
40712
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
40712
40713
|
this.path.setBackgroundOpacity(this.backgroundOpacity);
|
|
@@ -40762,7 +40763,7 @@ class Frame2 extends BaseItem {
|
|
|
40762
40763
|
const anchorPoints = Frames[this.shapeType].anchorPoints;
|
|
40763
40764
|
const points = [];
|
|
40764
40765
|
for (const anchorPoint of anchorPoints) {
|
|
40765
|
-
points.push(anchorPoint.getTransformed(this.transformation.
|
|
40766
|
+
points.push(anchorPoint.getTransformed(this.transformation.toMatrix()));
|
|
40766
40767
|
}
|
|
40767
40768
|
return points;
|
|
40768
40769
|
}
|
|
@@ -40938,7 +40939,7 @@ class Frame2 extends BaseItem {
|
|
|
40938
40939
|
div.style.borderColor = this.borderColor;
|
|
40939
40940
|
div.style.borderWidth = `${this.borderWidth}px`;
|
|
40940
40941
|
div.style.borderStyle = this.borderStyle;
|
|
40941
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
40942
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
40942
40943
|
const transform = `translate(${Math.round(translateX)}px, ${Math.round(translateY)}px) scale(1, 1)`;
|
|
40943
40944
|
const width2 = this.getMbr().getWidth();
|
|
40944
40945
|
const height2 = this.getMbr().getHeight();
|
|
@@ -41251,13 +41252,13 @@ class VideoItem extends BaseItem {
|
|
|
41251
41252
|
this.shootLoadCallbacks();
|
|
41252
41253
|
};
|
|
41253
41254
|
updateMbr() {
|
|
41254
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
41255
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
41255
41256
|
this.left = translateX;
|
|
41256
41257
|
this.top = translateY;
|
|
41257
41258
|
this.right = this.left + this.videoDimension.width * scaleX;
|
|
41258
41259
|
this.bottom = this.top + this.videoDimension.height * scaleY;
|
|
41259
41260
|
const playBtnSize = 50;
|
|
41260
|
-
const scaledPlayBtn = playBtnSize * this.transformation.
|
|
41261
|
+
const scaledPlayBtn = playBtnSize * this.transformation.getMatrixData().scaleX;
|
|
41261
41262
|
this.playBtnMbr = new Mbr(this.left + this.getWidth() / 2 - scaledPlayBtn / 2, this.top + this.getHeight() / 2 - scaledPlayBtn / 2, this.right - this.getWidth() / 2 + scaledPlayBtn / 2, this.bottom - this.getHeight() / 2 + scaledPlayBtn / 2);
|
|
41262
41263
|
}
|
|
41263
41264
|
render(context) {
|
|
@@ -41273,7 +41274,7 @@ class VideoItem extends BaseItem {
|
|
|
41273
41274
|
return;
|
|
41274
41275
|
}
|
|
41275
41276
|
ctx.save();
|
|
41276
|
-
this.transformation.
|
|
41277
|
+
this.transformation.applyToContext(ctx);
|
|
41277
41278
|
ctx.drawImage(this.preview, 0, 0);
|
|
41278
41279
|
if (this.shouldShowControls && this.previewUrl) {
|
|
41279
41280
|
ctx.restore();
|
|
@@ -41294,7 +41295,7 @@ class VideoItem extends BaseItem {
|
|
|
41294
41295
|
}
|
|
41295
41296
|
renderHTML(documentFactory) {
|
|
41296
41297
|
const div = documentFactory.createElement("video-item");
|
|
41297
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
41298
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
41298
41299
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
41299
41300
|
div.style.backgroundImage = this.previewUrl ? `url(${this.previewUrl})` : `url(${createPlaceholderImage(this.videoDimension.width, this.videoDimension.height).src})`;
|
|
41300
41301
|
div.id = this.getId();
|
|
@@ -41752,7 +41753,7 @@ class AudioItem extends BaseItem {
|
|
|
41752
41753
|
this.shootLoadCallbacks();
|
|
41753
41754
|
};
|
|
41754
41755
|
updateMbr() {
|
|
41755
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
41756
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
41756
41757
|
this.left = translateX;
|
|
41757
41758
|
this.top = translateY;
|
|
41758
41759
|
this.right = this.left + conf.AUDIO_DIMENSIONS.width * scaleX;
|
|
@@ -41782,7 +41783,7 @@ class AudioItem extends BaseItem {
|
|
|
41782
41783
|
}
|
|
41783
41784
|
renderHTML(documentFactory) {
|
|
41784
41785
|
const div = documentFactory.createElement("audio-item");
|
|
41785
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
41786
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
41786
41787
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
41787
41788
|
div.id = this.getId();
|
|
41788
41789
|
div.style.width = `${conf.AUDIO_DIMENSIONS.width}px`;
|
|
@@ -42134,7 +42135,7 @@ class Placeholder extends BaseItem {
|
|
|
42134
42135
|
const anchorPoints = Shapes[this.shapeType].anchorPoints;
|
|
42135
42136
|
const points = [];
|
|
42136
42137
|
for (const anchorPoint of anchorPoints) {
|
|
42137
|
-
points.push(anchorPoint.getTransformed(this.transformation.
|
|
42138
|
+
points.push(anchorPoint.getTransformed(this.transformation.toMatrix()));
|
|
42138
42139
|
}
|
|
42139
42140
|
return points;
|
|
42140
42141
|
}
|
|
@@ -42152,7 +42153,7 @@ class Placeholder extends BaseItem {
|
|
|
42152
42153
|
}
|
|
42153
42154
|
transformPath() {
|
|
42154
42155
|
this.path = Shapes[this.shapeType].createPath(this.mbr);
|
|
42155
|
-
this.path.transform(this.transformation.
|
|
42156
|
+
this.path.transform(this.transformation.toMatrix());
|
|
42156
42157
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
42157
42158
|
this.path.setBorderColor("transparent");
|
|
42158
42159
|
}
|
|
@@ -42348,7 +42349,7 @@ class ImageItem extends BaseItem {
|
|
|
42348
42349
|
this.subject.publish(this);
|
|
42349
42350
|
};
|
|
42350
42351
|
updateMbr() {
|
|
42351
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
42352
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
42352
42353
|
const rotation = this.transformation.getRotation();
|
|
42353
42354
|
const width2 = this.image.width * scaleX;
|
|
42354
42355
|
const height2 = this.image.height * scaleY;
|
|
@@ -42391,10 +42392,11 @@ class ImageItem extends BaseItem {
|
|
|
42391
42392
|
};
|
|
42392
42393
|
}
|
|
42393
42394
|
setCoordinates() {
|
|
42394
|
-
|
|
42395
|
-
this.
|
|
42396
|
-
this.
|
|
42397
|
-
this.
|
|
42395
|
+
const { translateX: coordX, translateY: coordY, scaleX: coordScaleX, scaleY: coordScaleY } = this.transformation.getMatrixData();
|
|
42396
|
+
this.left = coordX;
|
|
42397
|
+
this.top = coordY;
|
|
42398
|
+
this.right = this.left + this.image.width * coordScaleX;
|
|
42399
|
+
this.bottom = this.top + this.image.height * coordScaleY;
|
|
42398
42400
|
this.subject.publish(this);
|
|
42399
42401
|
}
|
|
42400
42402
|
shootBeforeLoadCallbacks() {
|
|
@@ -42461,7 +42463,7 @@ class ImageItem extends BaseItem {
|
|
|
42461
42463
|
}
|
|
42462
42464
|
const ctx = context.ctx;
|
|
42463
42465
|
ctx.save();
|
|
42464
|
-
this.transformation.
|
|
42466
|
+
this.transformation.applyToContext(ctx);
|
|
42465
42467
|
const rotation = this.transformation.getRotation();
|
|
42466
42468
|
if (rotation !== 0) {
|
|
42467
42469
|
const imgWidth = this.image.width || 0;
|
|
@@ -42479,7 +42481,7 @@ class ImageItem extends BaseItem {
|
|
|
42479
42481
|
}
|
|
42480
42482
|
renderHTML(documentFactory) {
|
|
42481
42483
|
const div = documentFactory.createElement("image-item");
|
|
42482
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
42484
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
42483
42485
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
42484
42486
|
div.style.backgroundImage = `url(${this.storageLink})`;
|
|
42485
42487
|
div.id = this.getId();
|
|
@@ -42632,7 +42634,7 @@ class Drawing extends BaseItem {
|
|
|
42632
42634
|
untransformedMbr.top -= offset;
|
|
42633
42635
|
untransformedMbr.right += offset;
|
|
42634
42636
|
untransformedMbr.bottom += offset;
|
|
42635
|
-
const mbr = untransformedMbr.getTransformed(this.transformation.
|
|
42637
|
+
const mbr = untransformedMbr.getTransformed(this.transformation.toMatrix());
|
|
42636
42638
|
this.left = mbr.left;
|
|
42637
42639
|
this.top = mbr.top;
|
|
42638
42640
|
this.right = mbr.right;
|
|
@@ -42679,7 +42681,7 @@ class Drawing extends BaseItem {
|
|
|
42679
42681
|
}
|
|
42680
42682
|
updateLines() {
|
|
42681
42683
|
this.lines = [];
|
|
42682
|
-
const matrix = this.transformation.
|
|
42684
|
+
const matrix = this.transformation.toMatrix();
|
|
42683
42685
|
if (this.points.length < 2) {
|
|
42684
42686
|
return;
|
|
42685
42687
|
}
|
|
@@ -42727,7 +42729,7 @@ class Drawing extends BaseItem {
|
|
|
42727
42729
|
ctx.lineWidth = this.strokeWidth;
|
|
42728
42730
|
ctx.lineCap = "round";
|
|
42729
42731
|
ctx.setLineDash(this.linePattern);
|
|
42730
|
-
this.transformation.
|
|
42732
|
+
this.transformation.applyToContext(ctx);
|
|
42731
42733
|
ctx.stroke(this.path2d.nativePath);
|
|
42732
42734
|
ctx.restore();
|
|
42733
42735
|
if (this.getLinkTo()) {
|
|
@@ -42737,7 +42739,7 @@ class Drawing extends BaseItem {
|
|
|
42737
42739
|
}
|
|
42738
42740
|
renderHTML(documentFactory) {
|
|
42739
42741
|
const div = documentFactory.createElement("drawing-item");
|
|
42740
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
42742
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
42741
42743
|
const mbr = this.getMbr();
|
|
42742
42744
|
const width2 = mbr.getWidth();
|
|
42743
42745
|
const height2 = mbr.getHeight();
|
|
@@ -42926,8 +42928,9 @@ class Drawing extends BaseItem {
|
|
|
42926
42928
|
return null;
|
|
42927
42929
|
}
|
|
42928
42930
|
isPointNearLine(point5, threshold = 10) {
|
|
42929
|
-
const
|
|
42930
|
-
const
|
|
42931
|
+
const { translateX: drawingTranslateX, translateY: drawingTranslateY, scaleX: drawingScaleX, scaleY: drawingScaleY } = this.transformation.getMatrixData();
|
|
42932
|
+
const transformedMouseX = (point5.x - drawingTranslateX) / drawingScaleX;
|
|
42933
|
+
const transformedMouseY = (point5.y - drawingTranslateY) / drawingScaleY;
|
|
42931
42934
|
const transformedMouse = new Point(transformedMouseX, transformedMouseY);
|
|
42932
42935
|
for (let i = 0;i < this.points.length - 1; i++) {
|
|
42933
42936
|
const p1 = this.points[i];
|
|
@@ -44254,40 +44257,16 @@ class AddFrame extends BoardTool {
|
|
|
44254
44257
|
this.applyTranslateBy(-this.frame.getMbr().getWidth() / 2, -this.frame.getMbr().getHeight() / 2);
|
|
44255
44258
|
}
|
|
44256
44259
|
applyScaleTo(x, y) {
|
|
44257
|
-
this.frame.transformation.
|
|
44258
|
-
class: "Transformation",
|
|
44259
|
-
method: "scaleTo",
|
|
44260
|
-
item: [this.frame.getId()],
|
|
44261
|
-
x,
|
|
44262
|
-
y
|
|
44263
|
-
});
|
|
44260
|
+
this.frame.transformation.setLocal({ scaleX: x, scaleY: y });
|
|
44264
44261
|
}
|
|
44265
44262
|
applyScaleBy(x, y) {
|
|
44266
|
-
this.frame.transformation.
|
|
44267
|
-
class: "Transformation",
|
|
44268
|
-
method: "scaleBy",
|
|
44269
|
-
item: [this.frame.getId()],
|
|
44270
|
-
x,
|
|
44271
|
-
y
|
|
44272
|
-
});
|
|
44263
|
+
this.frame.transformation.scaleBy(x, y);
|
|
44273
44264
|
}
|
|
44274
44265
|
applyTranslateTo(x, y) {
|
|
44275
|
-
this.frame.transformation.
|
|
44276
|
-
class: "Transformation",
|
|
44277
|
-
method: "translateTo",
|
|
44278
|
-
item: [this.frame.getId()],
|
|
44279
|
-
x,
|
|
44280
|
-
y
|
|
44281
|
-
});
|
|
44266
|
+
this.frame.transformation.setLocal(x, y);
|
|
44282
44267
|
}
|
|
44283
44268
|
applyTranslateBy(x, y) {
|
|
44284
|
-
this.frame.transformation.
|
|
44285
|
-
class: "Transformation",
|
|
44286
|
-
method: "translateBy",
|
|
44287
|
-
item: [this.frame.getId()],
|
|
44288
|
-
x,
|
|
44289
|
-
y
|
|
44290
|
-
});
|
|
44269
|
+
this.frame.transformation.translateBy(x, y);
|
|
44291
44270
|
}
|
|
44292
44271
|
applyAddChildren(children) {
|
|
44293
44272
|
const childrenIds = children.map((child) => {
|
|
@@ -44355,20 +44334,7 @@ class AddShape extends BoardTool {
|
|
|
44355
44334
|
initTransformation(sx, sy) {
|
|
44356
44335
|
sx = sx || this.bounds.getWidth() / 100;
|
|
44357
44336
|
sy = sy || this.bounds.getHeight() / 100;
|
|
44358
|
-
this.shape.transformation.
|
|
44359
|
-
class: "Transformation",
|
|
44360
|
-
method: "translateTo",
|
|
44361
|
-
item: [this.shape.getId()],
|
|
44362
|
-
x: this.bounds.left,
|
|
44363
|
-
y: this.bounds.top
|
|
44364
|
-
});
|
|
44365
|
-
this.shape.transformation.apply({
|
|
44366
|
-
class: "Transformation",
|
|
44367
|
-
method: "scaleTo",
|
|
44368
|
-
item: [this.shape.getId()],
|
|
44369
|
-
x: sx,
|
|
44370
|
-
y: sy
|
|
44371
|
-
});
|
|
44337
|
+
this.shape.transformation.setLocal(this.bounds.left, this.bounds.top, sx, sy);
|
|
44372
44338
|
}
|
|
44373
44339
|
leftButtonDown() {
|
|
44374
44340
|
if (this.type === "None") {
|
|
@@ -44903,7 +44869,7 @@ class ExportSnapshot extends Tool {
|
|
|
44903
44869
|
}
|
|
44904
44870
|
rectMoveTo(x, y) {
|
|
44905
44871
|
this.transformation.translateTo(x, y);
|
|
44906
|
-
this.mbr.transform(this.transformation.
|
|
44872
|
+
this.mbr.transform(this.transformation.toMatrix());
|
|
44907
44873
|
this.board.tools.publish();
|
|
44908
44874
|
}
|
|
44909
44875
|
resize() {
|
|
@@ -47094,20 +47060,7 @@ class ShapeTool extends CustomTool {
|
|
|
47094
47060
|
initTransformation(sx, sy) {
|
|
47095
47061
|
sx = sx || this.bounds.getWidth() / 100;
|
|
47096
47062
|
sy = sy || this.bounds.getHeight() / 100;
|
|
47097
|
-
this.item.transformation.
|
|
47098
|
-
class: "Transformation",
|
|
47099
|
-
method: "translateTo",
|
|
47100
|
-
item: [this.item.getId()],
|
|
47101
|
-
x: this.bounds.left,
|
|
47102
|
-
y: this.bounds.top
|
|
47103
|
-
});
|
|
47104
|
-
this.item.transformation.apply({
|
|
47105
|
-
class: "Transformation",
|
|
47106
|
-
method: "scaleTo",
|
|
47107
|
-
item: [this.item.getId()],
|
|
47108
|
-
x: sx,
|
|
47109
|
-
y: sy
|
|
47110
|
-
});
|
|
47063
|
+
this.item.transformation.setLocal(this.bounds.left, this.bounds.top, sx, sy);
|
|
47111
47064
|
}
|
|
47112
47065
|
pointerDown() {
|
|
47113
47066
|
this.isDown = true;
|
|
@@ -47178,22 +47131,10 @@ class StickerTool extends CustomTool {
|
|
|
47178
47131
|
}
|
|
47179
47132
|
pointerDown() {
|
|
47180
47133
|
const point5 = this.board.pointer.point;
|
|
47181
|
-
this.item.transformation.
|
|
47182
|
-
class: "Transformation",
|
|
47183
|
-
method: "translateTo",
|
|
47184
|
-
item: [this.item.getId()],
|
|
47185
|
-
x: point5.x - this.settings.width / 2,
|
|
47186
|
-
y: point5.y - this.settings.height / 2
|
|
47187
|
-
});
|
|
47134
|
+
this.item.transformation.setLocal(point5.x - this.settings.width / 2, point5.y - this.settings.height / 2);
|
|
47188
47135
|
const width2 = this.item.getWidth();
|
|
47189
47136
|
const height3 = this.item.getHeight();
|
|
47190
|
-
this.item.transformation.
|
|
47191
|
-
class: "Transformation",
|
|
47192
|
-
method: "scaleBy",
|
|
47193
|
-
item: [this.item.getId()],
|
|
47194
|
-
x: width2 / this.settings.width,
|
|
47195
|
-
y: height3 / this.settings.height
|
|
47196
|
-
});
|
|
47137
|
+
this.item.transformation.scaleBy(width2 / this.settings.width, height3 / this.settings.height);
|
|
47197
47138
|
const addedItem = this.board.add(this.item);
|
|
47198
47139
|
this.board.selection.removeAll();
|
|
47199
47140
|
this.board.selection.add(addedItem);
|
|
@@ -47811,7 +47752,7 @@ class Star2 extends BaseItem {
|
|
|
47811
47752
|
}
|
|
47812
47753
|
transformPath() {
|
|
47813
47754
|
this.path = starPath.copy();
|
|
47814
|
-
this.path.transform(this.transformation.
|
|
47755
|
+
this.path.transform(this.transformation.toMatrix());
|
|
47815
47756
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
47816
47757
|
this.path.setBorderColor(this.borderColor);
|
|
47817
47758
|
this.path.setBorderWidth(this.borderWidth);
|
|
@@ -47839,7 +47780,7 @@ class Star2 extends BaseItem {
|
|
|
47839
47780
|
}
|
|
47840
47781
|
renderHTML(documentFactory) {
|
|
47841
47782
|
const div = documentFactory.createElement("star-item");
|
|
47842
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
47783
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
47843
47784
|
const mbr = this.getMbr();
|
|
47844
47785
|
const unscaledWidth = mbr.getWidth() / scaleX;
|
|
47845
47786
|
const unscaledHeight = mbr.getHeight() / scaleY;
|
|
@@ -47926,13 +47867,7 @@ class AddCounter extends StickerTool {
|
|
|
47926
47867
|
const x = (left + right) / 2 - COUNTER_DIMENSIONS.width / 2;
|
|
47927
47868
|
const y = (top + bottom) / 2 - COUNTER_DIMENSIONS.height / 2;
|
|
47928
47869
|
const counter2 = new Counter(this.board, "");
|
|
47929
|
-
counter2.transformation.
|
|
47930
|
-
class: "Transformation",
|
|
47931
|
-
method: "translateTo",
|
|
47932
|
-
item: [counter2.getId()],
|
|
47933
|
-
x,
|
|
47934
|
-
y
|
|
47935
|
-
});
|
|
47870
|
+
counter2.transformation.setLocal(x, y);
|
|
47936
47871
|
const addedCounter = this.board.add(counter2);
|
|
47937
47872
|
this.board.selection.add(addedCounter);
|
|
47938
47873
|
}
|
|
@@ -47972,7 +47907,7 @@ class Counter extends BaseItem {
|
|
|
47972
47907
|
}
|
|
47973
47908
|
}
|
|
47974
47909
|
updateMbr() {
|
|
47975
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
47910
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
47976
47911
|
this.left = translateX;
|
|
47977
47912
|
this.top = translateY;
|
|
47978
47913
|
this.right = this.left + COUNTER_DIMENSIONS.width * scaleX;
|
|
@@ -48169,7 +48104,7 @@ class Card extends BaseItem {
|
|
|
48169
48104
|
}
|
|
48170
48105
|
renderHTML(documentFactory) {
|
|
48171
48106
|
const div = super.renderHTML(documentFactory);
|
|
48172
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
48107
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
48173
48108
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
48174
48109
|
div.style.backgroundImage = `url(${this.imageToRender?.src || this.backsideUrl})`;
|
|
48175
48110
|
div.id = this.getId();
|
|
@@ -48183,7 +48118,7 @@ class Card extends BaseItem {
|
|
|
48183
48118
|
return div;
|
|
48184
48119
|
}
|
|
48185
48120
|
updateMbr() {
|
|
48186
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
48121
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
48187
48122
|
const rotation = this.transformation.getRotation();
|
|
48188
48123
|
const height3 = this.dimensions.height * scaleY;
|
|
48189
48124
|
const width2 = this.dimensions.width * scaleX;
|
|
@@ -48334,24 +48269,12 @@ class Deck extends BaseItem {
|
|
|
48334
48269
|
const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular()) && (!firstCardDimensions || firstCardDimensions.width === foundItem.getDimensions().width && firstCardDimensions.height === foundItem.getDimensions().height);
|
|
48335
48270
|
if (canAddItem) {
|
|
48336
48271
|
this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
|
|
48337
|
-
foundItem.transformation.
|
|
48338
|
-
class: "Transformation",
|
|
48339
|
-
method: "translateTo",
|
|
48340
|
-
item: [this.id],
|
|
48341
|
-
x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
|
|
48342
|
-
y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
|
|
48343
|
-
});
|
|
48272
|
+
foundItem.transformation.setLocal(this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET), this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0));
|
|
48344
48273
|
if (firstCard) {
|
|
48345
|
-
const { scaleX, scaleY } = foundItem.transformation.
|
|
48346
|
-
const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.
|
|
48274
|
+
const { scaleX, scaleY } = foundItem.transformation.getMatrixData();
|
|
48275
|
+
const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.getMatrixData();
|
|
48347
48276
|
if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
|
|
48348
|
-
foundItem.transformation.
|
|
48349
|
-
class: "Transformation",
|
|
48350
|
-
method: "scaleTo",
|
|
48351
|
-
item: [this.id],
|
|
48352
|
-
x: targetScaleX,
|
|
48353
|
-
y: targetScaleY
|
|
48354
|
-
});
|
|
48277
|
+
foundItem.transformation.setLocal({ scaleX: targetScaleX, scaleY: targetScaleY });
|
|
48355
48278
|
}
|
|
48356
48279
|
}
|
|
48357
48280
|
this.board.selection.remove(foundItem);
|
|
@@ -48453,7 +48376,7 @@ class Deck extends BaseItem {
|
|
|
48453
48376
|
this.subject.publish(this);
|
|
48454
48377
|
}
|
|
48455
48378
|
updateMbr() {
|
|
48456
|
-
const { translateX, translateY } = this.transformation.
|
|
48379
|
+
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
48457
48380
|
const items = this.index.list();
|
|
48458
48381
|
const itemsMbr = items[0]?.getMbr().combine(items.slice(1).map((item) => item.getMbr()));
|
|
48459
48382
|
this.left = translateX;
|
|
@@ -48527,7 +48450,7 @@ class Deck extends BaseItem {
|
|
|
48527
48450
|
if (!topCard) {
|
|
48528
48451
|
return div;
|
|
48529
48452
|
}
|
|
48530
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
48453
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
48531
48454
|
const transform = `translate(${translateX}px, ${translateY}px) scale(1, 1)`;
|
|
48532
48455
|
const topCardElement = topCard.renderHTML(documentFactory);
|
|
48533
48456
|
div.appendChild(topCardElement);
|
|
@@ -48682,13 +48605,7 @@ function createDeck(event, board) {
|
|
|
48682
48605
|
const onlyCards = board.selection.items.isAllItemsType("Card");
|
|
48683
48606
|
if (onlyCards) {
|
|
48684
48607
|
const deck = new Deck(board, "");
|
|
48685
|
-
deck.transformation.
|
|
48686
|
-
class: "Transformation",
|
|
48687
|
-
method: "translateTo",
|
|
48688
|
-
item: [deck.getId()],
|
|
48689
|
-
x: cardsOrDecks[cardsOrDecks.length - 1].left,
|
|
48690
|
-
y: cardsOrDecks[cardsOrDecks.length - 1].top
|
|
48691
|
-
});
|
|
48608
|
+
deck.transformation.setLocal(cardsOrDecks[cardsOrDecks.length - 1].left, cardsOrDecks[cardsOrDecks.length - 1].top);
|
|
48692
48609
|
const addedDeck = board.add(deck);
|
|
48693
48610
|
board.selection.items.removeAll();
|
|
48694
48611
|
addedDeck.addChildItems(cardsOrDecks);
|
|
@@ -48775,7 +48692,7 @@ class Dice extends BaseItem {
|
|
|
48775
48692
|
}
|
|
48776
48693
|
transformPath() {
|
|
48777
48694
|
this.path = createRoundedRectanglePath(this).copy();
|
|
48778
|
-
this.path.transform(this.transformation.
|
|
48695
|
+
this.path.transform(this.transformation.toMatrix());
|
|
48779
48696
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
48780
48697
|
this.path.setBorderColor(this.borderColor);
|
|
48781
48698
|
this.path.setBorderWidth(this.borderWidth);
|
|
@@ -48997,7 +48914,7 @@ class Dice extends BaseItem {
|
|
|
48997
48914
|
}
|
|
48998
48915
|
renderHTML(documentFactory) {
|
|
48999
48916
|
const div = super.renderHTML(documentFactory);
|
|
49000
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
48917
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
49001
48918
|
const mbr = this.getMbr();
|
|
49002
48919
|
const width2 = mbr.getWidth();
|
|
49003
48920
|
const height3 = mbr.getHeight();
|
|
@@ -49248,7 +49165,7 @@ class Screen extends BaseItem {
|
|
|
49248
49165
|
}
|
|
49249
49166
|
transformPath() {
|
|
49250
49167
|
this.path = screenPath.copy();
|
|
49251
|
-
this.path.transform(this.transformation.
|
|
49168
|
+
this.path.transform(this.transformation.toMatrix());
|
|
49252
49169
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
49253
49170
|
this.path.setBorderColor(this.borderColor);
|
|
49254
49171
|
this.path.setBorderWidth(this.borderWidth);
|
|
@@ -51864,8 +51781,8 @@ function handleMultipleItemsResize({
|
|
|
51864
51781
|
let itemX = item.getMbr().left;
|
|
51865
51782
|
let itemY = item.getMbr().top;
|
|
51866
51783
|
if (item.itemType === "Drawing") {
|
|
51867
|
-
itemX = item.transformation.
|
|
51868
|
-
itemY = item.transformation.
|
|
51784
|
+
itemX = item.transformation.getMatrixData().translateX;
|
|
51785
|
+
itemY = item.transformation.getMatrixData().translateY;
|
|
51869
51786
|
}
|
|
51870
51787
|
const deltaX = itemX - initMbr.left;
|
|
51871
51788
|
const translateX = deltaX * matrix.scaleX - deltaX + matrix.translateX;
|