Przeglądaj źródła

cmSvgWriter.c : Added _cmSgWriterFlipY().

master
kevin 8 lat temu
rodzic
commit
bd1d645e81
2 zmienionych plików z 21 dodań i 1 usunięć
  1. 20
    0
      cmSvgWriter.c
  2. 1
    1
      cmSvgWriter.h

+ 20
- 0
cmSvgWriter.c Wyświetl plik

@@ -167,6 +167,24 @@ void _cmSvgSize( cmSvg_t* p, double* widthRef, double* heightRef )
167 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 189
 cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h,  const cmChar_t* cssFn, const cmChar_t* outFn )
172 190
 {
@@ -178,6 +196,8 @@ cmSvgRC_t cmSvgWriterWrite( cmSvgH_t h,  const cmChar_t* cssFn, const cmChar_t*
178 196
   cmFileH_t   fH        = cmFileNullHandle;
179 197
   
180 198
   _cmSvgSize(p, &svgWidth, &svgHeight );
199
+
200
+  _cmSvgWriterFlipY( p, svgHeight );
181 201
   
182 202
   if( cmFileOpen(&fH,outFn,kWriteFileFl,p->err.rpt) != kOkFileRC )
183 203
     return cmErrMsg(&p->err,kFileFailSvgRC,"SVG file create failed for '%s'.",cmStringNullGuard(outFn));

+ 1
- 1
cmSvgWriter.h Wyświetl plik

@@ -21,7 +21,7 @@ enum
21 21
   cmSvgRC_t cmSvgWriterFree(    cmSvgH_t* hp );
22 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 25
   cmSvgRC_t cmSvgWriterLine( cmSvgH_t h, double x0, double y0, double x1, double y1, const cmChar_t* cssClassLabel );
26 26
   cmSvgRC_t cmSvgWriterText( cmSvgH_t h, double  x, double y,  const cmChar_t* text, const cmChar_t* cssClassLabel );
27 27
 

Ładowanie…
Anuluj
Zapisz