Skip to content

Instantly share code, notes, and snippets.

@Krishan14sharma
Last active November 10, 2017 11:58
Show Gist options
  • Save Krishan14sharma/2b3570447f7b0a920d8dff3d3f950111 to your computer and use it in GitHub Desktop.
Save Krishan14sharma/2b3570447f7b0a920d8dff3d3f950111 to your computer and use it in GitHub Desktop.
fun getRectIndexesFor(x: Float, y: Float): Pair<Int, Int> {
squares.forEachIndexed {
i, rects ->
for ((j, rect) in rects.withIndex()) {
if (rect.contains(x.toInt(), y.toInt()))
return Pair(i, j)
}
}
return Pair(-1, -1) // x, y do not lie in our view
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment