microboard-temp 0.13.5 → 0.13.7
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 +52 -30
- package/dist/cjs/index.js +52 -30
- package/dist/cjs/node.js +52 -30
- package/dist/esm/browser.js +52 -30
- package/dist/esm/index.js +52 -30
- package/dist/esm/node.js +52 -30
- package/dist/types/Gravity/GravityEngine.d.ts +0 -6
- package/dist/types/Items/RichText/RichText.d.ts +2 -0
- package/dist/types/Settings.d.ts +6 -0
- package/package.json +1 -1
package/dist/cjs/node.js
CHANGED
|
@@ -5711,7 +5711,13 @@ var conf = {
|
|
|
5711
5711
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
5712
5712
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
5713
5713
|
MAX_CARD_SIZE: 500,
|
|
5714
|
-
CONNECTOR_ITEM_OFFSET: 20
|
|
5714
|
+
CONNECTOR_ITEM_OFFSET: 20,
|
|
5715
|
+
GRAVITY_G: 80,
|
|
5716
|
+
GRAVITY_G_CENTER: 120,
|
|
5717
|
+
GRAVITY_DAMPING: 0.96,
|
|
5718
|
+
GRAVITY_RESTITUTION: 0.5,
|
|
5719
|
+
GRAVITY_REPULSION: 200,
|
|
5720
|
+
GRAVITY_MAX_DISTANCE: 3000
|
|
5715
5721
|
};
|
|
5716
5722
|
initDefaultI18N();
|
|
5717
5723
|
|
|
@@ -24674,6 +24680,7 @@ class RichText extends BaseItem {
|
|
|
24674
24680
|
autoSizeScale = 1;
|
|
24675
24681
|
containerMaxWidth;
|
|
24676
24682
|
linkTo;
|
|
24683
|
+
localArea;
|
|
24677
24684
|
maxHeight;
|
|
24678
24685
|
selection;
|
|
24679
24686
|
transformationRenderBlock = undefined;
|
|
@@ -24695,6 +24702,7 @@ class RichText extends BaseItem {
|
|
|
24695
24702
|
this.autoSize = autoSize;
|
|
24696
24703
|
this.insideOf = insideOf;
|
|
24697
24704
|
this.initialTextStyles = initialTextStyles;
|
|
24705
|
+
this.localArea = container.copy();
|
|
24698
24706
|
counter = counter + 1;
|
|
24699
24707
|
this.rtCounter = counter;
|
|
24700
24708
|
this.linkTo = linkTo || new LinkTo(this.id, this.board.events);
|
|
@@ -24847,7 +24855,7 @@ class RichText extends BaseItem {
|
|
|
24847
24855
|
this.layoutNodes.width = this.containerMaxWidth;
|
|
24848
24856
|
}
|
|
24849
24857
|
}
|
|
24850
|
-
this.alignInRectangle(this.
|
|
24858
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
24851
24859
|
this.transformCanvas();
|
|
24852
24860
|
this.subject.publish(this);
|
|
24853
24861
|
this.updateRequired = false;
|
|
@@ -24927,7 +24935,7 @@ class RichText extends BaseItem {
|
|
|
24927
24935
|
this.right = transformed.right;
|
|
24928
24936
|
this.bottom = transformed.bottom;
|
|
24929
24937
|
} else {
|
|
24930
|
-
this.alignInRectangle(this.
|
|
24938
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
24931
24939
|
}
|
|
24932
24940
|
this.setClipPath();
|
|
24933
24941
|
if (!this.isInShape && !this.autoSize) {
|
|
@@ -24955,16 +24963,16 @@ class RichText extends BaseItem {
|
|
|
24955
24963
|
}
|
|
24956
24964
|
}
|
|
24957
24965
|
setClipPath() {
|
|
24958
|
-
const
|
|
24959
|
-
const
|
|
24960
|
-
const height = container.getHeight();
|
|
24966
|
+
const width = this.localArea.getWidth();
|
|
24967
|
+
const height = this.localArea.getHeight();
|
|
24961
24968
|
this.clipPath = new conf.path2DFactory;
|
|
24962
24969
|
this.clipPath.rect(0, 0, width, height);
|
|
24963
24970
|
}
|
|
24964
24971
|
setContainer(container) {
|
|
24965
24972
|
this.isContainerSet = true;
|
|
24973
|
+
this.localArea = container.copy();
|
|
24966
24974
|
this.container = container;
|
|
24967
|
-
this.
|
|
24975
|
+
this.updateElement();
|
|
24968
24976
|
}
|
|
24969
24977
|
applyMaxWidth(maxWidth) {
|
|
24970
24978
|
const shouldNotShrink = this.insideOf !== "RichText" && this.insideOf !== "AINode" && this.containerMaxWidth && this.shrinkWidth;
|
|
@@ -24987,8 +24995,8 @@ class RichText extends BaseItem {
|
|
|
24987
24995
|
matrix = this.transformation.toMatrix();
|
|
24988
24996
|
}
|
|
24989
24997
|
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
24990
|
-
const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
|
|
24991
|
-
return this.
|
|
24998
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
24999
|
+
return this.localArea.getTransformed(scaledMatrix);
|
|
24992
25000
|
}
|
|
24993
25001
|
emitWithoutApplying = (op) => {
|
|
24994
25002
|
if (this.board.events) {
|
|
@@ -25330,7 +25338,7 @@ class RichText extends BaseItem {
|
|
|
25330
25338
|
if (typeof document !== "undefined") {
|
|
25331
25339
|
document.fonts.ready.then(() => {
|
|
25332
25340
|
this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
|
|
25333
|
-
this.alignInRectangle(this.
|
|
25341
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
25334
25342
|
this.transformCanvas();
|
|
25335
25343
|
});
|
|
25336
25344
|
}
|
|
@@ -25360,7 +25368,7 @@ class RichText extends BaseItem {
|
|
|
25360
25368
|
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
25361
25369
|
context.matrix = scaledMatrix;
|
|
25362
25370
|
context.applyChanges();
|
|
25363
|
-
ctx.translate(this.
|
|
25371
|
+
ctx.translate(this.left, this.top);
|
|
25364
25372
|
const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
|
|
25365
25373
|
if (shouldClip) {
|
|
25366
25374
|
ctx.clip(this.clipPath.nativePath);
|
|
@@ -25501,7 +25509,7 @@ class RichText extends BaseItem {
|
|
|
25501
25509
|
}
|
|
25502
25510
|
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
25503
25511
|
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
25504
|
-
const transform = `translate(${scaledMatrix.translateX + this.
|
|
25512
|
+
const transform = `translate(${scaledMatrix.translateX + this.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
|
|
25505
25513
|
const transformedWidth = this.getMbr().getWidth();
|
|
25506
25514
|
const transformedHeight = this.getMbr().getHeight();
|
|
25507
25515
|
const div = documentFactory.createElement("rich-text");
|
|
@@ -25597,6 +25605,19 @@ class RichText extends BaseItem {
|
|
|
25597
25605
|
getPrevMbr() {
|
|
25598
25606
|
return this.prevMbr;
|
|
25599
25607
|
}
|
|
25608
|
+
getMbr() {
|
|
25609
|
+
const cameraScale = this.board.camera.getScale();
|
|
25610
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
25611
|
+
let matrix;
|
|
25612
|
+
if (this.customTransformationMatrix) {
|
|
25613
|
+
matrix = this.customTransformationMatrix();
|
|
25614
|
+
} else {
|
|
25615
|
+
matrix = this.transformation.toMatrix();
|
|
25616
|
+
}
|
|
25617
|
+
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
25618
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
25619
|
+
return new Mbr(this.left, this.top, this.right, this.bottom).getTransformed(scaledMatrix);
|
|
25620
|
+
}
|
|
25600
25621
|
}
|
|
25601
25622
|
|
|
25602
25623
|
// src/Items/Mbr/updateRects.ts
|
|
@@ -43497,6 +43518,8 @@ class DefaultFrameData {
|
|
|
43497
43518
|
|
|
43498
43519
|
// src/Items/Frame/Frame.ts
|
|
43499
43520
|
var defaultFrameData = new DefaultFrameData;
|
|
43521
|
+
var HEADING_TOP_OFFSET = -45;
|
|
43522
|
+
var HEADING_BOTTOM_OFFSET = -12;
|
|
43500
43523
|
|
|
43501
43524
|
class Frame2 extends BaseItem {
|
|
43502
43525
|
getItemById;
|
|
@@ -43534,14 +43557,14 @@ class Frame2 extends BaseItem {
|
|
|
43534
43557
|
this.borderStyle = borderStyle;
|
|
43535
43558
|
this.borderWidth = borderWidth;
|
|
43536
43559
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
43560
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
43561
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
43537
43562
|
this.path = Frames[this.shapeType].path.copy();
|
|
43538
43563
|
this.transformation = new Transformation(this.id, board.events);
|
|
43539
43564
|
this.linkTo = new LinkTo(this.id, board.events);
|
|
43540
43565
|
this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
|
|
43541
43566
|
this.text.editor.verticalAlignment = "bottom";
|
|
43542
43567
|
this.text.setSelectionHorisontalAlignment("left");
|
|
43543
|
-
this.textContainer.top = -45;
|
|
43544
|
-
this.textContainer.bottom = -12;
|
|
43545
43568
|
this.text.customTransformationMatrix = () => {
|
|
43546
43569
|
const matrix = this.transformation.toMatrix();
|
|
43547
43570
|
return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
|
|
@@ -43574,6 +43597,8 @@ class Frame2 extends BaseItem {
|
|
|
43574
43597
|
initPath() {
|
|
43575
43598
|
this.path = Frames[this.shapeType].path.copy();
|
|
43576
43599
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
43600
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
43601
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
43577
43602
|
this.text.setContainer(this.textContainer.copy());
|
|
43578
43603
|
this.text.updateElement();
|
|
43579
43604
|
}
|
|
@@ -43718,6 +43743,9 @@ class Frame2 extends BaseItem {
|
|
|
43718
43743
|
}
|
|
43719
43744
|
if (data.text) {
|
|
43720
43745
|
this.text.deserialize(data.text);
|
|
43746
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
43747
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
43748
|
+
this.text.setContainer(this.textContainer.copy());
|
|
43721
43749
|
}
|
|
43722
43750
|
this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
|
|
43723
43751
|
this.subject.publish(this);
|
|
@@ -56821,14 +56849,8 @@ class GravityEngine {
|
|
|
56821
56849
|
tickTimer = null;
|
|
56822
56850
|
syncTimer = null;
|
|
56823
56851
|
lastSyncedPositions = new Map;
|
|
56824
|
-
G = 80;
|
|
56825
|
-
G_CENTER = 120;
|
|
56826
|
-
DAMPING = 0.96;
|
|
56827
|
-
RESTITUTION = 0.5;
|
|
56828
|
-
REPULSION = 200;
|
|
56829
56852
|
TICK_MS = 33;
|
|
56830
56853
|
SYNC_MS = 300;
|
|
56831
|
-
MAX_DISTANCE = 3000;
|
|
56832
56854
|
SOFTENING_SQ = 50 * 50;
|
|
56833
56855
|
MIN_MOVE_PX = 0.1;
|
|
56834
56856
|
constructor(board) {
|
|
@@ -56897,8 +56919,8 @@ class GravityEngine {
|
|
|
56897
56919
|
const dcx = centerX - s1.cx;
|
|
56898
56920
|
const dcy = centerY - s1.cy;
|
|
56899
56921
|
const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
|
|
56900
|
-
ax +=
|
|
56901
|
-
ay +=
|
|
56922
|
+
ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
|
|
56923
|
+
ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
|
|
56902
56924
|
for (let j = 0;j < snap.length; j++) {
|
|
56903
56925
|
if (i === j)
|
|
56904
56926
|
continue;
|
|
@@ -56906,7 +56928,7 @@ class GravityEngine {
|
|
|
56906
56928
|
const dx = s2.cx - s1.cx;
|
|
56907
56929
|
const dy = s2.cy - s1.cy;
|
|
56908
56930
|
const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
|
|
56909
|
-
if (dist >
|
|
56931
|
+
if (dist > conf.GRAVITY_MAX_DISTANCE)
|
|
56910
56932
|
continue;
|
|
56911
56933
|
const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
|
|
56912
56934
|
if (overlapping) {
|
|
@@ -56915,26 +56937,26 @@ class GravityEngine {
|
|
|
56915
56937
|
if (overlapX < overlapY) {
|
|
56916
56938
|
const sign = s1.cx < s2.cx ? -1 : 1;
|
|
56917
56939
|
if (sign * vel.vx < 0)
|
|
56918
|
-
vel.vx = -vel.vx *
|
|
56919
|
-
ax += sign *
|
|
56940
|
+
vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
|
|
56941
|
+
ax += sign * conf.GRAVITY_REPULSION * overlapX;
|
|
56920
56942
|
} else {
|
|
56921
56943
|
const sign = s1.cy < s2.cy ? -1 : 1;
|
|
56922
56944
|
if (sign * vel.vy < 0)
|
|
56923
|
-
vel.vy = -vel.vy *
|
|
56924
|
-
ay += sign *
|
|
56945
|
+
vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
|
|
56946
|
+
ay += sign * conf.GRAVITY_REPULSION * overlapY;
|
|
56925
56947
|
}
|
|
56926
56948
|
} else {
|
|
56927
56949
|
const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
|
|
56928
56950
|
if (dist < touchDist + 5)
|
|
56929
56951
|
continue;
|
|
56930
56952
|
const distSq = dx * dx + dy * dy;
|
|
56931
|
-
const gravAcc =
|
|
56953
|
+
const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
|
|
56932
56954
|
ax += gravAcc * dx / dist;
|
|
56933
56955
|
ay += gravAcc * dy / dist;
|
|
56934
56956
|
}
|
|
56935
56957
|
}
|
|
56936
|
-
vel.vx = (vel.vx + ax * dt) *
|
|
56937
|
-
vel.vy = (vel.vy + ay * dt) *
|
|
56958
|
+
vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
|
|
56959
|
+
vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
|
|
56938
56960
|
const moveX = vel.vx * dt;
|
|
56939
56961
|
const moveY = vel.vy * dt;
|
|
56940
56962
|
if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
|
package/dist/esm/browser.js
CHANGED
|
@@ -4494,7 +4494,13 @@ var conf = {
|
|
|
4494
4494
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
4495
4495
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
4496
4496
|
MAX_CARD_SIZE: 500,
|
|
4497
|
-
CONNECTOR_ITEM_OFFSET: 20
|
|
4497
|
+
CONNECTOR_ITEM_OFFSET: 20,
|
|
4498
|
+
GRAVITY_G: 80,
|
|
4499
|
+
GRAVITY_G_CENTER: 120,
|
|
4500
|
+
GRAVITY_DAMPING: 0.96,
|
|
4501
|
+
GRAVITY_RESTITUTION: 0.5,
|
|
4502
|
+
GRAVITY_REPULSION: 200,
|
|
4503
|
+
GRAVITY_MAX_DISTANCE: 3000
|
|
4498
4504
|
};
|
|
4499
4505
|
initDefaultI18N();
|
|
4500
4506
|
|
|
@@ -22031,6 +22037,7 @@ class RichText extends BaseItem {
|
|
|
22031
22037
|
autoSizeScale = 1;
|
|
22032
22038
|
containerMaxWidth;
|
|
22033
22039
|
linkTo;
|
|
22040
|
+
localArea;
|
|
22034
22041
|
maxHeight;
|
|
22035
22042
|
selection;
|
|
22036
22043
|
transformationRenderBlock = undefined;
|
|
@@ -22052,6 +22059,7 @@ class RichText extends BaseItem {
|
|
|
22052
22059
|
this.autoSize = autoSize;
|
|
22053
22060
|
this.insideOf = insideOf;
|
|
22054
22061
|
this.initialTextStyles = initialTextStyles;
|
|
22062
|
+
this.localArea = container.copy();
|
|
22055
22063
|
counter = counter + 1;
|
|
22056
22064
|
this.rtCounter = counter;
|
|
22057
22065
|
this.linkTo = linkTo || new LinkTo(this.id, this.board.events);
|
|
@@ -22204,7 +22212,7 @@ class RichText extends BaseItem {
|
|
|
22204
22212
|
this.layoutNodes.width = this.containerMaxWidth;
|
|
22205
22213
|
}
|
|
22206
22214
|
}
|
|
22207
|
-
this.alignInRectangle(this.
|
|
22215
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
22208
22216
|
this.transformCanvas();
|
|
22209
22217
|
this.subject.publish(this);
|
|
22210
22218
|
this.updateRequired = false;
|
|
@@ -22284,7 +22292,7 @@ class RichText extends BaseItem {
|
|
|
22284
22292
|
this.right = transformed.right;
|
|
22285
22293
|
this.bottom = transformed.bottom;
|
|
22286
22294
|
} else {
|
|
22287
|
-
this.alignInRectangle(this.
|
|
22295
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
22288
22296
|
}
|
|
22289
22297
|
this.setClipPath();
|
|
22290
22298
|
if (!this.isInShape && !this.autoSize) {
|
|
@@ -22312,16 +22320,16 @@ class RichText extends BaseItem {
|
|
|
22312
22320
|
}
|
|
22313
22321
|
}
|
|
22314
22322
|
setClipPath() {
|
|
22315
|
-
const
|
|
22316
|
-
const
|
|
22317
|
-
const height = container.getHeight();
|
|
22323
|
+
const width = this.localArea.getWidth();
|
|
22324
|
+
const height = this.localArea.getHeight();
|
|
22318
22325
|
this.clipPath = new conf.path2DFactory;
|
|
22319
22326
|
this.clipPath.rect(0, 0, width, height);
|
|
22320
22327
|
}
|
|
22321
22328
|
setContainer(container) {
|
|
22322
22329
|
this.isContainerSet = true;
|
|
22330
|
+
this.localArea = container.copy();
|
|
22323
22331
|
this.container = container;
|
|
22324
|
-
this.
|
|
22332
|
+
this.updateElement();
|
|
22325
22333
|
}
|
|
22326
22334
|
applyMaxWidth(maxWidth) {
|
|
22327
22335
|
const shouldNotShrink = this.insideOf !== "RichText" && this.insideOf !== "AINode" && this.containerMaxWidth && this.shrinkWidth;
|
|
@@ -22344,8 +22352,8 @@ class RichText extends BaseItem {
|
|
|
22344
22352
|
matrix = this.transformation.toMatrix();
|
|
22345
22353
|
}
|
|
22346
22354
|
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
22347
|
-
const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
|
|
22348
|
-
return this.
|
|
22355
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
22356
|
+
return this.localArea.getTransformed(scaledMatrix);
|
|
22349
22357
|
}
|
|
22350
22358
|
emitWithoutApplying = (op) => {
|
|
22351
22359
|
if (this.board.events) {
|
|
@@ -22687,7 +22695,7 @@ class RichText extends BaseItem {
|
|
|
22687
22695
|
if (typeof document !== "undefined") {
|
|
22688
22696
|
document.fonts.ready.then(() => {
|
|
22689
22697
|
this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
|
|
22690
|
-
this.alignInRectangle(this.
|
|
22698
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
22691
22699
|
this.transformCanvas();
|
|
22692
22700
|
});
|
|
22693
22701
|
}
|
|
@@ -22717,7 +22725,7 @@ class RichText extends BaseItem {
|
|
|
22717
22725
|
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
22718
22726
|
context.matrix = scaledMatrix;
|
|
22719
22727
|
context.applyChanges();
|
|
22720
|
-
ctx.translate(this.
|
|
22728
|
+
ctx.translate(this.left, this.top);
|
|
22721
22729
|
const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
|
|
22722
22730
|
if (shouldClip) {
|
|
22723
22731
|
ctx.clip(this.clipPath.nativePath);
|
|
@@ -22858,7 +22866,7 @@ class RichText extends BaseItem {
|
|
|
22858
22866
|
}
|
|
22859
22867
|
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
22860
22868
|
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
22861
|
-
const transform = `translate(${scaledMatrix.translateX + this.
|
|
22869
|
+
const transform = `translate(${scaledMatrix.translateX + this.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
|
|
22862
22870
|
const transformedWidth = this.getMbr().getWidth();
|
|
22863
22871
|
const transformedHeight = this.getMbr().getHeight();
|
|
22864
22872
|
const div = documentFactory.createElement("rich-text");
|
|
@@ -22954,6 +22962,19 @@ class RichText extends BaseItem {
|
|
|
22954
22962
|
getPrevMbr() {
|
|
22955
22963
|
return this.prevMbr;
|
|
22956
22964
|
}
|
|
22965
|
+
getMbr() {
|
|
22966
|
+
const cameraScale = this.board.camera.getScale();
|
|
22967
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
22968
|
+
let matrix;
|
|
22969
|
+
if (this.customTransformationMatrix) {
|
|
22970
|
+
matrix = this.customTransformationMatrix();
|
|
22971
|
+
} else {
|
|
22972
|
+
matrix = this.transformation.toMatrix();
|
|
22973
|
+
}
|
|
22974
|
+
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
22975
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
22976
|
+
return new Mbr(this.left, this.top, this.right, this.bottom).getTransformed(scaledMatrix);
|
|
22977
|
+
}
|
|
22957
22978
|
}
|
|
22958
22979
|
|
|
22959
22980
|
// src/Items/Mbr/updateRects.ts
|
|
@@ -40853,6 +40874,8 @@ class DefaultFrameData {
|
|
|
40853
40874
|
|
|
40854
40875
|
// src/Items/Frame/Frame.ts
|
|
40855
40876
|
var defaultFrameData = new DefaultFrameData;
|
|
40877
|
+
var HEADING_TOP_OFFSET = -45;
|
|
40878
|
+
var HEADING_BOTTOM_OFFSET = -12;
|
|
40856
40879
|
|
|
40857
40880
|
class Frame2 extends BaseItem {
|
|
40858
40881
|
getItemById;
|
|
@@ -40890,14 +40913,14 @@ class Frame2 extends BaseItem {
|
|
|
40890
40913
|
this.borderStyle = borderStyle;
|
|
40891
40914
|
this.borderWidth = borderWidth;
|
|
40892
40915
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
40916
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
40917
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
40893
40918
|
this.path = Frames[this.shapeType].path.copy();
|
|
40894
40919
|
this.transformation = new Transformation(this.id, board.events);
|
|
40895
40920
|
this.linkTo = new LinkTo(this.id, board.events);
|
|
40896
40921
|
this.text = new RichText(board, this.textContainer, this.id, this.transformation, this.linkTo, this.name, true, false, "Frame", { ...conf.DEFAULT_TEXT_STYLES, fontSize: 18, fontColor: FRAME_TITLE_COLOR });
|
|
40897
40922
|
this.text.editor.verticalAlignment = "bottom";
|
|
40898
40923
|
this.text.setSelectionHorisontalAlignment("left");
|
|
40899
|
-
this.textContainer.top = -45;
|
|
40900
|
-
this.textContainer.bottom = -12;
|
|
40901
40924
|
this.text.customTransformationMatrix = () => {
|
|
40902
40925
|
const matrix = this.transformation.toMatrix();
|
|
40903
40926
|
return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
|
|
@@ -40930,6 +40953,8 @@ class Frame2 extends BaseItem {
|
|
|
40930
40953
|
initPath() {
|
|
40931
40954
|
this.path = Frames[this.shapeType].path.copy();
|
|
40932
40955
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
40956
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
40957
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
40933
40958
|
this.text.setContainer(this.textContainer.copy());
|
|
40934
40959
|
this.text.updateElement();
|
|
40935
40960
|
}
|
|
@@ -41074,6 +41099,9 @@ class Frame2 extends BaseItem {
|
|
|
41074
41099
|
}
|
|
41075
41100
|
if (data.text) {
|
|
41076
41101
|
this.text.deserialize(data.text);
|
|
41102
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
41103
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
41104
|
+
this.text.setContainer(this.textContainer.copy());
|
|
41077
41105
|
}
|
|
41078
41106
|
this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
|
|
41079
41107
|
this.subject.publish(this);
|
|
@@ -54177,14 +54205,8 @@ class GravityEngine {
|
|
|
54177
54205
|
tickTimer = null;
|
|
54178
54206
|
syncTimer = null;
|
|
54179
54207
|
lastSyncedPositions = new Map;
|
|
54180
|
-
G = 80;
|
|
54181
|
-
G_CENTER = 120;
|
|
54182
|
-
DAMPING = 0.96;
|
|
54183
|
-
RESTITUTION = 0.5;
|
|
54184
|
-
REPULSION = 200;
|
|
54185
54208
|
TICK_MS = 33;
|
|
54186
54209
|
SYNC_MS = 300;
|
|
54187
|
-
MAX_DISTANCE = 3000;
|
|
54188
54210
|
SOFTENING_SQ = 50 * 50;
|
|
54189
54211
|
MIN_MOVE_PX = 0.1;
|
|
54190
54212
|
constructor(board) {
|
|
@@ -54253,8 +54275,8 @@ class GravityEngine {
|
|
|
54253
54275
|
const dcx = centerX - s1.cx;
|
|
54254
54276
|
const dcy = centerY - s1.cy;
|
|
54255
54277
|
const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
|
|
54256
|
-
ax +=
|
|
54257
|
-
ay +=
|
|
54278
|
+
ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
|
|
54279
|
+
ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
|
|
54258
54280
|
for (let j = 0;j < snap.length; j++) {
|
|
54259
54281
|
if (i === j)
|
|
54260
54282
|
continue;
|
|
@@ -54262,7 +54284,7 @@ class GravityEngine {
|
|
|
54262
54284
|
const dx = s2.cx - s1.cx;
|
|
54263
54285
|
const dy = s2.cy - s1.cy;
|
|
54264
54286
|
const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
|
|
54265
|
-
if (dist >
|
|
54287
|
+
if (dist > conf.GRAVITY_MAX_DISTANCE)
|
|
54266
54288
|
continue;
|
|
54267
54289
|
const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
|
|
54268
54290
|
if (overlapping) {
|
|
@@ -54271,26 +54293,26 @@ class GravityEngine {
|
|
|
54271
54293
|
if (overlapX < overlapY) {
|
|
54272
54294
|
const sign = s1.cx < s2.cx ? -1 : 1;
|
|
54273
54295
|
if (sign * vel.vx < 0)
|
|
54274
|
-
vel.vx = -vel.vx *
|
|
54275
|
-
ax += sign *
|
|
54296
|
+
vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
|
|
54297
|
+
ax += sign * conf.GRAVITY_REPULSION * overlapX;
|
|
54276
54298
|
} else {
|
|
54277
54299
|
const sign = s1.cy < s2.cy ? -1 : 1;
|
|
54278
54300
|
if (sign * vel.vy < 0)
|
|
54279
|
-
vel.vy = -vel.vy *
|
|
54280
|
-
ay += sign *
|
|
54301
|
+
vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
|
|
54302
|
+
ay += sign * conf.GRAVITY_REPULSION * overlapY;
|
|
54281
54303
|
}
|
|
54282
54304
|
} else {
|
|
54283
54305
|
const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
|
|
54284
54306
|
if (dist < touchDist + 5)
|
|
54285
54307
|
continue;
|
|
54286
54308
|
const distSq = dx * dx + dy * dy;
|
|
54287
|
-
const gravAcc =
|
|
54309
|
+
const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
|
|
54288
54310
|
ax += gravAcc * dx / dist;
|
|
54289
54311
|
ay += gravAcc * dy / dist;
|
|
54290
54312
|
}
|
|
54291
54313
|
}
|
|
54292
|
-
vel.vx = (vel.vx + ax * dt) *
|
|
54293
|
-
vel.vy = (vel.vy + ay * dt) *
|
|
54314
|
+
vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
|
|
54315
|
+
vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
|
|
54294
54316
|
const moveX = vel.vx * dt;
|
|
54295
54317
|
const moveY = vel.vy * dt;
|
|
54296
54318
|
if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
|