Jump to content
  • Advertisement
Sign in to follow this  
VQuery

[Solved] How to check if Android Path contains point?

Recommended Posts

Specifically speaking, this path: https://developer.android.com/reference/android/graphics/Path.html

No, using it as a Region does not work because that returns the bounds, not the polygon shape. Yes, it needs to be a Path because I'm directly using svg elements so it cannot be a "Polygon class". 

Ideas:
- op method, although for some reason it always returns true (which is NOT what I need)
- Somehow converting the Path into a Polygon

Any help would be appreciated. 

Edit: Solved. My solution requires parsing the pathData, converting it to a path, creating a new Polygon class, and converting the path data into Polygon points.

Edited by VQuery

Share this post


Link to post
Share on other sites
Advertisement

On first sight, I'd say you don't, at least not with Path itself.

The class has lots of "addFoo" for complicated values of Foo. To answer your question either the class needs to supply a call/interface for it, or you have to write it yourself, which means you need to get into the internal structure of the added shapes and test the question on each shape.

The class has no query API for either of those things.

So your solution (if it exists with Path) is not in Path, but in some other package that transforms a Path to some other thing. I can imagine a renderer exists that converts the Path object to a collection of pixels or to a collection of lines and/or filled areas (at least a likely use of the Path seems to display it, right?). Browse the graphics package looking for classes that take Paths and do something with it.

If it is extendable, there may exist generic walker classes that expose the Path internals which you can derive from.

Share this post


Link to post
Share on other sites
4 minutes ago, Alberth said:

On first sight, I'd say you don't, at least not with Path itself.

The class has lots of "addFoo" for complicated values of Foo. To answer your question either the class needs to supply a call/interface for it, or you have to write it yourself, which means you need to get into the internal structure of the added shapes and test the question on each shape.

The class has no query API for either of those things.

So your solution (if it exists with Path) is not in Path, but in some other package that transforms a Path to some other thing. I can imagine a renderer exists that converts the Path object to a collection of pixels or to a collection of lines and/or filled areas (at least a likely use of the Path seems to display it, right?). Browse the graphics package looking for classes that take Paths and do something with it.

If it is extendable, there may exist generic walker classes that expose the Path internals which you can derive from.

Unfortunately much of what I find is native calls.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!