Browse Source

cmSvgWriter.c : Added _cmSgWriterFlipY().

master
kevin 8 years ago
parent
commit
bd1d645e81
2 changed files with 21 additions and 1 deletions
  1. 20
    0
      cmSvgWriter.c
  2. 1
    1
      cmSvgWriter.h

+ 20
- 0
cmSvgWriter.c View File

167
   *heightRef = max_y - min_y;
167
   *heightRef = max_y - min_y;
168
 }
168
 }
169
 
169
 
170
+void _cmSvgWriterFlipY( cmSvg_t* p, unsigned height )
171
+{
172
+  cmSvgEle_t* e = p->elist;
173
+  for(; e!=NULL; e=e->link)
174
+  {
175
+    e->y0 = (-e->y0) + height;
176
+    e->y1 = (-e->y1) + height;
177
+
178
+    if( e->id == kRectSvgId )
179
+    {
180
+      double t = e->y1;
181
+      e->y1 = e->y0;
182
+      e->y0 = t;
183
+    }
184
+    
185
+  }
186
+}
187
+
170
 
188
 
171
 cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h,  const cmChar_t* cssFn, const cmChar_t* outFn )
189
 cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h,  const cmChar_t* cssFn, const cmChar_t* outFn )
172
 {
190
 {
178
   cmFileH_t   fH        = cmFileNullHandle;
196
   cmFileH_t   fH        = cmFileNullHandle;
179
   
197
   
180
   _cmSvgSize(p, &svgWidth, &svgHeight );
198
   _cmSvgSize(p, &svgWidth, &svgHeight );
199
+
200
+  _cmSvgWriterFlipY( p, svgHeight );
181
   
201
   
182
   if( cmFileOpen(&fH,outFn,kWriteFileFl,p->err.rpt) != kOkFileRC )
202
   if( cmFileOpen(&fH,outFn,kWriteFileFl,p->err.rpt) != kOkFileRC )
183
     return cmErrMsg(&p->err,kFileFailSvgRC,"SVG file create failed for '%s'.",cmStringNullGuard(outFn));
203
     return cmErrMsg(&p->err,kFileFailSvgRC,"SVG file create failed for '%s'.",cmStringNullGuard(outFn));

+ 1
- 1
cmSvgWriter.h View File

21
   cmSvgRC_t cmSvgWriterFree(    cmSvgH_t* hp );
21
   cmSvgRC_t cmSvgWriterFree(    cmSvgH_t* hp );
22
   bool      cmSvgWriterIsValid( cmSvgH_t h );
22
   bool      cmSvgWriterIsValid( cmSvgH_t h );
23
   
23
   
24
-  cmSvgRC_t cmSvgWriterRect( cmSvgH_t h, double  x, double y,  double ww,  double hh,  const cmChar_t* cssClassLabel );
24
+  cmSvgRC_t cmSvgWriterRect( cmSvgH_t h, double  x, double y,  double ww, double hh, const cmChar_t* cssClassLabel );
25
   cmSvgRC_t cmSvgWriterLine( cmSvgH_t h, double x0, double y0, double x1, double y1, const cmChar_t* cssClassLabel );
25
   cmSvgRC_t cmSvgWriterLine( cmSvgH_t h, double x0, double y0, double x1, double y1, const cmChar_t* cssClassLabel );
26
   cmSvgRC_t cmSvgWriterText( cmSvgH_t h, double  x, double y,  const cmChar_t* text, const cmChar_t* cssClassLabel );
26
   cmSvgRC_t cmSvgWriterText( cmSvgH_t h, double  x, double y,  const cmChar_t* text, const cmChar_t* cssClassLabel );
27
 
27
 

Loading…
Cancel
Save