romainguy / pathway

A set of APIs to manipulate graphics paths on Android.
Apache License 2.0
197 stars 3 forks source link

Can we have PathIterator.size? #3

Closed chethaase closed 1 year ago

chethaase commented 1 year ago

In using the iterator API, I'm finding myself wanting to know how many commands there are in a path, so I can pre-allocate structures based on that info. Not sure if that API belongs on PathIterator or some other queryable object, but seems like an API that might be useful in general.

romainguy commented 1 year ago

We could add this, the info is available internally. It would only be an issue when a path contains conic segments: we want to convert them to cubic which would affect the total count.

romainguy commented 1 year ago

Done, added in 0.6.0. I added rawSize and size. The former returns the segment count without any conversion (conic->quadratic) and is fast, the second one returns the exact number of segments to iterate taking into account conversions, but is more expensive.