// -------------------------------------------------- status_t DrawShape::IterateBezierTo(int32 bezierCount, BPoint *control) { REPORT(kDebug, 0, "BezierTo"); for (int32 i = 0; i < bezierCount; i++, control += 3) { REPORT(kDebug, 0," (%f %f) (%f %f) (%f %f)", tx(control[0].x), ty(control[0].y), tx(control[1].x), ty(control[1].y), tx(control[2].x), ty(control[2].y)); if (TransformPath()) { BPoint p[4] = { fCurrentPoint, control[0], control[1], control[2] }; CreateBezierPath(p); } else { PDF_curveto(Pdf(), tx(control[0].x), ty(control[0].y), tx(control[1].x), ty(control[1].y), tx(control[2].x), ty(control[2].y)); } fCurrentPoint = control[2]; } return B_OK; }
static int mkline(gfxline_t*line, PDF*p, double mx, double my, double scale, char fill) { double x=0,y=0; char first = 1; int ret = 0; gfxline_t*free_line = 0; if(fill) { line = gfxline_restitch(gfxline_clone(line)); free_line = line; } while(line) { if(line->type == gfx_moveTo && (x!=line->x || y!=line->y || first)) { first = 0; PDF_moveto(p, line->x*scale+mx, line->y*scale+my); } else if(line->type == gfx_lineTo) { PDF_lineto(p, line->x*scale+mx, line->y*scale+my); ret = 1; } else { /* when converting a quadratic bezier to a cubic bezier, the two new control points are both 2/3 the way from the endpoints to the old control point */ double c1x = (x + line->sx*2)/3; double c1y = (y + line->sy*2)/3; double c2x = (line->x + line->sx*2)/3; double c2y = (line->y + line->sy*2)/3; PDF_curveto(p, c1x*scale+mx, c1y*scale+my, c2x*scale+mx, c2y*scale+my, line->x*scale+mx, line->y*scale+my); ret = 1; } x = line->x; y = line->y; line = line->next; } if(free_line) gfxline_free(free_line); return ret; }