//
//  QuartzCodeCategoryiOX.h
//
//  Code generated using QuartzCode.
//  www.quartzcodeapp.com
//

#import "QuartzCodeCategoryiOS.h"

@implementation UIBezierPath (QuartzCode)

- (CGPoint)firstPoint
{
    CGPathRef yourCGPath = self.CGPath;
    NSMutableArray *bezierPoints = [NSMutableArray array];
    CGPathApply(yourCGPath, (__bridge void *)(bezierPoints), CGPathFirstPointApplierFunc);
    CGPoint p = [bezierPoints.firstObject CGPointValue];
    
    return p;
}

void CGPathFirstPointApplierFunc (void *info, const CGPathElement *element) {
    NSMutableArray *bezierPoints = (__bridge NSMutableArray *)info;
    
    CGPoint *points = element->points;
    CGPathElementType type = element->type;
    
    if (type == kCGPathElementMoveToPoint) {
        [bezierPoints addObject:[NSValue valueWithCGPoint:points[0]]];
    }
}

- (void)offsetBy:(CGPoint)offset{
    CGAffineTransform affineTransform = CGAffineTransformTranslate(CGAffineTransformIdentity, offset.x, offset.y);
    [self applyTransform:affineTransform];
}

@end