From 72894b60b8d012c4fb10f8e42b342a65e03303f1 Mon Sep 17 00:00:00 2001 From: jmoenig Date: Sat, 17 Apr 2021 16:38:05 +0200 Subject: [PATCH] speed-up talk bubble positioning by 5x --- HISTORY.md | 3 +++ snap.html | 2 +- src/objects.js | 12 +++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 90478b59..8c75d651 100755 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,12 +1,15 @@ # Snap! (BYOB) History ## in development: +* **Notable Changes:** + * speed-up talk bubble positioning by 5x * **Notable Fixes:** * work around a floating point precision glitch in "ray length" ### 2021-04-17 * new dev version * threads: worked around a floating point precision glitch in "ray length" +* objects: speed-up talk bubble positioning by 5x ## 6.7.4 * **Notable Fixes:** diff --git a/snap.html b/snap.html index 68ff600e..4f251db9 100755 --- a/snap.html +++ b/snap.html @@ -10,7 +10,7 @@ - + diff --git a/src/objects.js b/src/objects.js index 9a8b2731..3596f0bc 100644 --- a/src/objects.js +++ b/src/objects.js @@ -84,7 +84,7 @@ BlockEditorMorph, BlockDialogMorph, PrototypeHatBlockMorph, BooleanSlotMorph, localize, TableMorph, TableFrameMorph, normalizeCanvas, VectorPaintEditorMorph, AlignmentMorph, Process, WorldMap, copyCanvas, useBlurredShadows*/ -modules.objects = '2021-April-09'; +modules.objects = '2021-April-17'; var SpriteMorph; var StageMorph; @@ -5377,7 +5377,12 @@ SpriteMorph.prototype.positionTalkBubble = function () { var stage = this.parentThatIsA(StageMorph), stageScale = stage ? stage.scale : 1, bubble = this.talkBubble(), - middle = this.center().y; + middle = this.center().y, + // step = new Point(-10, 10); + step = this.extent().divideBy(10) + .max(new Point(5, 5).scaleBy(stageScale)) + .multiplyBy(new Point(-1, 1)); + if (!bubble) {return null; } bubble.show(); if (!bubble.isPointingRight) { @@ -5388,8 +5393,9 @@ SpriteMorph.prototype.positionTalkBubble = function () { bubble.setLeft(this.right()); bubble.setBottom(this.top()); while (!this.isTouching(bubble) && bubble.bottom() < middle) { - bubble.moveBy(new Point(-1, 1).scaleBy(stageScale)); + bubble.moveBy(step); } + bubble.moveBy(step.mirror()); if (!stage) {return null; } if (bubble.right() > stage.right()) { bubble.isPointingRight = false;