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/esm/index.js
CHANGED
|
@@ -4487,7 +4487,13 @@ var conf = {
|
|
|
4487
4487
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
4488
4488
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
4489
4489
|
MAX_CARD_SIZE: 500,
|
|
4490
|
-
CONNECTOR_ITEM_OFFSET: 20
|
|
4490
|
+
CONNECTOR_ITEM_OFFSET: 20,
|
|
4491
|
+
GRAVITY_G: 80,
|
|
4492
|
+
GRAVITY_G_CENTER: 120,
|
|
4493
|
+
GRAVITY_DAMPING: 0.96,
|
|
4494
|
+
GRAVITY_RESTITUTION: 0.5,
|
|
4495
|
+
GRAVITY_REPULSION: 200,
|
|
4496
|
+
GRAVITY_MAX_DISTANCE: 3000
|
|
4491
4497
|
};
|
|
4492
4498
|
initDefaultI18N();
|
|
4493
4499
|
|
|
@@ -22024,6 +22030,7 @@ class RichText extends BaseItem {
|
|
|
22024
22030
|
autoSizeScale = 1;
|
|
22025
22031
|
containerMaxWidth;
|
|
22026
22032
|
linkTo;
|
|
22033
|
+
localArea;
|
|
22027
22034
|
maxHeight;
|
|
22028
22035
|
selection;
|
|
22029
22036
|
transformationRenderBlock = undefined;
|
|
@@ -22045,6 +22052,7 @@ class RichText extends BaseItem {
|
|
|
22045
22052
|
this.autoSize = autoSize;
|
|
22046
22053
|
this.insideOf = insideOf;
|
|
22047
22054
|
this.initialTextStyles = initialTextStyles;
|
|
22055
|
+
this.localArea = container.copy();
|
|
22048
22056
|
counter = counter + 1;
|
|
22049
22057
|
this.rtCounter = counter;
|
|
22050
22058
|
this.linkTo = linkTo || new LinkTo(this.id, this.board.events);
|
|
@@ -22197,7 +22205,7 @@ class RichText extends BaseItem {
|
|
|
22197
22205
|
this.layoutNodes.width = this.containerMaxWidth;
|
|
22198
22206
|
}
|
|
22199
22207
|
}
|
|
22200
|
-
this.alignInRectangle(this.
|
|
22208
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
22201
22209
|
this.transformCanvas();
|
|
22202
22210
|
this.subject.publish(this);
|
|
22203
22211
|
this.updateRequired = false;
|
|
@@ -22277,7 +22285,7 @@ class RichText extends BaseItem {
|
|
|
22277
22285
|
this.right = transformed.right;
|
|
22278
22286
|
this.bottom = transformed.bottom;
|
|
22279
22287
|
} else {
|
|
22280
|
-
this.alignInRectangle(this.
|
|
22288
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
22281
22289
|
}
|
|
22282
22290
|
this.setClipPath();
|
|
22283
22291
|
if (!this.isInShape && !this.autoSize) {
|
|
@@ -22305,16 +22313,16 @@ class RichText extends BaseItem {
|
|
|
22305
22313
|
}
|
|
22306
22314
|
}
|
|
22307
22315
|
setClipPath() {
|
|
22308
|
-
const
|
|
22309
|
-
const
|
|
22310
|
-
const height = container.getHeight();
|
|
22316
|
+
const width = this.localArea.getWidth();
|
|
22317
|
+
const height = this.localArea.getHeight();
|
|
22311
22318
|
this.clipPath = new conf.path2DFactory;
|
|
22312
22319
|
this.clipPath.rect(0, 0, width, height);
|
|
22313
22320
|
}
|
|
22314
22321
|
setContainer(container) {
|
|
22315
22322
|
this.isContainerSet = true;
|
|
22323
|
+
this.localArea = container.copy();
|
|
22316
22324
|
this.container = container;
|
|
22317
|
-
this.
|
|
22325
|
+
this.updateElement();
|
|
22318
22326
|
}
|
|
22319
22327
|
applyMaxWidth(maxWidth) {
|
|
22320
22328
|
const shouldNotShrink = this.insideOf !== "RichText" && this.insideOf !== "AINode" && this.containerMaxWidth && this.shrinkWidth;
|
|
@@ -22337,8 +22345,8 @@ class RichText extends BaseItem {
|
|
|
22337
22345
|
matrix = this.transformation.toMatrix();
|
|
22338
22346
|
}
|
|
22339
22347
|
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
22340
|
-
const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
|
|
22341
|
-
return this.
|
|
22348
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
22349
|
+
return this.localArea.getTransformed(scaledMatrix);
|
|
22342
22350
|
}
|
|
22343
22351
|
emitWithoutApplying = (op) => {
|
|
22344
22352
|
if (this.board.events) {
|
|
@@ -22680,7 +22688,7 @@ class RichText extends BaseItem {
|
|
|
22680
22688
|
if (typeof document !== "undefined") {
|
|
22681
22689
|
document.fonts.ready.then(() => {
|
|
22682
22690
|
this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
|
|
22683
|
-
this.alignInRectangle(this.
|
|
22691
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
22684
22692
|
this.transformCanvas();
|
|
22685
22693
|
});
|
|
22686
22694
|
}
|
|
@@ -22710,7 +22718,7 @@ class RichText extends BaseItem {
|
|
|
22710
22718
|
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
22711
22719
|
context.matrix = scaledMatrix;
|
|
22712
22720
|
context.applyChanges();
|
|
22713
|
-
ctx.translate(this.
|
|
22721
|
+
ctx.translate(this.left, this.top);
|
|
22714
22722
|
const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
|
|
22715
22723
|
if (shouldClip) {
|
|
22716
22724
|
ctx.clip(this.clipPath.nativePath);
|
|
@@ -22851,7 +22859,7 @@ class RichText extends BaseItem {
|
|
|
22851
22859
|
}
|
|
22852
22860
|
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
22853
22861
|
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
22854
|
-
const transform = `translate(${scaledMatrix.translateX + this.
|
|
22862
|
+
const transform = `translate(${scaledMatrix.translateX + this.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
|
|
22855
22863
|
const transformedWidth = this.getMbr().getWidth();
|
|
22856
22864
|
const transformedHeight = this.getMbr().getHeight();
|
|
22857
22865
|
const div = documentFactory.createElement("rich-text");
|
|
@@ -22947,6 +22955,19 @@ class RichText extends BaseItem {
|
|
|
22947
22955
|
getPrevMbr() {
|
|
22948
22956
|
return this.prevMbr;
|
|
22949
22957
|
}
|
|
22958
|
+
getMbr() {
|
|
22959
|
+
const cameraScale = this.board.camera.getScale();
|
|
22960
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
22961
|
+
let matrix;
|
|
22962
|
+
if (this.customTransformationMatrix) {
|
|
22963
|
+
matrix = this.customTransformationMatrix();
|
|
22964
|
+
} else {
|
|
22965
|
+
matrix = this.transformation.toMatrix();
|
|
22966
|
+
}
|
|
22967
|
+
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
22968
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
22969
|
+
return new Mbr(this.left, this.top, this.right, this.bottom).getTransformed(scaledMatrix);
|
|
22970
|
+
}
|
|
22950
22971
|
}
|
|
22951
22972
|
|
|
22952
22973
|
// src/Items/Mbr/updateRects.ts
|
|
@@ -40846,6 +40867,8 @@ class DefaultFrameData {
|
|
|
40846
40867
|
|
|
40847
40868
|
// src/Items/Frame/Frame.ts
|
|
40848
40869
|
var defaultFrameData = new DefaultFrameData;
|
|
40870
|
+
var HEADING_TOP_OFFSET = -45;
|
|
40871
|
+
var HEADING_BOTTOM_OFFSET = -12;
|
|
40849
40872
|
|
|
40850
40873
|
class Frame2 extends BaseItem {
|
|
40851
40874
|
getItemById;
|
|
@@ -40883,14 +40906,14 @@ class Frame2 extends BaseItem {
|
|
|
40883
40906
|
this.borderStyle = borderStyle;
|
|
40884
40907
|
this.borderWidth = borderWidth;
|
|
40885
40908
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
40909
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
40910
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
40886
40911
|
this.path = Frames[this.shapeType].path.copy();
|
|
40887
40912
|
this.transformation = new Transformation(this.id, board.events);
|
|
40888
40913
|
this.linkTo = new LinkTo(this.id, board.events);
|
|
40889
40914
|
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 });
|
|
40890
40915
|
this.text.editor.verticalAlignment = "bottom";
|
|
40891
40916
|
this.text.setSelectionHorisontalAlignment("left");
|
|
40892
|
-
this.textContainer.top = -45;
|
|
40893
|
-
this.textContainer.bottom = -12;
|
|
40894
40917
|
this.text.customTransformationMatrix = () => {
|
|
40895
40918
|
const matrix = this.transformation.toMatrix();
|
|
40896
40919
|
return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
|
|
@@ -40923,6 +40946,8 @@ class Frame2 extends BaseItem {
|
|
|
40923
40946
|
initPath() {
|
|
40924
40947
|
this.path = Frames[this.shapeType].path.copy();
|
|
40925
40948
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
40949
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
40950
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
40926
40951
|
this.text.setContainer(this.textContainer.copy());
|
|
40927
40952
|
this.text.updateElement();
|
|
40928
40953
|
}
|
|
@@ -41067,6 +41092,9 @@ class Frame2 extends BaseItem {
|
|
|
41067
41092
|
}
|
|
41068
41093
|
if (data.text) {
|
|
41069
41094
|
this.text.deserialize(data.text);
|
|
41095
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
41096
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
41097
|
+
this.text.setContainer(this.textContainer.copy());
|
|
41070
41098
|
}
|
|
41071
41099
|
this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
|
|
41072
41100
|
this.subject.publish(this);
|
|
@@ -54170,14 +54198,8 @@ class GravityEngine {
|
|
|
54170
54198
|
tickTimer = null;
|
|
54171
54199
|
syncTimer = null;
|
|
54172
54200
|
lastSyncedPositions = new Map;
|
|
54173
|
-
G = 80;
|
|
54174
|
-
G_CENTER = 120;
|
|
54175
|
-
DAMPING = 0.96;
|
|
54176
|
-
RESTITUTION = 0.5;
|
|
54177
|
-
REPULSION = 200;
|
|
54178
54201
|
TICK_MS = 33;
|
|
54179
54202
|
SYNC_MS = 300;
|
|
54180
|
-
MAX_DISTANCE = 3000;
|
|
54181
54203
|
SOFTENING_SQ = 50 * 50;
|
|
54182
54204
|
MIN_MOVE_PX = 0.1;
|
|
54183
54205
|
constructor(board) {
|
|
@@ -54246,8 +54268,8 @@ class GravityEngine {
|
|
|
54246
54268
|
const dcx = centerX - s1.cx;
|
|
54247
54269
|
const dcy = centerY - s1.cy;
|
|
54248
54270
|
const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
|
|
54249
|
-
ax +=
|
|
54250
|
-
ay +=
|
|
54271
|
+
ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
|
|
54272
|
+
ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
|
|
54251
54273
|
for (let j = 0;j < snap.length; j++) {
|
|
54252
54274
|
if (i === j)
|
|
54253
54275
|
continue;
|
|
@@ -54255,7 +54277,7 @@ class GravityEngine {
|
|
|
54255
54277
|
const dx = s2.cx - s1.cx;
|
|
54256
54278
|
const dy = s2.cy - s1.cy;
|
|
54257
54279
|
const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
|
|
54258
|
-
if (dist >
|
|
54280
|
+
if (dist > conf.GRAVITY_MAX_DISTANCE)
|
|
54259
54281
|
continue;
|
|
54260
54282
|
const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
|
|
54261
54283
|
if (overlapping) {
|
|
@@ -54264,26 +54286,26 @@ class GravityEngine {
|
|
|
54264
54286
|
if (overlapX < overlapY) {
|
|
54265
54287
|
const sign = s1.cx < s2.cx ? -1 : 1;
|
|
54266
54288
|
if (sign * vel.vx < 0)
|
|
54267
|
-
vel.vx = -vel.vx *
|
|
54268
|
-
ax += sign *
|
|
54289
|
+
vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
|
|
54290
|
+
ax += sign * conf.GRAVITY_REPULSION * overlapX;
|
|
54269
54291
|
} else {
|
|
54270
54292
|
const sign = s1.cy < s2.cy ? -1 : 1;
|
|
54271
54293
|
if (sign * vel.vy < 0)
|
|
54272
|
-
vel.vy = -vel.vy *
|
|
54273
|
-
ay += sign *
|
|
54294
|
+
vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
|
|
54295
|
+
ay += sign * conf.GRAVITY_REPULSION * overlapY;
|
|
54274
54296
|
}
|
|
54275
54297
|
} else {
|
|
54276
54298
|
const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
|
|
54277
54299
|
if (dist < touchDist + 5)
|
|
54278
54300
|
continue;
|
|
54279
54301
|
const distSq = dx * dx + dy * dy;
|
|
54280
|
-
const gravAcc =
|
|
54302
|
+
const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
|
|
54281
54303
|
ax += gravAcc * dx / dist;
|
|
54282
54304
|
ay += gravAcc * dy / dist;
|
|
54283
54305
|
}
|
|
54284
54306
|
}
|
|
54285
|
-
vel.vx = (vel.vx + ax * dt) *
|
|
54286
|
-
vel.vy = (vel.vy + ay * dt) *
|
|
54307
|
+
vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
|
|
54308
|
+
vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
|
|
54287
54309
|
const moveX = vel.vx * dt;
|
|
54288
54310
|
const moveY = vel.vy * dt;
|
|
54289
54311
|
if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
|
package/dist/esm/node.js
CHANGED
|
@@ -5271,7 +5271,13 @@ var conf = {
|
|
|
5271
5271
|
CARD_DIMENSIONS: { width: 250, height: 400 },
|
|
5272
5272
|
DEFAULT_GAME_ITEM_DIMENSIONS: { width: 200, height: 200 },
|
|
5273
5273
|
MAX_CARD_SIZE: 500,
|
|
5274
|
-
CONNECTOR_ITEM_OFFSET: 20
|
|
5274
|
+
CONNECTOR_ITEM_OFFSET: 20,
|
|
5275
|
+
GRAVITY_G: 80,
|
|
5276
|
+
GRAVITY_G_CENTER: 120,
|
|
5277
|
+
GRAVITY_DAMPING: 0.96,
|
|
5278
|
+
GRAVITY_RESTITUTION: 0.5,
|
|
5279
|
+
GRAVITY_REPULSION: 200,
|
|
5280
|
+
GRAVITY_MAX_DISTANCE: 3000
|
|
5275
5281
|
};
|
|
5276
5282
|
initDefaultI18N();
|
|
5277
5283
|
|
|
@@ -24491,6 +24497,7 @@ class RichText extends BaseItem {
|
|
|
24491
24497
|
autoSizeScale = 1;
|
|
24492
24498
|
containerMaxWidth;
|
|
24493
24499
|
linkTo;
|
|
24500
|
+
localArea;
|
|
24494
24501
|
maxHeight;
|
|
24495
24502
|
selection;
|
|
24496
24503
|
transformationRenderBlock = undefined;
|
|
@@ -24512,6 +24519,7 @@ class RichText extends BaseItem {
|
|
|
24512
24519
|
this.autoSize = autoSize;
|
|
24513
24520
|
this.insideOf = insideOf;
|
|
24514
24521
|
this.initialTextStyles = initialTextStyles;
|
|
24522
|
+
this.localArea = container.copy();
|
|
24515
24523
|
counter = counter + 1;
|
|
24516
24524
|
this.rtCounter = counter;
|
|
24517
24525
|
this.linkTo = linkTo || new LinkTo(this.id, this.board.events);
|
|
@@ -24664,7 +24672,7 @@ class RichText extends BaseItem {
|
|
|
24664
24672
|
this.layoutNodes.width = this.containerMaxWidth;
|
|
24665
24673
|
}
|
|
24666
24674
|
}
|
|
24667
|
-
this.alignInRectangle(this.
|
|
24675
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
24668
24676
|
this.transformCanvas();
|
|
24669
24677
|
this.subject.publish(this);
|
|
24670
24678
|
this.updateRequired = false;
|
|
@@ -24744,7 +24752,7 @@ class RichText extends BaseItem {
|
|
|
24744
24752
|
this.right = transformed.right;
|
|
24745
24753
|
this.bottom = transformed.bottom;
|
|
24746
24754
|
} else {
|
|
24747
|
-
this.alignInRectangle(this.
|
|
24755
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
24748
24756
|
}
|
|
24749
24757
|
this.setClipPath();
|
|
24750
24758
|
if (!this.isInShape && !this.autoSize) {
|
|
@@ -24772,16 +24780,16 @@ class RichText extends BaseItem {
|
|
|
24772
24780
|
}
|
|
24773
24781
|
}
|
|
24774
24782
|
setClipPath() {
|
|
24775
|
-
const
|
|
24776
|
-
const
|
|
24777
|
-
const height = container.getHeight();
|
|
24783
|
+
const width = this.localArea.getWidth();
|
|
24784
|
+
const height = this.localArea.getHeight();
|
|
24778
24785
|
this.clipPath = new conf.path2DFactory;
|
|
24779
24786
|
this.clipPath.rect(0, 0, width, height);
|
|
24780
24787
|
}
|
|
24781
24788
|
setContainer(container) {
|
|
24782
24789
|
this.isContainerSet = true;
|
|
24790
|
+
this.localArea = container.copy();
|
|
24783
24791
|
this.container = container;
|
|
24784
|
-
this.
|
|
24792
|
+
this.updateElement();
|
|
24785
24793
|
}
|
|
24786
24794
|
applyMaxWidth(maxWidth) {
|
|
24787
24795
|
const shouldNotShrink = this.insideOf !== "RichText" && this.insideOf !== "AINode" && this.containerMaxWidth && this.shrinkWidth;
|
|
@@ -24804,8 +24812,8 @@ class RichText extends BaseItem {
|
|
|
24804
24812
|
matrix = this.transformation.toMatrix();
|
|
24805
24813
|
}
|
|
24806
24814
|
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
24807
|
-
const scaledMatrix = new Matrix(translateX, translateY, scaleX, scaleY);
|
|
24808
|
-
return this.
|
|
24815
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
24816
|
+
return this.localArea.getTransformed(scaledMatrix);
|
|
24809
24817
|
}
|
|
24810
24818
|
emitWithoutApplying = (op) => {
|
|
24811
24819
|
if (this.board.events) {
|
|
@@ -25147,7 +25155,7 @@ class RichText extends BaseItem {
|
|
|
25147
25155
|
if (typeof document !== "undefined") {
|
|
25148
25156
|
document.fonts.ready.then(() => {
|
|
25149
25157
|
this.layoutNodes = getBlockNodes(this.getBlockNodes(), this.shrinkWidth ? Infinity : this.getMaxWidth() || 0, this.shrinkWidth, this.insideOf === "Frame");
|
|
25150
|
-
this.alignInRectangle(this.
|
|
25158
|
+
this.alignInRectangle(this.localArea, this.editor.verticalAlignment);
|
|
25151
25159
|
this.transformCanvas();
|
|
25152
25160
|
});
|
|
25153
25161
|
}
|
|
@@ -25177,7 +25185,7 @@ class RichText extends BaseItem {
|
|
|
25177
25185
|
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
25178
25186
|
context.matrix = scaledMatrix;
|
|
25179
25187
|
context.applyChanges();
|
|
25180
|
-
ctx.translate(this.
|
|
25188
|
+
ctx.translate(this.left, this.top);
|
|
25181
25189
|
const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
|
|
25182
25190
|
if (shouldClip) {
|
|
25183
25191
|
ctx.clip(this.clipPath.nativePath);
|
|
@@ -25318,7 +25326,7 @@ class RichText extends BaseItem {
|
|
|
25318
25326
|
}
|
|
25319
25327
|
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
25320
25328
|
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
25321
|
-
const transform = `translate(${scaledMatrix.translateX + this.
|
|
25329
|
+
const transform = `translate(${scaledMatrix.translateX + this.left * scaledMatrix.scaleX}px, ${scaledMatrix.translateY + this.top * scaledMatrix.scaleY}px) scale(${scaledMatrix.scaleX}, ${scaledMatrix.scaleY})`;
|
|
25322
25330
|
const transformedWidth = this.getMbr().getWidth();
|
|
25323
25331
|
const transformedHeight = this.getMbr().getHeight();
|
|
25324
25332
|
const div = documentFactory.createElement("rich-text");
|
|
@@ -25414,6 +25422,19 @@ class RichText extends BaseItem {
|
|
|
25414
25422
|
getPrevMbr() {
|
|
25415
25423
|
return this.prevMbr;
|
|
25416
25424
|
}
|
|
25425
|
+
getMbr() {
|
|
25426
|
+
const cameraScale = this.board.camera.getScale();
|
|
25427
|
+
const extraScale = this.renderingScale ? this.renderingScale(cameraScale) : 1;
|
|
25428
|
+
let matrix;
|
|
25429
|
+
if (this.customTransformationMatrix) {
|
|
25430
|
+
matrix = this.customTransformationMatrix();
|
|
25431
|
+
} else {
|
|
25432
|
+
matrix = this.transformation.toMatrix();
|
|
25433
|
+
}
|
|
25434
|
+
const { translateX, translateY, scaleX, scaleY } = matrix;
|
|
25435
|
+
const scaledMatrix = new Matrix(translateX, translateY, scaleX * extraScale, scaleY * extraScale);
|
|
25436
|
+
return new Mbr(this.left, this.top, this.right, this.bottom).getTransformed(scaledMatrix);
|
|
25437
|
+
}
|
|
25417
25438
|
}
|
|
25418
25439
|
|
|
25419
25440
|
// src/Items/Mbr/updateRects.ts
|
|
@@ -43314,6 +43335,8 @@ class DefaultFrameData {
|
|
|
43314
43335
|
|
|
43315
43336
|
// src/Items/Frame/Frame.ts
|
|
43316
43337
|
var defaultFrameData = new DefaultFrameData;
|
|
43338
|
+
var HEADING_TOP_OFFSET = -45;
|
|
43339
|
+
var HEADING_BOTTOM_OFFSET = -12;
|
|
43317
43340
|
|
|
43318
43341
|
class Frame2 extends BaseItem {
|
|
43319
43342
|
getItemById;
|
|
@@ -43351,14 +43374,14 @@ class Frame2 extends BaseItem {
|
|
|
43351
43374
|
this.borderStyle = borderStyle;
|
|
43352
43375
|
this.borderWidth = borderWidth;
|
|
43353
43376
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
43377
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
43378
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
43354
43379
|
this.path = Frames[this.shapeType].path.copy();
|
|
43355
43380
|
this.transformation = new Transformation(this.id, board.events);
|
|
43356
43381
|
this.linkTo = new LinkTo(this.id, board.events);
|
|
43357
43382
|
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 });
|
|
43358
43383
|
this.text.editor.verticalAlignment = "bottom";
|
|
43359
43384
|
this.text.setSelectionHorisontalAlignment("left");
|
|
43360
|
-
this.textContainer.top = -45;
|
|
43361
|
-
this.textContainer.bottom = -12;
|
|
43362
43385
|
this.text.customTransformationMatrix = () => {
|
|
43363
43386
|
const matrix = this.transformation.toMatrix();
|
|
43364
43387
|
return new Matrix(matrix.translateX, matrix.translateY, 1, 1);
|
|
@@ -43391,6 +43414,8 @@ class Frame2 extends BaseItem {
|
|
|
43391
43414
|
initPath() {
|
|
43392
43415
|
this.path = Frames[this.shapeType].path.copy();
|
|
43393
43416
|
this.textContainer = Frames[this.shapeType].textBounds.copy();
|
|
43417
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
43418
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
43394
43419
|
this.text.setContainer(this.textContainer.copy());
|
|
43395
43420
|
this.text.updateElement();
|
|
43396
43421
|
}
|
|
@@ -43535,6 +43560,9 @@ class Frame2 extends BaseItem {
|
|
|
43535
43560
|
}
|
|
43536
43561
|
if (data.text) {
|
|
43537
43562
|
this.text.deserialize(data.text);
|
|
43563
|
+
this.textContainer.top = HEADING_TOP_OFFSET;
|
|
43564
|
+
this.textContainer.bottom = HEADING_BOTTOM_OFFSET;
|
|
43565
|
+
this.text.setContainer(this.textContainer.copy());
|
|
43538
43566
|
}
|
|
43539
43567
|
this.canChangeRatio = data.canChangeRatio ?? this.canChangeRatio;
|
|
43540
43568
|
this.subject.publish(this);
|
|
@@ -56638,14 +56666,8 @@ class GravityEngine {
|
|
|
56638
56666
|
tickTimer = null;
|
|
56639
56667
|
syncTimer = null;
|
|
56640
56668
|
lastSyncedPositions = new Map;
|
|
56641
|
-
G = 80;
|
|
56642
|
-
G_CENTER = 120;
|
|
56643
|
-
DAMPING = 0.96;
|
|
56644
|
-
RESTITUTION = 0.5;
|
|
56645
|
-
REPULSION = 200;
|
|
56646
56669
|
TICK_MS = 33;
|
|
56647
56670
|
SYNC_MS = 300;
|
|
56648
|
-
MAX_DISTANCE = 3000;
|
|
56649
56671
|
SOFTENING_SQ = 50 * 50;
|
|
56650
56672
|
MIN_MOVE_PX = 0.1;
|
|
56651
56673
|
constructor(board) {
|
|
@@ -56714,8 +56736,8 @@ class GravityEngine {
|
|
|
56714
56736
|
const dcx = centerX - s1.cx;
|
|
56715
56737
|
const dcy = centerY - s1.cy;
|
|
56716
56738
|
const distCenter = Math.sqrt(dcx * dcx + dcy * dcy) + 1;
|
|
56717
|
-
ax +=
|
|
56718
|
-
ay +=
|
|
56739
|
+
ax += conf.GRAVITY_G_CENTER * dcx / distCenter;
|
|
56740
|
+
ay += conf.GRAVITY_G_CENTER * dcy / distCenter;
|
|
56719
56741
|
for (let j = 0;j < snap.length; j++) {
|
|
56720
56742
|
if (i === j)
|
|
56721
56743
|
continue;
|
|
@@ -56723,7 +56745,7 @@ class GravityEngine {
|
|
|
56723
56745
|
const dx = s2.cx - s1.cx;
|
|
56724
56746
|
const dy = s2.cy - s1.cy;
|
|
56725
56747
|
const dist = Math.sqrt(dx * dx + dy * dy) + 0.001;
|
|
56726
|
-
if (dist >
|
|
56748
|
+
if (dist > conf.GRAVITY_MAX_DISTANCE)
|
|
56727
56749
|
continue;
|
|
56728
56750
|
const overlapping = s1.right > s2.left && s2.right > s1.left && s1.bottom > s2.top && s2.bottom > s1.top;
|
|
56729
56751
|
if (overlapping) {
|
|
@@ -56732,26 +56754,26 @@ class GravityEngine {
|
|
|
56732
56754
|
if (overlapX < overlapY) {
|
|
56733
56755
|
const sign = s1.cx < s2.cx ? -1 : 1;
|
|
56734
56756
|
if (sign * vel.vx < 0)
|
|
56735
|
-
vel.vx = -vel.vx *
|
|
56736
|
-
ax += sign *
|
|
56757
|
+
vel.vx = -vel.vx * conf.GRAVITY_RESTITUTION;
|
|
56758
|
+
ax += sign * conf.GRAVITY_REPULSION * overlapX;
|
|
56737
56759
|
} else {
|
|
56738
56760
|
const sign = s1.cy < s2.cy ? -1 : 1;
|
|
56739
56761
|
if (sign * vel.vy < 0)
|
|
56740
|
-
vel.vy = -vel.vy *
|
|
56741
|
-
ay += sign *
|
|
56762
|
+
vel.vy = -vel.vy * conf.GRAVITY_RESTITUTION;
|
|
56763
|
+
ay += sign * conf.GRAVITY_REPULSION * overlapY;
|
|
56742
56764
|
}
|
|
56743
56765
|
} else {
|
|
56744
56766
|
const touchDist = (s1.w + s2.w + s1.h + s2.h) * 0.25;
|
|
56745
56767
|
if (dist < touchDist + 5)
|
|
56746
56768
|
continue;
|
|
56747
56769
|
const distSq = dx * dx + dy * dy;
|
|
56748
|
-
const gravAcc =
|
|
56770
|
+
const gravAcc = conf.GRAVITY_G * s2.mass / (distSq + this.SOFTENING_SQ);
|
|
56749
56771
|
ax += gravAcc * dx / dist;
|
|
56750
56772
|
ay += gravAcc * dy / dist;
|
|
56751
56773
|
}
|
|
56752
56774
|
}
|
|
56753
|
-
vel.vx = (vel.vx + ax * dt) *
|
|
56754
|
-
vel.vy = (vel.vy + ay * dt) *
|
|
56775
|
+
vel.vx = (vel.vx + ax * dt) * conf.GRAVITY_DAMPING;
|
|
56776
|
+
vel.vy = (vel.vy + ay * dt) * conf.GRAVITY_DAMPING;
|
|
56755
56777
|
const moveX = vel.vx * dt;
|
|
56756
56778
|
const moveY = vel.vy * dt;
|
|
56757
56779
|
if (Math.abs(moveX) >= this.MIN_MOVE_PX || Math.abs(moveY) >= this.MIN_MOVE_PX) {
|
|
@@ -5,14 +5,8 @@ export declare class GravityEngine {
|
|
|
5
5
|
private tickTimer;
|
|
6
6
|
private syncTimer;
|
|
7
7
|
private lastSyncedPositions;
|
|
8
|
-
readonly G = 80;
|
|
9
|
-
readonly G_CENTER = 120;
|
|
10
|
-
readonly DAMPING = 0.96;
|
|
11
|
-
readonly RESTITUTION = 0.5;
|
|
12
|
-
readonly REPULSION = 200;
|
|
13
8
|
readonly TICK_MS = 33;
|
|
14
9
|
readonly SYNC_MS = 300;
|
|
15
|
-
readonly MAX_DISTANCE = 3000;
|
|
16
10
|
readonly SOFTENING_SQ: number;
|
|
17
11
|
readonly MIN_MOVE_PX = 0.1;
|
|
18
12
|
constructor(board: Board);
|
|
@@ -44,6 +44,7 @@ export declare class RichText extends BaseItem {
|
|
|
44
44
|
private autoSizeScale;
|
|
45
45
|
private containerMaxWidth?;
|
|
46
46
|
readonly linkTo: LinkTo;
|
|
47
|
+
private localArea;
|
|
47
48
|
maxHeight: number;
|
|
48
49
|
private selection?;
|
|
49
50
|
transformationRenderBlock?: boolean;
|
|
@@ -153,4 +154,5 @@ export declare class RichText extends BaseItem {
|
|
|
153
154
|
getRichText(): RichText;
|
|
154
155
|
getLinkTo(): string | undefined;
|
|
155
156
|
getPrevMbr(): Mbr | null;
|
|
157
|
+
getMbr(): Mbr;
|
|
156
158
|
}
|
package/dist/types/Settings.d.ts
CHANGED
|
@@ -247,6 +247,12 @@ export declare const conf: {
|
|
|
247
247
|
};
|
|
248
248
|
MAX_CARD_SIZE: number;
|
|
249
249
|
CONNECTOR_ITEM_OFFSET: number;
|
|
250
|
+
GRAVITY_G: number;
|
|
251
|
+
GRAVITY_G_CENTER: number;
|
|
252
|
+
GRAVITY_DAMPING: number;
|
|
253
|
+
GRAVITY_RESTITUTION: number;
|
|
254
|
+
GRAVITY_REPULSION: number;
|
|
255
|
+
GRAVITY_MAX_DISTANCE: number;
|
|
250
256
|
};
|
|
251
257
|
export type Settings = typeof conf;
|
|
252
258
|
export {};
|