Latest 0.1.1
Homepage https://github.com/dclelland/UIBezierPath-DSL
License MIT
Platforms ios 7.0, requires ARC
Authors

UIBezierPath+DSL provides a simple way to build bezier paths using a psuedo-DSL.

Inspired by Masonry and TurtleBezierPath.

✓ Supports relative positioning.

UIBezierPath *path = [UIBezierPath makePath:^(DSLBezierPathMaker *make) {
    make.moveTo(CGPointMake(0.5, 0.5));
    make.lineUp(0.5);
    make.lineRight(0.5);
    make.lineDown(0.5);
    make.lineLeft(1.0);
    make.lineDown(0.5);
    make.lineRight(0.5);
    make.closed();
}];

✓ Supports transformations.

UIBezierPath *path = [[UIBezierPath bezierPathWithOvalInRect:CGRectMake(0.0, 0.0, 1.0, 1.0)] makePath:^(DSLBezierPathMaker *make) {
    make.scale(CGSizeMake(20.0, 20.0));
    make.translate(CGPointMake(10.0, 10.0));
}];

✓ Supports function chaining.

UIBezierPath *path = [UIBezierPath makePath:^(DSLBezierPathMaker *make) {
    make.ovalAt(CGPointMake(0.5, 0.5), 0.25);
    make.moveTo(CGPointMake(0.0, 0.5)).lineTo(CGPointMake(0.5, 0.0)).lineTo(CGPointMake(1.0, 0.5)).lineTo(CGPointMake(0.5, 1.0)).close();
}];

✓ Direction helpers.

UIBezierPath *path = [UIBezierPath makePath:^(DSLBezierPathMaker *make) {
    make.move(1.0, DSLDirectionNorthEast);
    make.line(1.0, DSLDirectionSouthEast);
    make.line(1.0, DSLDirectionSouthWest);
    make.line(1.0, DSLDirectionNorthWest);
    make.closed();
}];

Full API:

UIBezierPath (DSL)

+ (UIBezierPath *)makePath:(void(^)(DSLBezierPathMaker *make))block;

- (UIBezierPath *)makePath:(void(^)(DSLBezierPathMaker *make))block;

DSLBezierPathMaker

.moveTo(CGPoint point);
.move(CGFloat distance, CGFloat direction);
.moveUp(CGFloat distance);
.moveLeft(CGFloat distance);
.moveDown(CGFloat distance);
.moveRight(CGFloat distance);

.lineTo(CGPoint point);
.line(CGFloat distance, CGFloat direction);
.lineUp(CGFloat distance);
.lineLeft(CGFloat distance);
.lineDown(CGFloat distance);
.lineRight(CGFloat distance);

.arcAt(CGPoint center, CGFloat radius, CGFloat startAngle, CGFloat endAngle, BOOL clockwise);

.curveTo(CGPoint point, CGPoint controlPoint1, CGPoint controlPoint2);

.quadCurveTo(CGPoint point, CGPoint controlPoint);

.transform(CGAffineTransform transform);
.translate(CGPoint point);
.scale(CGSize size);
.rotate(CGFloat angle);

.path(UIBezierPath *path);

.rect(CGRect rect);
.rectAt(CGPoint center, CGFloat radius);

.oval(CGRect rect);
.ovalAt(CGPoint center, CGFloat radius);

.roundedRect(CGRect rect, CGFloat cornerRadius);
.roundedRectAt(CGPoint center, CGFloat radius, CGFloat cornerRadius);

.close();
.closed();

Latest podspec

{
    "name": "UIBezierPath+DSL",
    "version": "0.1.1",
    "summary": "UIBezierPath+DSL provides a simple way to build bezier paths using a psuedo-DSL.",
    "homepage": "https://github.com/dclelland/UIBezierPath-DSL",
    "license": {
        "type": "MIT"
    },
    "authors": {
        "Daniel Clelland": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dclelland/UIBezierPath-DSL.git",
        "tag": "0.1.1"
    },
    "platforms": {
        "ios": "7.0"
    },
    "ios": {
        "source_files": "UIBezierPath+DSL/*.{h,m}"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This