4 #include "../gfxdevice.h"
7 static inline void gfxpoly_add_segment(segment_t**list, double _x1, double _y1, double _x2, double _y2)
14 segment_t*s = segment_new(x1, y1, x2, y2);
15 segment_insert_before(list, s);
19 gfxpoly_t* gfxpoly_fillToPoly(gfxline_t*line)
23 /* factor that determines into how many line fragments a spline is converted */
24 double subfraction = 2.4;//0.3
26 double lastx=0, lasty=0;
27 assert(!line || line[0].type == gfx_moveTo);
29 if(line->type == gfx_moveTo) {
30 } else if(line->type == gfx_lineTo) {
31 gfxpoly_add_segment(&s, lastx, lasty, line->x, line->y);
32 } else if(line->type == gfx_splineTo) {
33 int parts = (int)(sqrt(fabs(line->x-2*line->sx+lastx) +
34 fabs(line->y-2*line->sy+lasty))*subfraction);
36 double stepsize = 1.0/parts;
38 for(i=0;i<parts;i++) {
39 double t = (double)i*stepsize;
40 double x = line->x*t*t + 2*line->sx*t*(1-t) + x*(1-t)*(1-t);
41 double y = line->y*t*t + 2*line->sy*t*(1-t) + y*(1-t)*(1-t);
42 gfxpoly_add_segment(&s, lastx, lasty, x, y);
46 gfxpoly_add_segment(&s, lastx, lasty, line->x, line->y);