/
BTCairoContext.m
117 lines (91 loc) · 1.81 KB
/
BTCairoContext.m
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#import "BTCairoContext.h"
@implementation BTCairoContext : NSObject
- (id)initWithTargetSurface:(BTCairoSurface *)surface
{
if((self = [super init]) != nil)
{
context = cairo_create([surface _surface]);
}
return self;
}
- (void)save
{
}
- (void)restore
{
}
//- (BTCairoSurface *)getTargetSurface
//- (void)pushGroup
//- (void)pushGroupWithContent:(cairo_content_t)content
- (void)setSourceRed:(double)red green:(double)green blue:(double)blue
{
[self setSourceRed:red green:green blue:blue alpha:1.0];
}
- (void)setSourceRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha
{
cairo_set_source_rgba(context, red, green, blue, alpha);
}
- (void)setSourcePattern:(BTCairoPattern *)pattern
{
cairo_set_source(context, [pattern _pattern]);
}
//- (void)setSourceSurface:(BTCairoSurface *)surface
//- (BTCairoPattern *)getSourcePattern
//- (BTCairoSurface *)getSourceSurface
- (void)setAntiAliasing:(cairo_antialias_t)mode
{
cairo_set_antialias(context, mode);
}
//- (cairo_antialias_t)getAntiAliasing
- (void)clip
{
cairo_clip(context);
}
- (void)fill
{
cairo_fill(context);
}
- (void)maskWithPattern:(BTCairoPattern *)pattern;
{
cairo_mask(context, [pattern _pattern]);
}
- (void)paint
{
cairo_paint(context);
}
- (void)stroke
{
cairo_stroke(context);
}
- (void)showPage
{
cairo_show_page(context);
}
#pragma mark Paths
- (void)closePath
{
cairo_close_path(context);
}
- (void)lineTo:(double)x y:(double)y
{
cairo_line_to(context, x, y);
}
- (void)moveTo:(double)x y:(double)y
{
cairo_move_to(context, x, y);
}
- (void)rectangle:(double)x y:(double)y width:(double)width height:(double)height
{
cairo_rectangle(context, x, y, width, height);
}
#pragma mark Private
- (cairo_t *)_context
{
return context;
}
- (void)dealloc
{
if(context) cairo_destroy(context);
[super dealloc];
}
@end