-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFAFNSBezierPathAdditions.m
More file actions
executable file
·54 lines (45 loc) · 1.7 KB
/
FAFNSBezierPathAdditions.m
File metadata and controls
executable file
·54 lines (45 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// https://github.com/fishman/mail.appetizer
#import "FAFNSBezierPathAdditions.h"
@implementation NSBezierPath (FAFNSBezierPathAdditions)
+ (NSBezierPath*) bezierPathWithRoundedRect:(NSRect)rect_ {
return [self bezierPathWithRoundedRect:rect_ radius:6.0];
}
+ (NSBezierPath*) bezierPathWithRoundedRect:(NSRect)rect_ radius:(float)radius_ {
NSRect centeredArcRect = NSInsetRect(rect_, radius_, radius_);
float bottom = NSMinY(centeredArcRect);
float left = NSMinX(centeredArcRect);
float top = NSMaxY(centeredArcRect);
float right = NSMaxX(centeredArcRect);
#define threeOclock 0.0f
#define twelveOclock 90.0f
#define nineOclock 180.0f
#define sixOclock 270.0f
NSBezierPath *path = [NSBezierPath bezierPath];
// These have to be in order, starting at nine o'clock on the bottom left.
[path appendBezierPathWithArcWithCenter:NSMakePoint(left, bottom)
radius:radius_
startAngle:nineOclock
endAngle:sixOclock];
[path appendBezierPathWithArcWithCenter:NSMakePoint(right, bottom)
radius:radius_
startAngle:sixOclock
endAngle:threeOclock];
[path appendBezierPathWithArcWithCenter:NSMakePoint(right, top)
radius:radius_
startAngle:threeOclock
endAngle:twelveOclock];
[path appendBezierPathWithArcWithCenter:NSMakePoint(left, top)
radius:radius_
startAngle:twelveOclock
endAngle:nineOclock];
[path closePath];
return path;
}
+ (NSBezierPath*)bezierPathWithMissingOutline:(NSRect)rect {
NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:NSInsetRect(rect, 2, 2)];
[path setLineWidth:4];
float pattern[2] = { 15.0, 5.0 };
[path setLineDash:pattern count:2 phase:0.0];
return path;
}
@end