PDA

View Full Version : A simple question



tinuhp
11-15-2007, 07:56 AM
How to draw a quadratic curve using OpenVG....

I used the following code:

VGPath path;

VGubyte segments[] = {VG_QUAD_TO_ABS};
VGfloat coords[] = { 100,100,
150,200,
200,100
};
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
vgAppendPathData(path,1,segments,coords);
vgDrawPath( path, VG_STROKE_PATH );
vgDestroyPath( path );


I get nothing...
When I change the 2nd parameter to 2 ,I get some curve which I cannot understand...

When I am drawing only a single path why should I give 2 in the parameter.....
Expecting Reply...

Ivo Moravec
11-15-2007, 12:15 PM
How to draw a quadratic curve using OpenVG....

I used the following code:

VGPath path;

VGubyte segments[] = {VG_QUAD_TO_ABS};
VGfloat coords[] = { 100,100,
150,200,
200,100
};
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
vgAppendPathData(path,1,segments,coords);
vgDrawPath( path, VG_STROKE_PATH );
vgDestroyPath( path );


I get nothing...
When I change the 2nd parameter to 2 ,I get some curve which I cannot understand...

When I am drawing only a single path why should I give 2 in the parameter.....
Expecting Reply...

VG_QUAD_TO expects only 2 coordinates not 3. The first coordinate is given by the current position. The start position on a new path is always (0,0) so you were actually drawing a quad with the 3 points: (0,0),(100,100), and (150,200) instead of the one you were expecting. Thus you should add a VG_MOVE_TO_ABS to your command stream by:

VGubyte segments[] = {VG_MOVE_TO_ABS, VG_QUAD_TO_ABS};
VGfloat coords[] = { 100,100, 150,200,200,100};
vgAppendPathData(path,2,segments,coords);

tinuhp
11-15-2007, 11:31 PM
Thanks for the reply ....
It worked...
And I have doubts yet...

1:We need three control points to draw a quad curve....
a starting point,an ending point and an internal control point
But QUAD_TO expects only 2 points ....
Actually what are these two points....
Are they internal control point and ending point .....

2:If so,when I use the following code to draw my quadratic curve at origin only,
I dont see anything...

VGPath path;

VGubyte segments[] = {VG_QUAD_TO_ABS};
VGfloat coords[] = {150,200,200,100};
path = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VG_PATH_CAPABILITY_ALL);
vgAppendPathData(path,1,segments,coords);
vgDrawPath( path, VG_STROKE_PATH );
vgDestroyPath( path );

Expecting Reply.....

muratmat
11-16-2007, 02:50 AM
2: If so,when I use the following code to draw my quadratic curve at origin only, I dont see anything...


If you are using AmanithVG, there was an already known bug related to paths made of a single command without an initial move_to.
The next public release will contain the patch.

tinuhp
11-16-2007, 03:20 AM
Yes. I am using AmanithVG ....
Thanks for the reply.....