I am currently involved in a project of implementing a canvas element supporting for our browser.
in our last version we use gdi+ library to draw stuff , here in this version , we changed to use OpenVG.
i encountered a problem when i want to implement a function as : isPointInPath. The detailed definition defined in html5 protocol is as below:
The isPointInPath(x, y) method must return true if the point given by the x and y coordinates passed to the method, when treated as coordinates in the canvas coordinate space unaffected by the current transformation, is inside the current path as determined by the non-zero winding number rule; and must return false otherwise. Points on the path itself are considered to be inside the path. If either of the arguments is infinite or NaN, then the method must return false.
In GDI+ library, the class region provides a similar function like isVisible which checks whether a specific
point locates inside the region . then you can create a region with your path then call this member function
to easily get the result.
but here in OpenVG there is no such a easy way to do that. as least , there is no region.
my first thought is to fill the Path to a temporary buffer-like surface ( masklayer? vgimage? i’m still not sure yet.)
then read the pixel value of that point to check the result. It seem to work ,although i not yet try it.
however , it is really ineffective and memory-consuming, especally at some occasions with intensive calls to the isPointInPath.
It seems to be a fundmental problem in computer graphics , yet im a beginner about that.
I wonder if there is a better algorithemic approch to handle this problem using the existing OpenVG functions.