Skip to content

Instantly share code, notes, and snippets.

@C4Examples
Created July 24, 2012 20:03
Show Gist options
  • Save C4Examples/3172270 to your computer and use it in GitHub Desktop.
Save C4Examples/3172270 to your computer and use it in GitHub Desktop.
Bezier & Quadratic Curves
//
// C4WorkSpace.m
// Examples
//
// Created by Travis Kirton on 12-07-19.
//
#import "C4WorkSpace.h"
@implementation C4WorkSpace
-(void)setup {
C4Shape *bezierCurve, *quadraticCurve;
//create the end points for the bezier curve
CGPoint bezierEndPoints[2] = {CGPointZero,CGPointMake(200,200)};
//create the control points for the bezier curve
CGPoint bezierControlPoints[2] = {CGPointMake(-100, 200), CGPointMake(300, 0)};
//create the bezier curve
bezierCurve = [C4Shape curve:bezierEndPoints controlPoints:bezierControlPoints];
bezierCurve.center = CGPointMake(self.canvas.center.x, self.canvas.height * 1/3);
//create the end points for the quadratic curve
CGPoint quadEndPoints[2] = {CGPointZero,CGPointMake(200, 0)};
//create the controlPoint for the quadratic curve
CGPoint quadControlPoint = CGPointMake(100, -200);
//create the quadratic curve
quadraticCurve = [C4Shape quadCurve:quadEndPoints controlPoint:quadControlPoint];
quadraticCurve.center = CGPointMake(self.canvas.center.x, self.canvas.height * 2/3);
//add the curves to the canvas
[self.canvas addShape:bezierCurve];
[self.canvas addShape:quadraticCurve];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment