micahpearlman / MonkVG

MonkVG is an OpenVG 1.1 like vector graphics API implementation optimized for game use currently using an OpenGL ES backend that should be compatible with any HW that supports OpenGL ES 2.0 which includes most iOS and Android devices.
Other
376 stars 66 forks source link

The problem with drawing of circles #18

Closed gerchicov closed 2 years ago

gerchicov commented 11 years ago
void OpenVG_SVGHandler::onPathCubic( float x1, float y1, float x2, float y2, float x3, float y3 ) { 
    VGubyte seg = VG_CUBIC_TO | openVGRelative();
    VGfloat data[6];

    data[0] = x1; data[1] = y1;
    data[2] = x2; data[3] = y2;
    data[4] = x3; data[5] = y3;
    vgAppendPathData( _current_group->current_path->path, 1, &seg, data);

}
void OpenVG_SVGHandler::onPathSCubic( float x2, float y2, float x3, float y3 ) {
    VGubyte seg = VG_SCUBIC_TO | openVGRelative();
    VGfloat data[4];

    data[0] = x2; data[1] = y2;
    data[2] = x3; data[3] = y3;
    vgAppendPathData( _current_group->current_path->path, 1, &seg, data);

}

it is a code from MonkSVG, but it uses MonkVG and shows its bug. I have a code which draws a circle:

Description is here (8.3.6 The cubic Bézier curve commands): http://www.w3.org/TR/SVG/paths.html#PathDataMovetoCommands

So the circle is drawn as 3 segments using the first function and one segment is drawn using the second one. The first 3 segments look like a parts of a circle and the last segment looks like a part of a square with rounded corners.

micahpearlman commented 11 years ago

Can you send me a full SVG file with the issue? It may be a bug with MonkSVG parsing. Can you repro this hardcoded into code?

gerchicov commented 11 years ago

I have sent this file to your email

gerchicov commented 11 years ago

if it will be easier for you here is a java-library with a similar svg-parsing: https://github.com/pents90/svg-android/blob/master/svgandroid/src/com/larvalabs/svgandroid/SVGParser.java but they use the same function for both "S s" and "C c" tags and it works

gerchicov commented 11 years ago

so my temporary solution is replacing "S s" drawing calls with "C c" calls and this android library helped very much