+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;
+}
+
+static windcontext_t onepolygon = {1};
+gfxline_t* gfxpoly_circular_to_evenodd(gfxline_t*line, double gridsize)
+{
+ gfxpoly_t*poly = gfxpoly_from_fill(line, gridsize);
+ gfxpoly_t*poly2 = gfxpoly_process(poly, 0, &windrule_circular, &onepolygon);
+ gfxline_t*line2 = gfxline_from_gfxpoly(poly2);
+ gfxpoly_destroy(poly);
+ gfxpoly_destroy(poly2);
+ return line2;
+}
+
+gfxpoly_t* gfxpoly_createbox(double x1, double y1,double x2, double y2, double gridsize)
+{
+ gfxline_t* line = gfxline_makerectangle(x1, y1, x2, y2);
+ gfxpoly_t* poly = gfxpoly_from_fill(line, gridsize);
+ gfxline_free(line);
+ return poly;
+}
+