cmSvgWriter.c : Added _cmSgWriterFlipY().

This commit is contained in:
kevin 2016-08-17 18:58:42 -04:00
parent be6dc19ade
commit bd1d645e81
2 changed files with 21 additions and 1 deletions

View File

@ -167,6 +167,24 @@ void _cmSvgSize( cmSvg_t* p, double* widthRef, double* heightRef )
*heightRef = max_y - min_y; *heightRef = max_y - min_y;
} }
void _cmSvgWriterFlipY( cmSvg_t* p, unsigned height )
{
cmSvgEle_t* e = p->elist;
for(; e!=NULL; e=e->link)
{
e->y0 = (-e->y0) + height;
e->y1 = (-e->y1) + height;
if( e->id == kRectSvgId )
{
double t = e->y1;
e->y1 = e->y0;
e->y0 = t;
}
}
}
cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t* outFn ) cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t* outFn )
{ {
@ -179,6 +197,8 @@ cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t*
_cmSvgSize(p, &svgWidth, &svgHeight ); _cmSvgSize(p, &svgWidth, &svgHeight );
_cmSvgWriterFlipY( p, svgHeight );
if( cmFileOpen(&fH,outFn,kWriteFileFl,p->err.rpt) != kOkFileRC ) if( cmFileOpen(&fH,outFn,kWriteFileFl,p->err.rpt) != kOkFileRC )
return cmErrMsg(&p->err,kFileFailSvgRC,"SVG file create failed for '%s'.",cmStringNullGuard(outFn)); return cmErrMsg(&p->err,kFileFailSvgRC,"SVG file create failed for '%s'.",cmStringNullGuard(outFn));