From 31ac3ec644547bd4a3450820f9a69ebcfd17661e Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 3 Oct 2022 13:19:14 -0400
Subject: fixed client crash on text menu for ink strokes.  fixed circle rubber
 banding. fixed vertical position of text in ink stroke

---
 src/client/util/InteractionUtils.tsx | 53 ++++++++++--------------------------
 1 file changed, 14 insertions(+), 39 deletions(-)

(limited to 'src/client/util/InteractionUtils.tsx')

diff --git a/src/client/util/InteractionUtils.tsx b/src/client/util/InteractionUtils.tsx
index 4af51b9a0..85700da37 100644
--- a/src/client/util/InteractionUtils.tsx
+++ b/src/client/util/InteractionUtils.tsx
@@ -230,58 +230,33 @@ export namespace InteractionUtils {
                 points.push({ X: right, Y: bottom });
                 points.push({ X: left, Y: bottom });
                 points.push({ X: left, Y: top });
+                break;
             case 'triangle':
-                // points.push({ X: left, Y: bottom });
-                // points.push({ X: right, Y: bottom });
-                // points.push({ X: (right + left) / 2, Y: top });
-                // points.push({ X: left, Y: bottom });
-
-                points.push({ X: left, Y: bottom });
                 points.push({ X: left, Y: bottom });
-
-                points.push({ X: right, Y: bottom });
-                points.push({ X: right, Y: bottom });
                 points.push({ X: right, Y: bottom });
-                points.push({ X: right, Y: bottom });
-
-                points.push({ X: (right + left) / 2, Y: top });
-                points.push({ X: (right + left) / 2, Y: top });
                 points.push({ X: (right + left) / 2, Y: top });
-                points.push({ X: (right + left) / 2, Y: top });
-
-                points.push({ X: left, Y: bottom });
                 points.push({ X: left, Y: bottom });
+                break;
             case 'circle':
                 const centerX = (Math.max(left, right) + Math.min(left, right)) / 2;
                 const centerY = (Math.max(top, bottom) + Math.min(top, bottom)) / 2;
                 const radius = Math.max(centerX - Math.min(left, right), centerY - Math.min(top, bottom));
-                if (centerX - Math.min(left, right) < centerY - Math.min(top, bottom)) {
-                    for (var y = Math.min(top, bottom); y < Math.max(top, bottom); y++) {
-                        const x = Math.sqrt(Math.pow(radius, 2) - Math.pow(y - centerY, 2)) + centerX;
-                        points.push({ X: x, Y: y });
-                    }
-                    for (var y = Math.max(top, bottom); y > Math.min(top, bottom); y--) {
-                        const x = Math.sqrt(Math.pow(radius, 2) - Math.pow(y - centerY, 2)) + centerX;
-                        const newX = centerX - (x - centerX);
-                        points.push({ X: newX, Y: y });
-                    }
-                    points.push({ X: Math.sqrt(Math.pow(radius, 2) - Math.pow(Math.min(top, bottom) - centerY, 2)) + centerX, Y: Math.min(top, bottom) });
-                } else {
-                    for (var x = Math.min(left, right); x < Math.max(left, right); x++) {
-                        const y = Math.sqrt(Math.pow(radius, 2) - Math.pow(x - centerX, 2)) + centerY;
-                        points.push({ X: x, Y: y });
-                    }
-                    for (var x = Math.max(left, right); x > Math.min(left, right); x--) {
-                        const y = Math.sqrt(Math.pow(radius, 2) - Math.pow(x - centerX, 2)) + centerY;
-                        const newY = centerY - (y - centerY);
-                        points.push({ X: x, Y: newY });
-                    }
-                    points.push({ X: Math.min(left, right), Y: Math.sqrt(Math.pow(radius, 2) - Math.pow(Math.min(left, right) - centerX, 2)) + centerY });
+                for (var x = Math.min(left, right); x < Math.max(left, right); x++) {
+                    const y = Math.sqrt(Math.pow(radius, 2) - Math.pow(x - centerX, 2)) + centerY;
+                    points.push({ X: x, Y: y });
                 }
+                for (var x = Math.max(left, right); x > Math.min(left, right); x--) {
+                    const y = Math.sqrt(Math.pow(radius, 2) - Math.pow(x - centerX, 2)) + centerY;
+                    const newY = centerY - (y - centerY);
+                    points.push({ X: x, Y: newY });
+                }
+                points.push({ X: Math.min(left, right), Y: Math.sqrt(Math.pow(radius, 2) - Math.pow(Math.min(left, right) - centerX, 2)) + centerY });
+                break;
+
             case 'line':
                 points.push({ X: left, Y: top });
                 points.push({ X: right, Y: bottom });
-                return points;
+                break;
         }
         return points;
     }
-- 
cgit v1.2.3-70-g09d2

