+ return 0;
+}
+
+void SketcherCurve::draw(VFrame *img, int alias)
+{
+ if( !points.size() ) return;
+ img->set_pixel_color(color, (~color>>24)&0xff);
+ const float fmx = 16383;
+ SketcherVPen *vpen = new_vpen(img);
+ vpen->set_draw_flags(alias);
+ FillRegion fill(points, vpen);
+ SketcherPoint *pnt0 = fill.next();
+ SketcherPoint *pnt1 = pnt0 ? fill.next() : 0;
+ SketcherPoint *pnt2 = pnt1 ? fill.next() : 0;
+ if( pnt0 && pnt1 && pnt2 ) {
+ SketcherPoint *pt0 = pnt0, *pt1 = pnt1, *pt2 = pnt2;
+ float ax,ay, bx,by, cx,cy, dx,dy, sx,sy;
+ bx = pt0->x; by = pt0->y;
+ cx = pt1->x; cy = pt1->y;
+ dx = pt2->x; dy = pt2->y;
+ smooth_axy(ax,ay, bx,by, cx,cy, dx,dy);
+ while( pt2 ) {
+ dx = pt2->x; dy = pt2->y;
+ switch( pt0->arc ) {
+ case ARC_CURVE:
+ if( convex(ax,ay, bx,by, cx,cy, dx,dy) >= 0 ) {
+ // s = ac thru b x bd thru c
+ intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
+ vpen->draw_smooth(bx,by, sx,sy, cx,cy);
+ break;
+ } // fall thru
+ case ARC_LINE:
+ vpen->draw_line(bx, by, cx, cy);
+ break;
+ }
+ ax = bx; ay = by; pt0 = pt1;
+ bx = cx; by = cy; pt1 = pt2;
+ cx = dx; cy = dy; pt2 = fill.next();
+ }
+ switch( pt1->arc ) {
+ case ARC_LINE:
+ vpen->draw_line(bx, by, cx, cy);
+ if( fill.exists() ) {
+ dx = pnt0->x; dy = pnt0->y;
+ vpen->draw_line(cx,cy, dx,dy);
+ }
+ break;
+ case ARC_CURVE: {
+ if( fill.exists() ) {
+ dx = pnt0->x; dy = pnt0->y;
+ intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
+ vpen->draw_smooth(bx,by, sx,sy, cx,cy);
+ ax = bx; ay = by;
+ bx = cx; by = cy;
+ cx = dx; cy = dy;
+ dx = pnt1->x; dy = pnt1->y;
+ }
+ else
+ smooth_dxy(dx,dy, ax,ay, bx,by, cx,cy);
+ intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
+ vpen->draw_smooth(bx,by, sx,sy, cx,cy);
+ break; }
+ }
+ fill.run();
+ }
+ else if( pnt0 && pnt1 ) {
+ vpen->draw_line(pnt0->x, pnt0->y, pnt1->x, pnt1->y);
+ }
+ else if( pnt0 ) {
+ vpen->draw_pixel(pnt0->x, pnt0->y, 1);