+gfxline_t*gfxline_from_gfxpoly(gfxpoly_t*poly)
+{
+ gfxpolystroke_t*stroke;
+ int count = 0;
+ for(stroke=poly->strokes;stroke;stroke=stroke->next) {
+ assert(stroke->num_points);
+ count += stroke->num_points;
+ }
+ if(!count) return 0;
+ gfxline_t*l = malloc(sizeof(gfxline_t)*count);
+ count = 0;
+ /* TODO: it might make sense to concatenate strokes */
+ for(stroke=poly->strokes;stroke;stroke=stroke->next) {
+ int t;
+ for(t=0;t<stroke->num_points;t++) {
+ l[count+t].x = stroke->points[t].x * poly->gridsize;
+ l[count+t].y = stroke->points[t].y * poly->gridsize;
+ l[count+t].type = gfx_lineTo;
+ l[count+t].next = &l[count+t+1];
+ }
+ l[count].type = gfx_moveTo;
+ count+=stroke->num_points;
+ }
+ l[count-1].next = 0;
+ return l;
+}
+