From bd1d645e81af5a117af99309374a0ee205961db2 Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 17 Aug 2016 18:58:42 -0400 Subject: [PATCH] cmSvgWriter.c : Added _cmSgWriterFlipY(). --- cmSvgWriter.c | 20 ++++++++++++++++++++ cmSvgWriter.h | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cmSvgWriter.c b/cmSvgWriter.c index d854932..5533bfb 100644 --- a/cmSvgWriter.c +++ b/cmSvgWriter.c @@ -167,6 +167,24 @@ void _cmSvgSize( cmSvg_t* p, double* widthRef, double* heightRef ) *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 ) { @@ -178,6 +196,8 @@ cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h, const cmChar_t* cssFn, const cmChar_t* cmFileH_t fH = cmFileNullHandle; _cmSvgSize(p, &svgWidth, &svgHeight ); + + _cmSvgWriterFlipY( p, svgHeight ); if( cmFileOpen(&fH,outFn,kWriteFileFl,p->err.rpt) != kOkFileRC ) return cmErrMsg(&p->err,kFileFailSvgRC,"SVG file create failed for '%s'.",cmStringNullGuard(outFn)); diff --git a/cmSvgWriter.h b/cmSvgWriter.h index aca0a43..83470d0 100644 --- a/cmSvgWriter.h +++ b/cmSvgWriter.h @@ -21,7 +21,7 @@ enum cmSvgRC_t cmSvgWriterFree( cmSvgH_t* hp ); bool cmSvgWriterIsValid( cmSvgH_t h ); - cmSvgRC_t cmSvgWriterRect( cmSvgH_t h, double x, double y, double ww, double hh, const cmChar_t* cssClassLabel ); + cmSvgRC_t cmSvgWriterRect( cmSvgH_t h, double x, double y, double ww, double hh, const cmChar_t* cssClassLabel ); cmSvgRC_t cmSvgWriterLine( cmSvgH_t h, double x0, double y0, double x1, double y1, const cmChar_t* cssClassLabel ); cmSvgRC_t cmSvgWriterText( cmSvgH_t h, double x, double y, const cmChar_t* text, const cmChar_t* cssClassLabel );