Code

switch to using SVG::PathString for building paths
[inkscape.git] / src / svg / svg-path.cpp
1 #define __SP_SVG_PARSE_C__
2 /* 
3    svg-path.c: Parse SVG path element data into bezier path.
4  
5    Copyright (C) 2000 Eazel, Inc.
6    Copyright (C) 2000 Lauris Kaplinski
7    Copyright (C) 2001 Ximian, Inc.
8   
9    This program is free software; you can redistribute it and/or
10    modify it under the terms of the GNU General Public License as
11    published by the Free Software Foundation; either version 2 of the
12    License, or (at your option) any later version.
13   
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17    General Public License for more details.
18   
19    You should have received a copy of the GNU General Public
20    License along with this program; if not, write to the
21    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22    Boston, MA 02111-1307, USA.
23   
24    Authors:
25      Raph Levien <raph@artofcode.com>
26      Lauris Kaplinski <lauris@ximian.com>
27 */
29 #include <cassert>
30 #include <glib/gmem.h>
31 #include <glib/gmessages.h>
32 #include <glib/gstrfuncs.h>
34 #include "libnr/n-art-bpath.h"
35 #include "gnome-canvas-bpath-util.h"
36 #include "svg/path-string.h"
39 /* This module parses an SVG path element into an RsvgBpathDef.
41    At present, there is no support for <marker> or any other contextual
42    information from the SVG file. The API will need to change rather
43    significantly to support these.
45    Reference: SVG working draft 3 March 2000, section 8.
46 */
48 #ifndef M_PI
49 #define M_PI 3.14159265358979323846
50 #endif  /*  M_PI  */
52 /* We are lazy ;-) (Lauris) */
53 #define rsvg_bpath_def_new gnome_canvas_bpath_def_new
54 #define rsvg_bpath_def_moveto gnome_canvas_bpath_def_moveto
55 #define rsvg_bpath_def_lineto gnome_canvas_bpath_def_lineto
56 #define rsvg_bpath_def_curveto gnome_canvas_bpath_def_curveto
57 #define rsvg_bpath_def_closepath gnome_canvas_bpath_def_closepath
59 struct RSVGParsePathCtx {
60     GnomeCanvasBpathDef *bpath;
61     double cpx, cpy;  /* current point */
62     double rpx, rpy;  /* reflection point (for 's' and 't' commands) */
63     double spx, spy;  /* beginning of current subpath point */
64     char cmd;         /* current command (lowercase) */
65     int param;        /* parameter number */
66     bool rel;         /* true if relative coords */
67     double params[7]; /* parameters that have been parsed */
68 };
70 static void rsvg_path_arc_segment(RSVGParsePathCtx *ctx,
71               double xc, double yc,
72               double th0, double th1,
73               double rx, double ry, double x_axis_rotation)
74 {
75     double sin_th, cos_th;
76     double a00, a01, a10, a11;
77     double x1, y1, x2, y2, x3, y3;
78     double t;
79     double th_half;
81     sin_th = sin (x_axis_rotation * (M_PI / 180.0));
82     cos_th = cos (x_axis_rotation * (M_PI / 180.0)); 
83     /* inverse transform compared with rsvg_path_arc */
84     a00 = cos_th * rx;
85     a01 = -sin_th * ry;
86     a10 = sin_th * rx;
87     a11 = cos_th * ry;
89     th_half = 0.5 * (th1 - th0);
90     t = (8.0 / 3.0) * sin(th_half * 0.5) * sin(th_half * 0.5) / sin(th_half);
91     x1 = xc + cos (th0) - t * sin (th0);
92     y1 = yc + sin (th0) + t * cos (th0);
93     x3 = xc + cos (th1);
94     y3 = yc + sin (th1);
95     x2 = x3 + t * sin (th1);
96     y2 = y3 - t * cos (th1);
97     rsvg_bpath_def_curveto(ctx->bpath,
98                            a00 * x1 + a01 * y1, a10 * x1 + a11 * y1,
99                            a00 * x2 + a01 * y2, a10 * x2 + a11 * y2,
100                            a00 * x3 + a01 * y3, a10 * x3 + a11 * y3);
103 /**
104  * rsvg_path_arc: Add an RSVG arc to the path context.
105  * @ctx: Path context.
106  * @rx: Radius in x direction (before rotation).
107  * @ry: Radius in y direction (before rotation).
108  * @x_axis_rotation: Rotation angle for axes.
109  * @large_arc_flag: 0 for arc length <= 180, 1 for arc >= 180.
110  * @sweep: 0 for "negative angle", 1 for "positive angle".
111  * @x: New x coordinate.
112  * @y: New y coordinate.
113  *
114  **/
115 static void rsvg_path_arc (RSVGParsePathCtx *ctx,
116                            double rx, double ry, double x_axis_rotation,
117                            int large_arc_flag, int sweep_flag,
118                            double x, double y)
120     double sin_th, cos_th;
121     double a00, a01, a10, a11;
122     double x0, y0, x1, y1, xc, yc;
123     double d, sfactor, sfactor_sq;
124     double th0, th1, th_arc;
125     double px, py, pl;
126     int i, n_segs;
128     sin_th = sin (x_axis_rotation * (M_PI / 180.0));
129     cos_th = cos (x_axis_rotation * (M_PI / 180.0));
131     /*                                                                            
132                                                                                   Correction of out-of-range radii as described in Appendix F.6.6:           
134                                                                                   1. Ensure radii are non-zero (Done?).                                      
135                                                                                   2. Ensure that radii are positive.                                         
136                                                                                   3. Ensure that radii are large enough.                                     
137     */                                                                            
139     if(rx < 0.0) rx = -rx;                                                        
140     if(ry < 0.0) ry = -ry;                                                        
142     px = cos_th * (ctx->cpx - x) * 0.5 + sin_th * (ctx->cpy - y) * 0.5;           
143     py = cos_th * (ctx->cpy - y) * 0.5 - sin_th * (ctx->cpx - x) * 0.5;           
144     pl = (px * px) / (rx * rx) + (py * py) / (ry * ry);                           
146     if(pl > 1.0)                                                                  
147     {                                                                             
148         pl  = sqrt(pl);                                                           
149         rx *= pl;                                                                 
150         ry *= pl;                                                                 
151     }                                                                             
153     /* Proceed with computations as described in Appendix F.6.5 */                
155     a00 = cos_th / rx;
156     a01 = sin_th / rx;
157     a10 = -sin_th / ry;
158     a11 = cos_th / ry;
159     x0 = a00 * ctx->cpx + a01 * ctx->cpy;
160     y0 = a10 * ctx->cpx + a11 * ctx->cpy;
161     x1 = a00 * x + a01 * y;
162     y1 = a10 * x + a11 * y;
163     /* (x0, y0) is current point in transformed coordinate space.
164        (x1, y1) is new point in transformed coordinate space.
166        The arc fits a unit-radius circle in this space.
167     */
168     d = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
169     sfactor_sq = 1.0 / d - 0.25;
170     if (sfactor_sq < 0) sfactor_sq = 0;
171     sfactor = sqrt (sfactor_sq);
172     if (sweep_flag == large_arc_flag) sfactor = -sfactor;
173     xc = 0.5 * (x0 + x1) - sfactor * (y1 - y0);
174     yc = 0.5 * (y0 + y1) + sfactor * (x1 - x0);
175     /* (xc, yc) is center of the circle. */
177     th0 = atan2 (y0 - yc, x0 - xc);
178     th1 = atan2 (y1 - yc, x1 - xc);
180     th_arc = th1 - th0;
181     if (th_arc < 0 && sweep_flag)
182         th_arc += 2 * M_PI;
183     else if (th_arc > 0 && !sweep_flag)
184         th_arc -= 2 * M_PI;
186     n_segs = (int) ceil (fabs (th_arc / (M_PI * 0.5 + 0.001)));
188     for (i = 0; i < n_segs; i++) {
189         rsvg_path_arc_segment(ctx, xc, yc,
190                               th0 + i * th_arc / n_segs,
191                               th0 + (i + 1) * th_arc / n_segs,
192                               rx, ry, x_axis_rotation);
193     }
195     ctx->cpx = x;
196     ctx->cpy = y;
200 /* supply defaults for missing parameters, assuming relative coordinates
201    are to be interpreted as x,y */
202 static void rsvg_parse_path_default_xy(RSVGParsePathCtx *ctx, int n_params)
204     int i;
206     if (ctx->rel) {
207         for (i = ctx->param; i < n_params; i++) {
208             if (i > 2)
209                 ctx->params[i] = ctx->params[i - 2];
210             else if (i == 1)
211                 ctx->params[i] = ctx->cpy;
212             else if (i == 0)
213                 /* we shouldn't get here (usually ctx->param > 0 as
214                    precondition) */
215                 ctx->params[i] = ctx->cpx;
216         }
217     } else {
218         for (i = ctx->param; i < n_params; i++) {
219             ctx->params[i] = 0.0;
220         }
221     }
224 static void rsvg_parse_path_do_cmd(RSVGParsePathCtx *ctx, bool final)
226     double x1, y1, x2, y2, x3, y3;
228 #ifdef VERBOSE
229     int i;
231     g_print ("parse_path %c:", ctx->cmd);
232     for (i = 0; i < ctx->param; i++) {
233         g_print(" %f", ctx->params[i]);
234     }
235     g_print (final ? ".\n" : "\n");
236 #endif
238     switch (ctx->cmd) {
239     case 'm':
240         /* moveto */
241         if (ctx->param == 2 || final)
242         {
243             rsvg_parse_path_default_xy (ctx, 2);
244 #ifdef VERBOSE
245             g_print ("'m' moveto %g,%g\n",
246                      ctx->params[0], ctx->params[1]);
247 #endif
248             rsvg_bpath_def_moveto (ctx->bpath,
249                                    ctx->params[0], ctx->params[1]);
250             ctx->cpx = ctx->rpx = ctx->spx = ctx->params[0];
251             ctx->cpy = ctx->rpy = ctx->spy = ctx->params[1];
252             ctx->param = 0;
253             ctx->cmd = 'l';
254         }
255         break;
256     case 'l':
257         /* lineto */
258         if (ctx->param == 2 || final)
259         {
260             rsvg_parse_path_default_xy (ctx, 2);
261 #ifdef VERBOSE
262             g_print ("'l' lineto %g,%g\n",
263                      ctx->params[0], ctx->params[1]);
264 #endif
265             rsvg_bpath_def_lineto (ctx->bpath,
266                                    ctx->params[0], ctx->params[1]);
267             ctx->cpx = ctx->rpx = ctx->params[0];
268             ctx->cpy = ctx->rpy = ctx->params[1];
269             ctx->param = 0;
270         }
271         break;
272     case 'c':
273         /* curveto */
274         if (ctx->param == 6 || final )
275         {
276             rsvg_parse_path_default_xy (ctx, 6);
277             x1 = ctx->params[0];
278             y1 = ctx->params[1];
279             x2 = ctx->params[2];
280             y2 = ctx->params[3];
281             x3 = ctx->params[4];
282             y3 = ctx->params[5];
283 #ifdef VERBOSE
284             g_print ("'c' curveto %g,%g %g,%g, %g,%g\n",
285                      x1, y1, x2, y2, x3, y3);
286 #endif
287             rsvg_bpath_def_curveto (ctx->bpath,
288                                     x1, y1, x2, y2, x3, y3);
289             ctx->rpx = x2;
290             ctx->rpy = y2;
291             ctx->cpx = x3;
292             ctx->cpy = y3;
293             ctx->param = 0;
294         }
295         break;
296     case 's':
297         /* smooth curveto */
298         if (ctx->param == 4 || final)
299         {
300             rsvg_parse_path_default_xy (ctx, 4);
301             x1 = 2 * ctx->cpx - ctx->rpx;
302             y1 = 2 * ctx->cpy - ctx->rpy;
303             x2 = ctx->params[0];
304             y2 = ctx->params[1];
305             x3 = ctx->params[2];
306             y3 = ctx->params[3];
307 #ifdef VERBOSE
308             g_print ("'s' curveto %g,%g %g,%g, %g,%g\n",
309                      x1, y1, x2, y2, x3, y3);
310 #endif
311             rsvg_bpath_def_curveto (ctx->bpath,
312                                     x1, y1, x2, y2, x3, y3);
313             ctx->rpx = x2;
314             ctx->rpy = y2;
315             ctx->cpx = x3;
316             ctx->cpy = y3;
317             ctx->param = 0;
318         }
319         break;
320     case 'h':
321         /* horizontal lineto */
322         if (ctx->param == 1) {
323 #ifdef VERBOSE
324             g_print ("'h' lineto %g,%g\n",
325                      ctx->params[0], ctx->cpy);
326 #endif
327             rsvg_bpath_def_lineto (ctx->bpath,
328                                    ctx->params[0], ctx->cpy);
329             ctx->cpx = ctx->rpx = ctx->params[0];
330             ctx->param = 0;
331         }
332         break;
333     case 'v':
334         /* vertical lineto */
335         if (ctx->param == 1) {
336 #ifdef VERBOSE
337             g_print ("'v' lineto %g,%g\n",
338                      ctx->cpx, ctx->params[0]);
339 #endif
340             rsvg_bpath_def_lineto (ctx->bpath,
341                                    ctx->cpx, ctx->params[0]);
342             ctx->cpy = ctx->rpy = ctx->params[0];
343             ctx->param = 0;
344         }
345         break;
346     case 'q':
347         /* quadratic bezier curveto */
349         /* non-normative reference:
350            http://www.icce.rug.nl/erikjan/bluefuzz/beziers/beziers/beziers.html
351         */
352         if (ctx->param == 4 || final)
353         {
354             rsvg_parse_path_default_xy (ctx, 4);
355             /* raise quadratic bezier to cubic */
356             x1 = (ctx->cpx + 2 * ctx->params[0]) * (1.0 / 3.0);
357             y1 = (ctx->cpy + 2 * ctx->params[1]) * (1.0 / 3.0);
358             x3 = ctx->params[2];
359             y3 = ctx->params[3];
360             x2 = (x3 + 2 * ctx->params[0]) * (1.0 / 3.0);
361             y2 = (y3 + 2 * ctx->params[1]) * (1.0 / 3.0);
362 #ifdef VERBOSE
363             g_print("'q' curveto %g,%g %g,%g, %g,%g\n",
364                     x1, y1, x2, y2, x3, y3);
365 #endif
366             rsvg_bpath_def_curveto(ctx->bpath,
367                                    x1, y1, x2, y2, x3, y3);
368             ctx->rpx = ctx->params[0];
369             ctx->rpy = ctx->params[1];
370             ctx->cpx = x3;
371             ctx->cpy = y3;
372             ctx->param = 0;
373         }
374         break;
375     case 't':
376         /* Truetype quadratic bezier curveto */
377         if (ctx->param == 2 || final) {
378             double xc, yc; /* quadratic control point */
380             xc = 2 * ctx->cpx - ctx->rpx;
381             yc = 2 * ctx->cpy - ctx->rpy;
382             /* generate a quadratic bezier with control point = xc, yc */
383             x1 = (ctx->cpx + 2 * xc) * (1.0 / 3.0);
384             y1 = (ctx->cpy + 2 * yc) * (1.0 / 3.0);
385             x3 = ctx->params[0];
386             y3 = ctx->params[1];
387             x2 = (x3 + 2 * xc) * (1.0 / 3.0);
388             y2 = (y3 + 2 * yc) * (1.0 / 3.0);
389 #ifdef VERBOSE
390             g_print ("'t' curveto %g,%g %g,%g, %g,%g\n",
391                      x1, y1, x2, y2, x3, y3);
392 #endif
393             rsvg_bpath_def_curveto (ctx->bpath,
394                                     x1, y1, x2, y2, x3, y3);
395             ctx->rpx = xc;
396             ctx->rpy = yc;
397             ctx->cpx = x3;
398             ctx->cpy = y3;
399             ctx->param = 0;
400         } else if (final) {
401             if (ctx->param > 2) {
402                 rsvg_parse_path_default_xy(ctx, 4);
403                 /* raise quadratic bezier to cubic */
404                 x1 = (ctx->cpx + 2 * ctx->params[0]) * (1.0 / 3.0);
405                 y1 = (ctx->cpy + 2 * ctx->params[1]) * (1.0 / 3.0);
406                 x3 = ctx->params[2];
407                 y3 = ctx->params[3];
408                 x2 = (x3 + 2 * ctx->params[0]) * (1.0 / 3.0);
409                 y2 = (y3 + 2 * ctx->params[1]) * (1.0 / 3.0);
410 #ifdef VERBOSE
411                 g_print ("'t' curveto %g,%g %g,%g, %g,%g\n",
412                          x1, y1, x2, y2, x3, y3);
413 #endif
414                 rsvg_bpath_def_curveto (ctx->bpath,
415                                         x1, y1, x2, y2, x3, y3);
416                 ctx->rpx = x2;
417                 ctx->rpy = y2;
418                 ctx->cpx = x3;
419                 ctx->cpy = y3;
420             } else {
421                 rsvg_parse_path_default_xy(ctx, 2);
422 #ifdef VERBOSE
423                 g_print ("'t' lineto %g,%g\n",
424                          ctx->params[0], ctx->params[1]);
425 #endif
426                 rsvg_bpath_def_lineto(ctx->bpath,
427                                       ctx->params[0], ctx->params[1]);
428                 ctx->cpx = ctx->rpx = ctx->params[0];
429                 ctx->cpy = ctx->rpy = ctx->params[1];
430             }
431             ctx->param = 0;
432         }
433         break;
434     case 'a':
435         if (ctx->param == 7 || final)
436         {
437             rsvg_path_arc(ctx,
438                           ctx->params[0], ctx->params[1], ctx->params[2],
439                           (int) ctx->params[3], (int) ctx->params[4],
440                           ctx->params[5], ctx->params[6]);
441             ctx->param = 0;
442         }
443         break;
444     default:
445         ctx->param = 0;
446     }
449 static void rsvg_parse_path_data(RSVGParsePathCtx *ctx, const char *data)
451     int i = 0;
452     double val = 0;
453     char c = 0;
454     bool in_num = false;
455     bool in_frac = false;
456     bool in_exp = false;
457     bool exp_wait_sign = false;
458     int sign = 0;
459     int exp = 0;
460     int exp_sign = 0;
461     double frac = 0.0;
463     /* fixme: Do better error processing: e.g. at least stop parsing as soon as we find an error.
464      * At some point we'll need to do all of
465      * http://www.w3.org/TR/SVG11/implnote.html#ErrorProcessing.
466      */
467     for (i = 0; ; i++)
468     {
469         c = data[i];
470         if (c >= '0' && c <= '9')
471         {
472             /* digit */
473             if (in_num)
474             {
475                 if (in_exp)
476                 {
477                     exp = (exp * 10) + c - '0';
478                     exp_wait_sign = false;
479                 }
480                 else if (in_frac)
481                     val += (frac *= 0.1) * (c - '0');
482                 else
483                     val = (val * 10) + c - '0';
484             }
485             else
486             {
487                 in_num = true;
488                 assert(!in_frac && !in_exp);
489                 exp = 0;
490                 exp_sign = 1;
491                 exp_wait_sign = false;
492                 val = c - '0';
493                 sign = 1;
494             }
495         }
496         else if (c == '.' && !(in_frac || in_exp))
497         {
498             if (!in_num)
499             {
500                 in_num = true;
501                 assert(!in_exp);
502                 exp = 0;
503                 exp_sign = 1;
504                 exp_wait_sign = false;
505                 val = 0;
506                 sign = 1;
507             }
508             in_frac = true;
509             frac = 1;
510         }
511         else if ((c == 'E' || c == 'e') && in_num)
512         {
513             /* fixme: Should we add `&& !in_exp' to the above condition?
514              * It looks like the current code will parse `1e3e4' (as 1e4). */
515             in_exp = true;
516             exp_wait_sign = true;
517             exp = 0;
518             exp_sign = 1;
519         }
520         else if ((c == '+' || c == '-') && in_exp)
521         {
522             exp_sign = c == '+' ? 1 : -1;
523         }
524         else if (in_num)
525         {
526             /* end of number */
528             val *= sign * pow (10, exp_sign * exp);
529             if (ctx->rel)
530             {
531                 /* Handle relative coordinates. This switch statement attempts
532                    to determine _what_ the coords are relative to. This is
533                    underspecified in the 12 Apr working draft. */
534                 switch (ctx->cmd)
535                 {
536                 case 'l':
537                 case 'm':
538                 case 'c':
539                 case 's':
540                 case 'q':
541                 case 't':
542                     if ( ctx->param & 1 ) {
543                         val += ctx->cpy; /* odd param, y */
544                     } else {
545                         val += ctx->cpx; /* even param, x */
546                     }
547                     break;
548                 case 'a':
549                     /* rule: sixth and seventh are x and y, rest are not
550                        relative */
551                     if (ctx->param == 5)
552                         val += ctx->cpx;
553                     else if (ctx->param == 6)
554                         val += ctx->cpy;
555                     break;
556                 case 'h':
557                     /* rule: x-relative */
558                     val += ctx->cpx;
559                     break;
560                 case 'v':
561                     /* rule: y-relative */
562                     val += ctx->cpy;
563                     break;
564                 }
565             }
566             ctx->params[ctx->param++] = val;
567             rsvg_parse_path_do_cmd (ctx, false);
568             if (c=='.') {
569                 in_num = true;
570                 val = 0;
571                 in_frac = true;
572                 in_exp = false;
573                 frac = 1;
574             }
575             else {
576                 in_num = false;
577                 in_frac = false;
578                 in_exp = false;
579             }
580         }
582         if (c == '\0')
583             break;
584         else if ((c == '+' || c == '-') && !exp_wait_sign)
585         {
586             sign = c == '+' ? 1 : -1;;
587             val = 0;
588             in_num = true;
589             in_frac = false;
590             in_exp = false;
591             exp = 0;
592             exp_sign = 1;
593             exp_wait_sign = false;
594         }
595         else if (c == 'z' || c == 'Z')
596         {
597             if (ctx->param)
598                 rsvg_parse_path_do_cmd (ctx, true);
599             rsvg_bpath_def_closepath (ctx->bpath);
601             ctx->cmd = 'm';
602             ctx->params[0] = ctx->cpx = ctx->rpx = ctx->spx;
603             ctx->params[1] = ctx->cpy = ctx->rpy = ctx->spy;
604             ctx->param = 2;
605         }
606         else if (c >= 'A' && c <= 'Z' && c != 'E')
607         {
608             if (ctx->param)
609                 rsvg_parse_path_do_cmd (ctx, true);
610             ctx->cmd = c + 'a' - 'A';
611             ctx->rel = false;
612         }
613         else if (c >= 'a' && c <= 'z' && c != 'e')
614         {
615             if (ctx->param)
616                 rsvg_parse_path_do_cmd (ctx, true);
617             ctx->cmd = c;
618             ctx->rel = true;
619         }
620         /* else c _should_ be whitespace or , */
621     }
625 NArtBpath *sp_svg_read_path(gchar const *str)
627     RSVGParsePathCtx ctx;
628     NArtBpath *bpath;
630     ctx.bpath = gnome_canvas_bpath_def_new ();
631     ctx.cpx = 0.0;
632     ctx.cpy = 0.0;
633     ctx.cmd = 0;
634     ctx.param = 0;
636     rsvg_parse_path_data (&ctx, str);
638     if (ctx.param && ctx.cmd != 'm') {
639         rsvg_parse_path_do_cmd (&ctx, TRUE);
640     }
642     gnome_canvas_bpath_def_art_finish (ctx.bpath);
644     bpath = g_new (NArtBpath, ctx.bpath->n_bpath);
645     memcpy (bpath, ctx.bpath->bpath, ctx.bpath->n_bpath * sizeof (NArtBpath));
646     g_assert ((bpath + ctx.bpath->n_bpath - 1)->code == NR_END);
647     gnome_canvas_bpath_def_unref (ctx.bpath);
649     return bpath;
652 gchar *sp_svg_write_path(NArtBpath const *bpath)
654     Inkscape::SVGOStringStream os;
655     bool closed=false;
656     
657     g_return_val_if_fail (bpath != NULL, NULL);
659     Inkscape::SVG::PathString str;
661     for (int i = 0; bpath[i].code != NR_END; i++){
662         switch (bpath [i].code){
663         case NR_LINETO:
664             str.lineTo(bpath[i].x3, bpath[i].y3);
665             break;
667         case NR_CURVETO:
668             str.curveTo(bpath[i].x1, bpath[i].y1,
669                         bpath[i].x2, bpath[i].y2,
670                         bpath[i].x3, bpath[i].y3);
671             break;
673         case NR_MOVETO_OPEN:
674         case NR_MOVETO:
675             if (closed) {
676                 str.closePath();
677             }
678             closed = ( bpath[i].code == NR_MOVETO );
679             str.moveTo(bpath[i].x3, bpath[i].y3);
680             break;
682         default:
683             g_assert_not_reached ();
684         }
685     }
686     if (closed) {
687         str.closePath();
688     }
690     return g_strdup(str.c_str());
693 /*
694   Local Variables:
695   mode:c++
696   c-file-style:"stroustrup"
697   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
698   indent-tabs-mode:nil
699   fill-column:99
700   End:
701 */
702 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :