This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
StompyDotOrg (author)
Wed Jul 30 00:53:43 -0700 2008
commit 7427e2d6a8e416b8a4adbfd58c04ba6bd1239035
tree 10f3b4dd76883186d7266d91da298e99ff72171f
parent d3a8e9c3a83ed0dcd4bec48b2d1edb07e52b6201
tree 10f3b4dd76883186d7266d91da298e99ff72171f
parent d3a8e9c3a83ed0dcd4bec48b2d1edb07e52b6201
sobezier / SOBezierCurve.m
| aaacb876 » | StompyDotOrg | 2008-07-29 | 1 | // | |
| 2 | // SOBezierCurve.m | ||||
| 3 | // SOBezier | ||||
| 4 | // | ||||
| 5 | |||||
| 6 | #import "SOBezierCurve.h" | ||||
| 7 | |||||
| 8 | |||||
| 9 | @implementation SOBezierCurve | ||||
| 10 | @synthesize pt1, pt2, ControlPt1, ControlPt2; | ||||
| 11 | |||||
| 12 | - (id) init | ||||
| 13 | { | ||||
| 14 | // This just calls the designated initialiser with zero points. | ||||
| 7427e2d6 » | StompyDotOrg | 2008-07-30 | 15 | [self initWithPt1:NSZeroPoint | |
| 16 | Pt2:NSZeroPoint | ||||
| 17 | ControlPt1:NSZeroPoint | ||||
| 18 | ControlPt2:NSZeroPoint]; | ||||
| aaacb876 » | StompyDotOrg | 2008-07-29 | 19 | return self; | |
| 20 | } | ||||
| 21 | |||||
| 22 | - (id)initWithPt1:(NSPoint)point1 | ||||
| 23 | Pt2:(NSPoint)point2 | ||||
| 24 | ControlPt1:(NSPoint)cPoint1 | ||||
| 25 | ControlPt2:(NSPoint)cPoint2 | ||||
| 26 | { | ||||
| 27 | // Designated initialiser. | ||||
| 7427e2d6 » | StompyDotOrg | 2008-07-30 | 28 | if (![super init]) { | |
| 29 | return nil; | ||||
| 30 | } | ||||
| aaacb876 » | StompyDotOrg | 2008-07-29 | 31 | pt1 = point1; | |
| 32 | pt2 = point2; | ||||
| 33 | ControlPt1 = cPoint1; | ||||
| 34 | ControlPt2 = cPoint2; | ||||
| 35 | |||||
| 36 | return self; | ||||
| 37 | } | ||||
| 38 | |||||
| 39 | - (void)drawCurve | ||||
| 40 | { | ||||
| 41 | NSBezierPath *path = [NSBezierPath bezierPath]; | ||||
| 42 | // Move to the first control point | ||||
| 43 | [path moveToPoint:ControlPt1]; | ||||
| 44 | // Add a line from the control point to the first point of the curve | ||||
| 45 | [path lineToPoint:pt1]; | ||||
| 46 | // Create the curve | ||||
| 47 | [path curveToPoint:pt2 controlPoint1:ControlPt1 controlPoint2:ControlPt2]; | ||||
| 48 | // Draw a line from the end of the curve to the second control point | ||||
| 49 | [path lineToPoint:ControlPt2]; | ||||
| 50 | |||||
| 51 | // Now draw the curve | ||||
| 52 | [[NSColor blackColor] set]; | ||||
| 53 | [path stroke]; | ||||
| 54 | } | ||||
| 55 | |||||
| 56 | |||||
| 57 | @end | ||||







