Android Question x,y inside a path??

ilan

Expert
Licensed User
Longtime User
hi

i am creating a path (no specific shape, could be triangle, rect,..)

and in activity touch i would like to know if my x,y are inside that path

is that possible?

do we have some good math experts here?
 

JordiCP

Expert
Licensed User
Longtime User
Algorithm-less tricky way

Create a mutable bitmap with the same dimensions as the view you are showing. No need to attach it to a view. Initialize a canvas to it. Clip the path and fill it Red. When you want to see if X, Y is inside the path, just check the color of this point in the bitmap

(Surprisingly, it also works for other colors )
 
Upvote 0

ilan

Expert
Licensed User
Longtime User

i prefer klaus solution. the get pixel color function is to weak for my needs

but thank you anyway
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…