void BezierCurveN<3>::feed(PathSink &sink, bool moveto_initial) const
{
    if (moveto_initial) {
        sink.moveTo(controlPoint(0));
    }
    sink.curveTo(controlPoint(1), controlPoint(2), controlPoint(3));
}
void BezierCurveN<1>::feed(PathSink &sink, bool moveto_initial) const
{
    if (moveto_initial) {
        sink.moveTo(controlPoint(0));
    }
    sink.lineTo(controlPoint(1));
}
void BezierCurve::feed(PathSink &sink, bool moveto_initial) const
{
    if (size() > 4) {
        Curve::feed(sink, moveto_initial);
        return;
    }

    Point ip = controlPoint(0);
    if (moveto_initial) {
        sink.moveTo(ip);
    }
    switch (size()) {
    case 2:
        sink.lineTo(controlPoint(1));
        break;
    case 3:
        sink.quadTo(controlPoint(1), controlPoint(2));
        break;
    case 4:
        sink.curveTo(controlPoint(1), controlPoint(2), controlPoint(3));
        break;
    default:
        // TODO: add a path sink method that accepts a vector of control points
        //       and converts to cubic spline by default
        assert(false);
        break;
    }
}
Пример #4
0
void Curve::feed(PathSink &sink, bool moveto_initial) const
{
    std::vector<Point> pts;
    sbasis_to_bezier(pts, toSBasis(), 2); //TODO: use something better!
    if (moveto_initial) {
        sink.moveTo(initialPoint());
    }
    sink.curveTo(pts[0], pts[1], pts[2]);
}
Пример #5
0
static void
StreamPathToSinkApplierFunc(void *vinfo, const CGPathElement *element)
{
  PathSink *sink = reinterpret_cast<PathSink*>(vinfo);
  switch (element->type) {
    case kCGPathElementMoveToPoint:
      {
        CGPoint pt = element->points[0];
        sink->MoveTo(CGPointToPoint(pt));
        break;
      }
    case kCGPathElementAddLineToPoint:
      {
        CGPoint pt = element->points[0];
        sink->LineTo(CGPointToPoint(pt));
        break;
      }
    case kCGPathElementAddQuadCurveToPoint:
      {
        CGPoint cpt = element->points[0];
        CGPoint pt  = element->points[1];
        sink->QuadraticBezierTo(CGPointToPoint(cpt),
                                CGPointToPoint(pt));
        break;
      }
    case kCGPathElementAddCurveToPoint:
      {
        CGPoint cpt1 = element->points[0];
        CGPoint cpt2 = element->points[1];
        CGPoint pt   = element->points[2];
        sink->BezierTo(CGPointToPoint(cpt1),
                       CGPointToPoint(cpt2),
                       CGPointToPoint(pt));
        break;
      }
    case kCGPathElementCloseSubpath:
      {
        sink->Close();
        break;
      }
  }
}