Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions app/src/main/java/helium314/keyboard/keyboard/Key.java
Original file line number Diff line number Diff line change
Expand Up @@ -955,13 +955,14 @@ public boolean isOnKey(final int x, final int y) {
* @param x the x-coordinate of the point
* @param y the y-coordinate of the point
* @return the square of the distance of the point from the nearest edge of the
* key
* key (using the hitbox, which may be larger than the visual bounds
* for edge keys)
*/
public int squaredDistanceToEdge(final int x, final int y) {
final int left = getX();
final int right = left + mWidth;
final int top = getY();
final int bottom = top + mHeight;
final int left = mHitBox.left;
final int right = mHitBox.right - 1;
final int top = mHitBox.top;
final int bottom = mHitBox.bottom - 1;
final int edgeX = x < left ? left : Math.min(x, right);
final int edgeY = y < top ? top : Math.min(y, bottom);
final int dx = x - edgeX;
Expand Down
Loading
Loading