* Finds the corner (if any) of this rectangle that contains the point [x, y]. * @param x The x-coordinate to check * @param y The y-coordinate to check * @param cornerSize Each corner is treated as an inset square with this width and height. * @returns The compass directi
(x: number, y: number, cornerSize: number)
| 250 | * @returns The compass direction of the corner that contains the point, or `undefined` if the point is not in any corner. |
| 251 | */ |
| 252 | findContainingCorner(x: number, y: number, cornerSize: number): CompassCorners | undefined { |
| 253 | if (this.isInTopLeftCorner(x, y, cornerSize)) return "NW" |
| 254 | if (this.isInTopRightCorner(x, y, cornerSize)) return "NE" |
| 255 | if (this.isInBottomLeftCorner(x, y, cornerSize)) return "SW" |
| 256 | if (this.isInBottomRightCorner(x, y, cornerSize)) return "SE" |
| 257 | } |
| 258 | |
| 259 | /** @returns `true` if the point [{@link x}, {@link y}] is in the top-left corner of this rectangle, otherwise `false`. */ |
| 260 | isInTopLeftCorner(x: number, y: number, cornerSize: number): boolean { |
no test coverage detected