In the section 8.7.6 (OpenvG Specification 1.1) indicated that
if the user-to-surface tansformation includes non-uniform scaling, the geometry to be stroked must be transformed into surface coordinates prior to stroking. The paint transformation must also be set to the concatenation of the paint-to-user and user-to-surface transformations in order to allow correct painting of the stroked geometry.
According to the sample code, i wrote my code as below, but had no effect to the line width.Why?
Previously, with GDI+ , when i am to stroke a path, i can simply scale the Pen to change only the line width of my stroked path
without affecting its coordinates nor shape. It seems in GDI+ , the linewidth scaling for stroking is seperated from the coordinates
scaling of path shaping.
Here with OpenVG, is there any way by which i can achieve the same effect as the aforementioned case.
I mean only scale the linewidth, keeping the shape and coordinates the same.
Your code does not do any non-uniform scaling. It just draws a vertical line the normal way.
The VG 1.1 spec offers 2 different approaches to solve this problem:
If the desired transformations are uniform (i.e. the geometry stretches in all directions by the same amount), then simply figure out what the new line width should be (= linewidth / sqrt(absolute value of (sxsy – shxshy))), and use that (vgSetf(VG_STROKE_LINE_WIDTH, modified_line_width)).
or
If there are non-uniform transformations (e.g. line width stretches by a factor of 5 but the line length only by a factor of 3), then use vgTransformPath() like in the example in section 8.7.6.
In your case, it seems like the first approach should do the trick, and simply adding a
vgSetf(VG_STROKE_LINE_WIDTH, 4.0f/5.0f);
before your draw call ought to work (4.0f = line width, 5.0f = sqrt(|(sxsy – shxshy)|) = sqrt(|55 - 00|) [where sx,sy,shx,shy can be retrieved with vgGetMatrix()])