MDCPathGenerator

@interface MDCPathGenerator : NSObject

MDCPathGenerator is a factory for creating CGPaths. Describe your path with the lineTo and addArc… methods, then call appendToCGPath to append them to a CGPath.

Note

MDCPathGenerators always start at (0, 0) and end at @c endPoint.
  • The start point of the generated paths.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGPoint startPoint;
  • The end point of the generated paths.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGPoint endPoint;
  • Returns an initialized MDCPathGenerator instance with a startPoint of CGPointZero.

    Declaration

    Objective-C

    + (nonnull instancetype)pathGenerator;
  • Returns an initialized MDCPathGenerator instance.

    Declaration

    Objective-C

    + (nonnull instancetype)pathGeneratorWithStartPoint:(CGPoint)startPoint;

    Parameters

    startPoint

    The start point of the generated paths.

  • Appends a straight line segment to the path generator. Analogous to CGPathAddLineToPoint.

    Declaration

    Objective-C

    - (void)addLineToPoint:(CGPoint)point;

    Parameters

    point

    The end point of the line segment.

  • Appends an arc to the path generator, possibly preceded by a straight line segment. Analogous to CGPathAddArc.

    Declaration

    Objective-C

    - (void)addArcWithCenter:(CGPoint)center
                      radius:(CGFloat)radius
                  startAngle:(CGFloat)startAngle
                    endAngle:(CGFloat)endAngle
                   clockwise:(BOOL)clockwise;

    Parameters

    center

    The center of the arc.

    radius

    The radius of the arc.

    startAngle

    The start angle of the arc.

    endAngle

    The end angle of the arc.

    clockwise

    Whether the arc is clockwise (YES) or counterclockwise (NO).

  • Appends an arc to the path generator, possibly preceded by a straight line segment. Analogous to CGPathAddArcToPoint. The arc will be drawn inside the corner created by the start of the arc, tangentPoint and toPoint.

    Declaration

    Objective-C

    - (void)addArcWithTangentPoint:(CGPoint)tangentPoint
                           toPoint:(CGPoint)toPoint
                            radius:(CGFloat)radius;

    Parameters

    tangentPoint

    The corner of the arc.

    toPoint

    The final point of the arc.

    radius

    The radius inside of the arc.

  • Appends a cubic Bézier curve to the path generator.

    Declaration

    Objective-C

    - (void)addCurveWithControlPoint1:(CGPoint)controlPoint1
                        controlPoint2:(CGPoint)controlPoint2
                              toPoint:(CGPoint)toPoint;

    Parameters

    controlPoint1

    The first control point

    controlPoint2

    The second control point

    toPoint

    The end of the curve

  • Appends a quadratic Bézier curve to the path generator.

    Declaration

    Objective-C

    - (void)addQuadCurveWithControlPoint:(CGPoint)controlPoint
                                 toPoint:(CGPoint)toPoint;

    Parameters

    controlPoint

    The control point

    toPoint

    The end of the curve

  • Appends the recorded path operations to a CGPath using the provided transform.

    Declaration

    Objective-C

    - (void)appendToCGPath:(nonnull CGMutablePathRef)cgPath
                 transform:(nullable CGAffineTransform *)transform;

    Parameters

    cgPath

    A mutable CGPath to which the saved path operations will be appended.

    transform

    The transform applied ot each path operation before appending them to the CGPath.