From 7f432a6686954af9f35c779df4affc79413930d2 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 4 May 2019 14:04:34 +0200 Subject: [PATCH] Possible Circular Frames --- Frame.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/Frame.js b/Frame.js index 0fba2522b..acc87a992 100644 --- a/Frame.js +++ b/Frame.js @@ -9,6 +9,7 @@ function newFrame () { parentFrame: undefined, // Here we store the parent cointainer zoom object. width: browserCanvas.width, height: browserCanvas.height, + radius: 0, position: undefined, getBodyHeight: getBodyHeight, draw: draw, @@ -265,16 +266,24 @@ function newFrame () { } } - /* Now we check if the resulting point is whin the current Frame. */ + /* Now we check if the resulting point is whin the current Frame. */ - if (checkPoint.x < 0 || checkPoint.y < 0 || checkPoint.x > thisObject.width || checkPoint.y > thisObject.height) { - /* The point received is not in this frame */ + if (thisObject.type === 'Circle') { + let distance = Math.sqrt(Math.pow(thisObject.position.x - point.x, 2) + Math.pow(thisObject.position.y - point.y, 2)) - return false - } else { - /* The point is within this frame. */ + if (distance < thisObject.radius) { + return true + } else { + return false + } + } - return true + if (thisObject.type === 'Rectangle') { + if (checkPoint.x < 0 || checkPoint.y < 0 || checkPoint.x > thisObject.width || checkPoint.y > thisObject.height) { + return false + } else { + return true + } } }