PDA

View Full Version : how to get out path data from a vgPath



akaiwall
06-01-2009, 08:30 PM
Hi friends:

I am wrapping up OpenVG provided path fuctions to implement a generic Path Class which supports funtions like beginPath,closePath, moveTo, lineTo , arcTo, arc, bezierTo.. etc. most of the memeber functions share the same prototypes as defined in the html5.0 canvas protocol.

For some of them ,i only need to use vgAppendToPath to append the new segments and coordinates to the existing vgPath . but sometimes , i have to use the information of the pointes already in the path with the newly added coordinates to make some calculations., for eg. arcTo.

are there any cool ways to get points information from a vgPath handle which can achieve some similar effects like getLastPoint, getPointArray, getSegmentArray?

if not ,the only way i can do seems to be maintaining one or two arrays by myself. however,problem is the newly added points' coordinates can probably be changed by vgTransformpath, then i should synchronously transform the maintained points array by myself too. its really awkward and ineffective.

thanks for your suggestions .^_^

Ivo Moravec
06-02-2009, 10:54 AM
Short answer: not really. You may need to look for an extension that allows that sort of functionality.

It's a shame the functionality is not included - especially when vgGetParameterfv() accepts querying for VG_PATH_NUM_SEGMENTS, and VG_PATH_NUM_COORDS.
I suppose the thinking was to allow the driver to internally allow other transformations to the datatype, and querying the value would force the VG driver to keep the original data lying around.

That said, you can get some information by calling PointAlongPath() (it accepts start segment and number of segments, so querying with 0 and a large float value can (very inefficiently) get you the end points of any segment).

I suggest just keeping the original data with your path data and updating it on vgAppendPathData, vgTransformPath, vgInterpolate, etc. It's a pain, but alas...