C and c mean curves with 3 points defined.
S and s mean curves with 2 points defined.
The relevant functions are (monkSVG + monkVG/openVG):
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);
}
The problem is the second function (with 2 points) result image look likes incorrect. So I want to try to replace it with a function which look likes workable.
I tried to store a point from a previous step but it gives an incorrect result:
float x2 = d_string_to_float( c, &c );
float y2 = d_string_to_float( c, &c );
float x3 = d_string_to_float( c, &c );
float y3 = d_string_to_float( c, &c );
float x1 = 2 * prevX - x2;
float y1 = 2 * prevY - x2;
_handler->onPathCubic(x1, y1, x2, y2, x3, y3);
prevX = x3;
prevY = y3;
My solution is to write code similar to the same in another library: