cairo 1.5.0 → 1.5.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of cairo might be problematic. Click here for more details.
- data/ChangeLog +68 -0
- data/NEWS +15 -1
- data/README +15 -0
- data/extconf.rb +28 -26
- data/samples/agg/README +4 -0
- data/samples/agg/aa_demo.rb +47 -0
- data/samples/agg/aa_test.rb +304 -0
- data/src/cairo.def +2 -1
- data/src/lib/cairo.rb +6 -0
- data/src/lib/cairo/context.rb +2 -0
- data/src/lib/cairo/context/path.rb +1 -1
- data/src/lib/cairo/context/triangle.rb +12 -0
- data/src/rb_cairo.c +2 -2
- data/src/rb_cairo.h +83 -57
- data/src/rb_cairo_context.c +7 -4
- data/src/rb_cairo_private.h +12 -1
- data/src/rb_cairo_surface.c +98 -24
- metadata +46 -35
data/ChangeLog
CHANGED
@@ -1,5 +1,73 @@
|
|
1
|
+
2008-01-11 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
|
3
|
+
* src/: Cairo::WIN32Surface -> Cairo::Win32Surface.
|
4
|
+
|
5
|
+
* NEWS: added an entry for 1.5.1.
|
6
|
+
|
7
|
+
* extconf.rb: added Quartz backend check for -framework RubyCocoa.
|
8
|
+
|
9
|
+
* src/rb_cairo.h:
|
10
|
+
- RUBY_XXX -> RB_XXX.
|
11
|
+
- added extern "C" {}.
|
12
|
+
- added rb_cCairo_QuartzSurface.
|
13
|
+
|
14
|
+
* src/cairo.def: rb_cCairo_QuartzSurface.
|
15
|
+
|
16
|
+
* src/rb_cairo_surface.c: supported Quartz backend.
|
17
|
+
|
18
|
+
2007-12-29 Kouhei Sutou <kou@cozmixng.org>
|
19
|
+
|
20
|
+
* src/rb_cairo_context.c (cr_set_source_surface): fixed wrong type
|
21
|
+
conversion.
|
22
|
+
Reported by Binzo. Thanks!!!
|
23
|
+
|
24
|
+
* README: updated Binzo entry in Thanks list.
|
25
|
+
|
26
|
+
2007-12-28 Kouhei Sutou <kou@cozmixng.org>
|
27
|
+
|
28
|
+
* src/rb_cairo_context.c (cr_pop_group): fixed a memory leak bug.
|
29
|
+
Reported by Binzo. Thanks!!!
|
30
|
+
|
31
|
+
* README: added Binzo to Thanks list.
|
32
|
+
|
33
|
+
2007-06-14 Kouhei Sutou <kou@cozmixng.org>
|
34
|
+
|
35
|
+
* extconf.rb, src/rb_cairo_surface.c, src/rb_cairo_private.h: used
|
36
|
+
rb_errinfo() and RSTRING_LEN() if available for supporting ruby
|
37
|
+
1.9. Thanks to Paul van Tilburg!!!
|
38
|
+
|
39
|
+
* README: added Paul van Tilburg to Thanks list.
|
40
|
+
|
41
|
+
2007-06-14 Paul van Tilburg <paulvt@debian.org>
|
42
|
+
|
43
|
+
* extconf.rb: used String#each_line instead of String#each for
|
44
|
+
supporting ruby 1.9.
|
45
|
+
|
46
|
+
2007-06-03 Kouhei Sutou <kou@cozmixng.org>
|
47
|
+
|
48
|
+
* samples/agg/aa_test.rb: fixed wrong operation.
|
49
|
+
|
50
|
+
2007-05-29 Kouhei Sutou <kou@cozmixng.org>
|
51
|
+
|
52
|
+
* src/lib/cairo/context/path.rb: fixed typos.
|
53
|
+
Thanks to NANKI Haruo!!!
|
54
|
+
* README: added an entry for NANKI Haruo.
|
55
|
+
|
56
|
+
2007-05-28 Kouhei Sutou <kou@cozmixng.org>
|
57
|
+
|
58
|
+
* src/lib/cairo/context.rb, src/lib/cairo/context/triangle.rb:
|
59
|
+
added a convenience method.
|
60
|
+
|
61
|
+
* samples/agg/aa_test.rb: implemented random shapes test.
|
62
|
+
|
1
63
|
2007-05-27 Kouhei Sutou <kou@cozmixng.org>
|
2
64
|
|
65
|
+
* samples/agg/aa_test.rb: ported from AGG's example.
|
66
|
+
|
67
|
+
* README: added some links for documentation.
|
68
|
+
|
69
|
+
* src/rb_cairo.c: 1.5.0 -> 1.5.1.
|
70
|
+
|
3
71
|
* Rakefile: improved current release NEWS extraction.
|
4
72
|
|
5
73
|
* NEWS: updated.
|
data/NEWS
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
Release 1.5.1 (2008-01-11) Kouhei Sutou <kou@cozmixng.org>)
|
2
|
+
==========================================================
|
3
|
+
|
4
|
+
Features
|
5
|
+
--------
|
6
|
+
* Support Quartz surface.
|
7
|
+
* Fix a wrong type conversion bug. (Binzo)
|
8
|
+
* Fix a memory leak bug. (Binzo)
|
9
|
+
* Support ruby 1.9.0. (Paul van Tilburg)
|
10
|
+
* Fix typos. (NANKI Haruo)
|
11
|
+
* Rename Cairo::WIN32Surface to Cairo::Win32Surface
|
12
|
+
* Cairo::WIN32Surface is still available for backward compatibility but
|
13
|
+
don't use in newly written code.
|
14
|
+
|
1
15
|
Release 1.5.0 (2007-05-27) Kouhei Sutou <kou@cozmixng.org>)
|
2
16
|
==========================================================
|
3
17
|
|
@@ -19,7 +33,7 @@ Features
|
|
19
33
|
To:
|
20
34
|
context.set_source_color(:red)
|
21
35
|
|
22
|
-
* Support RGB
|
36
|
+
* Support color type conversion between RGB, CMYK and HSV.
|
23
37
|
* Many default color definitions.
|
24
38
|
* Support path creation using Cairo::Path without
|
25
39
|
Cairo::Context.
|
data/README
CHANGED
@@ -22,6 +22,18 @@ Compiling
|
|
22
22
|
# the samples in the samples folder should be able
|
23
23
|
# to run before installation.
|
24
24
|
|
25
|
+
Documents
|
26
|
+
---------
|
27
|
+
|
28
|
+
* Reference manual:
|
29
|
+
http://cairo.rubyforge.org/doc/
|
30
|
+
|
31
|
+
Repository of the reference manual:
|
32
|
+
http://www.cozmixng.org/repos/rcairo-doc/
|
33
|
+
|
34
|
+
* An article for rcairo on Rubyst Magazine a.k.a. RubiMa (in Japanese):
|
35
|
+
http://jp.rubyist.net/magazine/?0019-cairo
|
36
|
+
|
25
37
|
Mailing list
|
26
38
|
------------
|
27
39
|
|
@@ -35,3 +47,6 @@ Thanks
|
|
35
47
|
------
|
36
48
|
|
37
49
|
* Yoshinao Muramatsu: win32 surface support patch.
|
50
|
+
* NANKI Haruo: some bug fix patches.
|
51
|
+
* Paul van Tilburg: some patches that support ruby 1.9.
|
52
|
+
* Binzo: some bug reports and fixed that.
|
data/extconf.rb
CHANGED
@@ -20,26 +20,26 @@ else
|
|
20
20
|
$cc_is_gcc = false
|
21
21
|
end
|
22
22
|
|
23
|
-
def check_win32
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
23
|
+
def check_win32
|
24
|
+
checking_for("Win32 OS") do
|
25
|
+
win32_os = /cygwin|mingw|mswin32/ =~ RUBY_PLATFORM
|
26
|
+
if win32_os
|
27
|
+
$defs << "-DRUBY_CAIRO_PLATFORM_WIN32"
|
28
|
+
if $cc_is_gcc
|
29
|
+
if /^2\./ =~ `#{Config::CONFIG['CC']} -dumpversion`.chomp
|
30
|
+
$CFLAGS += ' -fnative-struct'
|
31
|
+
else
|
32
|
+
$CFLAGS += ' -mms-bitfields'
|
33
|
+
end
|
34
34
|
end
|
35
35
|
end
|
36
|
-
|
37
|
-
STDOUT.print "no\n"
|
36
|
+
win32_os
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
40
|
def set_output_lib(target_name)
|
42
|
-
|
41
|
+
case RUBY_PLATFORM
|
42
|
+
when /cygwin|mingw/
|
43
43
|
filename = "libruby-#{target_name}.a"
|
44
44
|
if RUBY_VERSION > "1.8.0"
|
45
45
|
$DLDFLAGS << ",--out-implib=#{filename}" if filename
|
@@ -50,19 +50,18 @@ def set_output_lib(target_name)
|
|
50
50
|
$DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '')
|
51
51
|
$DLDFLAGS << " --output-lib #{filename}" if filename
|
52
52
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
53
|
+
when /mswin32/
|
54
|
+
filename = "libruby-#{target_name}.lib"
|
55
|
+
$DLDFLAGS.gsub!(/ --output-lib\s+[^ ]+/, '')
|
56
|
+
$DLDFLAGS.gsub!(/ \/IMPLIB:[^ ]+/, '')
|
57
|
+
$DLDFLAGS << " /IMPLIB:#{filename}" if filename
|
58
|
+
when /darwin/
|
59
|
+
if have_macro("CAIRO_HAS_QUARTZ_SURFACE", ["cairo.h"])
|
60
|
+
$DLDFLAGS << " -Wl,-framework,RubyCocoa"
|
61
|
+
end
|
58
62
|
end
|
59
63
|
end
|
60
64
|
|
61
|
-
def setup_win32(target_name)
|
62
|
-
check_win32
|
63
|
-
set_output_lib(target_name)
|
64
|
-
end
|
65
|
-
|
66
65
|
|
67
66
|
pkg = "cairo"
|
68
67
|
modname = "cairo"
|
@@ -72,7 +71,10 @@ major, minor, micro = 1, 2, 0
|
|
72
71
|
|
73
72
|
PKGConfig.have_package(pkg, major, minor, micro) or exit 1
|
74
73
|
|
75
|
-
|
74
|
+
have_func("rb_errinfo")
|
75
|
+
|
76
|
+
check_win32
|
77
|
+
set_output_lib(File.basename(modname))
|
76
78
|
$defs << "-DRUBY_CAIRO_COMPILATION"
|
77
79
|
create_makefile(modname, srcdir)
|
78
80
|
|
@@ -80,7 +82,7 @@ makefile = File.read("Makefile")
|
|
80
82
|
File.open("Makefile", "w") do |f|
|
81
83
|
objs = []
|
82
84
|
co = nil
|
83
|
-
makefile.
|
85
|
+
makefile.each_line do |line|
|
84
86
|
case line
|
85
87
|
when /^TARGET\s*=\s*/
|
86
88
|
f.print("TARGET = #{ext_dir_name}/#{$POSTMATCH}")
|
data/samples/agg/README
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
top = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
|
4
|
+
src = File.join(top, "src")
|
5
|
+
$LOAD_PATH.unshift src
|
6
|
+
$LOAD_PATH.unshift File.join(src, "lib")
|
7
|
+
|
8
|
+
require 'gtk2'
|
9
|
+
|
10
|
+
window = Gtk::Window.new
|
11
|
+
window.set_default_size(600, 400)
|
12
|
+
|
13
|
+
layout = Gtk::Layout.new
|
14
|
+
|
15
|
+
pixel_scale = Gtk::HScale.new(8, 100, (100 - 8) / 23.0)
|
16
|
+
pixel_scale.value = 32
|
17
|
+
pixel_scale.set_size_request(500, 50)
|
18
|
+
layout.put(pixel_scale, 80, 350)
|
19
|
+
pixel_label = Gtk::Label.new("Pixel size=")
|
20
|
+
layout.put(pixel_label, 80, 370)
|
21
|
+
|
22
|
+
gamma_scale = Gtk::HScale.new(0.1, 3.0, 0.001)
|
23
|
+
gamma_scale.value = 1.0
|
24
|
+
gamma_scale.set_size_request(500, 50)
|
25
|
+
layout.put(gamma_scale, 80, 310)
|
26
|
+
gamma_label = Gtk::Label.new("Gamma=")
|
27
|
+
layout.put(gamma_label, 80, 330)
|
28
|
+
|
29
|
+
layout.signal_connect("expose-event") do |widget, event|
|
30
|
+
context = widget.bin_window.create_cairo_context
|
31
|
+
context.move_to(50, 80)
|
32
|
+
context.line_to(200, 250)
|
33
|
+
context.line_to(400, 130)
|
34
|
+
context.close_path
|
35
|
+
context.line_width = 30
|
36
|
+
context.antialias = :none
|
37
|
+
context.set_source_color([0, 150.0/255.0, 160.0/255.0, 200.0/255.0])
|
38
|
+
context.stroke
|
39
|
+
false
|
40
|
+
end
|
41
|
+
|
42
|
+
window.add(layout)
|
43
|
+
|
44
|
+
window.show_all
|
45
|
+
|
46
|
+
Gtk.main
|
47
|
+
|
@@ -0,0 +1,304 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# ported from examples/aa_test.cpp in AGG source tree.
|
4
|
+
|
5
|
+
top = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
|
6
|
+
src = File.join(top, "src")
|
7
|
+
$LOAD_PATH.unshift src
|
8
|
+
$LOAD_PATH.unshift File.join(src, "lib")
|
9
|
+
|
10
|
+
require 'gtk2'
|
11
|
+
|
12
|
+
window = Gtk::Window.new
|
13
|
+
window.set_default_size(480, 350)
|
14
|
+
|
15
|
+
area = Gtk::DrawingArea.new
|
16
|
+
|
17
|
+
def stroke_line(context, x1, y1, x2, y2, line_width, dash_length)
|
18
|
+
context.save do
|
19
|
+
yield if block_given?
|
20
|
+
context.move_to(x1, y1)
|
21
|
+
context.line_to(x2, y2)
|
22
|
+
context.set_dash(dash_length) if dash_length > 0
|
23
|
+
context.line_width = line_width
|
24
|
+
context.line_cap = :round
|
25
|
+
context.stroke
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def fill_triangle(context, x1, y1, x2, y2, x3, y3)
|
30
|
+
context.save do
|
31
|
+
yield if block_given?
|
32
|
+
context.triangle(x1, y1, x2, y2, x3, y3)
|
33
|
+
context.fill
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def set_gradient(context, x1, y1, x2, y2, color_stops)
|
38
|
+
pattern = Cairo::LinearPattern.new(x1, y1, x2, y2)
|
39
|
+
color_stops.each do |offset, color|
|
40
|
+
pattern.add_color_stop(offset, color)
|
41
|
+
end
|
42
|
+
context.set_source(pattern)
|
43
|
+
end
|
44
|
+
|
45
|
+
def stroke_gradient_line(context, x1, y1, x2, y2,
|
46
|
+
line_width, dash_length, color_stops)
|
47
|
+
stroke_line(context, x1, y1, x2, y2, line_width, dash_length) do
|
48
|
+
set_gradient(context, x1, y1, x2, y2, color_stops)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def fill_gradient_triangle(context, x1, y1, x2, y2, x3, y3, color_stops)
|
53
|
+
fill_triangle(context, x1, y1, x2, y2, x3, y3) do
|
54
|
+
set_gradient(context,
|
55
|
+
x1, y1,
|
56
|
+
x3 - (x3 - x2) / 2.0,
|
57
|
+
y3 - (y3 - y2) / 2.0,
|
58
|
+
color_stops)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def draw_background_circle(context, w, h)
|
63
|
+
context.set_source_color([1.0, 1.0, 1.0, 0.2])
|
64
|
+
|
65
|
+
cx = w / 2.0
|
66
|
+
cy = h / 2.0
|
67
|
+
radius = [cx, cy].min
|
68
|
+
1.upto(180) do |i|
|
69
|
+
n = 2 * Math::PI * i / 180.0
|
70
|
+
stroke_line(context,
|
71
|
+
cx + radius * Math.sin(n),
|
72
|
+
cy + radius * Math.cos(n),
|
73
|
+
cx, cy,
|
74
|
+
1.0, i < 90 ? i : 0)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def draw_upper_small_circles(context, i)
|
79
|
+
context.circle(18 + i * 4 + 0.5,
|
80
|
+
33 + 0.5,
|
81
|
+
i / 20.0)
|
82
|
+
context.fill
|
83
|
+
|
84
|
+
context.circle(18 + i * 4 + (i - 1) / 10.0 + 0.5,
|
85
|
+
27 + (i - 1) / 10.0 + 0.5,
|
86
|
+
0.5)
|
87
|
+
context.fill
|
88
|
+
end
|
89
|
+
|
90
|
+
def draw_upper_circles(context, i)
|
91
|
+
context.set_source_color(:white)
|
92
|
+
context.circle(20 + i * (i + 1) + 0.5,
|
93
|
+
20.5,
|
94
|
+
i / 2.0)
|
95
|
+
context.fill
|
96
|
+
|
97
|
+
draw_upper_small_circles(context, i)
|
98
|
+
end
|
99
|
+
|
100
|
+
def draw_upper_gradient_lines(context, i)
|
101
|
+
stroke_gradient_line(context,
|
102
|
+
20 + i * (i + 1),
|
103
|
+
40.5,
|
104
|
+
20 + i * (i + 1) + (i - 1) * 4,
|
105
|
+
100.5,
|
106
|
+
i,
|
107
|
+
0,
|
108
|
+
[[0, :white],
|
109
|
+
[1, [i % 2, (i % 3) * 0.5, (i % 5) * 0.25]]])
|
110
|
+
end
|
111
|
+
|
112
|
+
def draw_middle_small_circles(context, i)
|
113
|
+
stroke_gradient_line(context,
|
114
|
+
17.5 + i * 4,
|
115
|
+
107,
|
116
|
+
17.5 + i * 4 + i / 6.66666667,
|
117
|
+
107,
|
118
|
+
1,
|
119
|
+
0,
|
120
|
+
[[0, :red],
|
121
|
+
[1, :blue]])
|
122
|
+
|
123
|
+
stroke_gradient_line(context,
|
124
|
+
18 + i * 4,
|
125
|
+
112.5,
|
126
|
+
18 + i * 4,
|
127
|
+
112.5 + i / 6.66666667,
|
128
|
+
1,
|
129
|
+
0,
|
130
|
+
[[0, :red],
|
131
|
+
[1, :blue]])
|
132
|
+
end
|
133
|
+
|
134
|
+
def draw_middle_gradient_lines(context, i)
|
135
|
+
stroke_gradient_line(context,
|
136
|
+
21.5,
|
137
|
+
120 + (i - 1) * 3.1,
|
138
|
+
52.5,
|
139
|
+
120 + (i - 1) * 3.1,
|
140
|
+
1,
|
141
|
+
0,
|
142
|
+
[[0, :red],
|
143
|
+
[1, :white]])
|
144
|
+
|
145
|
+
stroke_gradient_line(context,
|
146
|
+
52.5,
|
147
|
+
118 + i * 3,
|
148
|
+
83.5,
|
149
|
+
118 + i * 3,
|
150
|
+
2 - (i - 1) / 10.0,
|
151
|
+
0,
|
152
|
+
[[0, :green],
|
153
|
+
[1, :white]])
|
154
|
+
|
155
|
+
stroke_gradient_line(context,
|
156
|
+
83.5,
|
157
|
+
119 + i * 3,
|
158
|
+
114.5,
|
159
|
+
119 + i * 3,
|
160
|
+
2 - (i - 1) / 10.0,
|
161
|
+
3.0,
|
162
|
+
[[0, :blue],
|
163
|
+
[1, :white]])
|
164
|
+
end
|
165
|
+
|
166
|
+
def draw_middle_white_lines(context, i)
|
167
|
+
context.set_source_color(:white)
|
168
|
+
stroke_line(context,
|
169
|
+
125.5, 119.5 + (i + 2) * (i / 2.0),
|
170
|
+
135.5, 119.5 + (i + 2) * (i / 2.0),
|
171
|
+
i, 0)
|
172
|
+
end
|
173
|
+
|
174
|
+
def draw_lower_short_lines(context, i)
|
175
|
+
context.set_source_color(:white)
|
176
|
+
|
177
|
+
stroke_line(context,
|
178
|
+
17.5 + i * 4, 192,
|
179
|
+
18.5 + i * 4, 192,
|
180
|
+
i / 10.0, 0)
|
181
|
+
|
182
|
+
stroke_line(context,
|
183
|
+
17.5 + i * 4 + (i - 1) / 10.0, 186,
|
184
|
+
18.5 + i * 4 + (i - 1) / 10.0, 186,
|
185
|
+
1.0, 0)
|
186
|
+
end
|
187
|
+
|
188
|
+
def draw_right_triangles(context, i, w, h)
|
189
|
+
x1 = w - 150
|
190
|
+
x2 = w - 20
|
191
|
+
y_upper = h - 20 - i * (i + 2)
|
192
|
+
y_middle = h - 20 - i * (i + 1.5)
|
193
|
+
y_lower = h - 20 - i * (i + 1)
|
194
|
+
context.save do
|
195
|
+
pattern = Cairo::LinearPattern.new(x1, y_middle, x2, y_middle)
|
196
|
+
pattern.add_color_stop(0, :white)
|
197
|
+
pattern.add_color_stop(1, [i % 2, (i % 3) * 0.5, (i % 5) * 0.25])
|
198
|
+
context.set_source(pattern)
|
199
|
+
context.move_to(x1, y_middle)
|
200
|
+
context.line_to(x2, y_lower)
|
201
|
+
context.line_to(x2, y_upper)
|
202
|
+
context.fill
|
203
|
+
end
|
204
|
+
end
|
205
|
+
|
206
|
+
def draw_sample_shapes(context, w, h)
|
207
|
+
context.set_source_color(:black)
|
208
|
+
context.paint
|
209
|
+
|
210
|
+
draw_background_circle(context, w, h)
|
211
|
+
|
212
|
+
1.upto(20) do |i|
|
213
|
+
draw_upper_circles(context, i)
|
214
|
+
draw_upper_gradient_lines(context, i)
|
215
|
+
draw_middle_small_circles(context, i)
|
216
|
+
draw_middle_gradient_lines(context, i)
|
217
|
+
draw_middle_white_lines(context, i) if i <= 10
|
218
|
+
draw_lower_short_lines(context, i)
|
219
|
+
end
|
220
|
+
|
221
|
+
1.upto(13) do |i|
|
222
|
+
draw_right_triangles(context, i, w, h)
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def draw_random_shapes(context, w, h)
|
227
|
+
srand(123)
|
228
|
+
|
229
|
+
context.set_source_color(:black)
|
230
|
+
context.paint
|
231
|
+
|
232
|
+
n_circles = 20000
|
233
|
+
start = Time.now
|
234
|
+
n_circles.times do |i|
|
235
|
+
context.circle(rand(w), rand(h), rand(20.0) + 1.0)
|
236
|
+
context.set_source_color([rand, rand, rand, 0.5 + rand / 2])
|
237
|
+
context.fill
|
238
|
+
end
|
239
|
+
circle_draw_time = Time.now - start
|
240
|
+
|
241
|
+
n_lines = 2000
|
242
|
+
start = Time.now
|
243
|
+
n_lines.times do |i|
|
244
|
+
x1 = rand(w)
|
245
|
+
y1 = rand(h)
|
246
|
+
stroke_gradient_line(context,
|
247
|
+
x1, y1,
|
248
|
+
x1 + rand(w * 0.5) - w * 0.25,
|
249
|
+
y1 + rand(h * 0.5) - h * 0.25,
|
250
|
+
10.0, 0,
|
251
|
+
[[0, [rand, rand, rand, 0.5 + rand / 2]],
|
252
|
+
[1, [rand, rand, rand, rand]]])
|
253
|
+
end
|
254
|
+
line_draw_time = Time.now - start
|
255
|
+
|
256
|
+
n_triangles = 2000
|
257
|
+
start = Time.now
|
258
|
+
n_triangles.times do |i|
|
259
|
+
x1 = rand(w)
|
260
|
+
y1 = rand(h)
|
261
|
+
fill_gradient_triangle(context,
|
262
|
+
x1, y1,
|
263
|
+
x1 + rand(w * 0.4) - w * 0.2,
|
264
|
+
y1 + rand(h * 0.4) - h * 0.2,
|
265
|
+
x1 + rand(w * 0.4) - w * 0.2,
|
266
|
+
y1 + rand(h * 0.4) - h * 0.2,
|
267
|
+
[[0, [rand, rand, rand, 0.5 + rand / 2]],
|
268
|
+
[0.5, [rand, rand, rand, rand]],
|
269
|
+
[1, [rand, rand, rand, rand]]])
|
270
|
+
end
|
271
|
+
triangle_draw_time = Time.now - start
|
272
|
+
|
273
|
+
puts "Points=%.2fK/sec, Lines=%.2fK/sec, Triangles=%.2fK/sec" %
|
274
|
+
[n_circles.to_f / circle_draw_time,
|
275
|
+
n_lines.to_f / line_draw_time,
|
276
|
+
n_triangles.to_f / triangle_draw_time]
|
277
|
+
end
|
278
|
+
|
279
|
+
random_mode = false
|
280
|
+
|
281
|
+
area.add_events(Gdk::Event::BUTTON_PRESS_MASK)
|
282
|
+
area.signal_connect("button-press-event") do |widget, event|
|
283
|
+
random_mode = !random_mode
|
284
|
+
widget.queue_draw
|
285
|
+
false
|
286
|
+
end
|
287
|
+
|
288
|
+
area.signal_connect("expose-event") do |widget, event|
|
289
|
+
context = widget.window.create_cairo_context
|
290
|
+
x, y, w, h = widget.allocation.to_a
|
291
|
+
if random_mode
|
292
|
+
draw_random_shapes(context, w, h)
|
293
|
+
else
|
294
|
+
draw_sample_shapes(context, w, h)
|
295
|
+
end
|
296
|
+
true
|
297
|
+
end
|
298
|
+
|
299
|
+
window.add(area)
|
300
|
+
|
301
|
+
window.show_all
|
302
|
+
|
303
|
+
Gtk.main
|
304
|
+
|
data/src/cairo.def
CHANGED
data/src/lib/cairo.rb
CHANGED
data/src/lib/cairo/context.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'cairo/context/rectangle'
|
2
|
+
require 'cairo/context/triangle'
|
2
3
|
require 'cairo/context/circle'
|
3
4
|
require 'cairo/context/path'
|
4
5
|
require 'cairo/context/blur'
|
@@ -7,6 +8,7 @@ require 'cairo/context/color'
|
|
7
8
|
module Cairo
|
8
9
|
class Context
|
9
10
|
include Rectangle
|
11
|
+
include Triangle
|
10
12
|
include Circle
|
11
13
|
include Path
|
12
14
|
include Blur
|
data/src/rb_cairo.c
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
5
|
* $Author: kou $
|
6
|
-
* $Date: 2007/05/
|
6
|
+
* $Date: 2007/05/27 02:46:01 $
|
7
7
|
*
|
8
8
|
* Copyright 2006-2007 Kouhei Sutou <kou@cozmixng.org>
|
9
9
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
@@ -58,7 +58,7 @@ Init_cairo ()
|
|
58
58
|
|
59
59
|
rb_define_const (rb_mCairo, "BINDINGS_VERSION",
|
60
60
|
rb_ary_new3 (4,
|
61
|
-
INT2FIX (1), INT2FIX (5), INT2FIX (
|
61
|
+
INT2FIX (1), INT2FIX (5), INT2FIX (1), Qnil));
|
62
62
|
|
63
63
|
rb_mCairo_Color = rb_const_get (rb_mCairo, rb_intern ("Color"));
|
64
64
|
rb_cCairo_Color_Base = rb_const_get (rb_mCairo_Color, rb_intern ("Base"));
|
data/src/rb_cairo.h
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
5
|
* $Author: kou $
|
6
|
-
* $Date:
|
6
|
+
* $Date: 2008-01-11 12:18:34 $
|
7
7
|
*
|
8
8
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
9
9
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
@@ -36,6 +36,10 @@
|
|
36
36
|
# undef OpenFile
|
37
37
|
#endif
|
38
38
|
|
39
|
+
#if CAIRO_HAS_QUARTZ_SURFACE
|
40
|
+
# include <cairo-quartz.h>
|
41
|
+
#endif
|
42
|
+
|
39
43
|
#define CAIRO_CHECK_VERSION(major, minor, micro) \
|
40
44
|
(CAIRO_VERSION_MAJOR > (major) || \
|
41
45
|
(CAIRO_VERSION_MAJOR == (major) && CAIRO_VERSION_MINOR > (minor)) || \
|
@@ -44,67 +48,87 @@
|
|
44
48
|
|
45
49
|
#include "ruby.h"
|
46
50
|
|
47
|
-
#if defined(
|
48
|
-
#
|
49
|
-
#
|
51
|
+
#if defined(__cplusplus)
|
52
|
+
# define RB_CAIRO_BEGIN_DECLS extern "C" {
|
53
|
+
# define RB_CAIRO_END_DECLS }
|
54
|
+
#else
|
55
|
+
# define RB_CAIRO_BEGIN_DECLS
|
56
|
+
# define RB_CAIRO_END_DECLS
|
57
|
+
#endif
|
58
|
+
|
59
|
+
RB_CAIRO_BEGIN_DECLS
|
60
|
+
|
61
|
+
#if defined(RUBY_CAIRO_PLATFORM_WIN32) && !defined(RB_CAIRO_PLATFORM_WIN32)
|
62
|
+
# define RB_CAIRO_PLATFORM_WIN32 RUBY_CAIRO_PLATFORM_WIN32
|
63
|
+
#endif
|
64
|
+
|
65
|
+
#if defined(RUBY_CAIRO_STATIC_COMPILATION) && !defined(RB_CAIRO_STATIC_COMPILATION)
|
66
|
+
# define RB_CAIRO_STATIC_COMPILATION RUBY_CAIRO_STATIC_COMPILATION
|
67
|
+
#endif
|
68
|
+
|
69
|
+
#if defined(RB_CAIRO_PLATFORM_WIN32) && !defined(RB_CAIRO_STATIC_COMPILATION)
|
70
|
+
# ifdef RB_CAIRO_COMPILATION
|
71
|
+
# define RB_CAIRO_VAR __declspec(dllexport)
|
50
72
|
# else
|
51
|
-
# define
|
73
|
+
# define RB_CAIRO_VAR extern __declspec(dllimport)
|
52
74
|
# endif
|
53
75
|
#else
|
54
|
-
# define
|
76
|
+
# define RB_CAIRO_VAR extern
|
55
77
|
#endif
|
56
78
|
|
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
|
-
|
79
|
+
RB_CAIRO_VAR VALUE rb_mCairo;
|
80
|
+
RB_CAIRO_VAR VALUE rb_cCairo_Context;
|
81
|
+
RB_CAIRO_VAR VALUE rb_cCairo_Point;
|
82
|
+
RB_CAIRO_VAR VALUE rb_cCairo_Path;
|
83
|
+
RB_CAIRO_VAR VALUE rb_cCairo_PathData;
|
84
|
+
RB_CAIRO_VAR VALUE rb_cCairo_PathMoveTo;
|
85
|
+
RB_CAIRO_VAR VALUE rb_cCairo_PathLineTo;
|
86
|
+
RB_CAIRO_VAR VALUE rb_cCairo_PathCurveTo;
|
87
|
+
RB_CAIRO_VAR VALUE rb_cCairo_PathClosePath;
|
88
|
+
RB_CAIRO_VAR VALUE rb_cCairo_Matrix;
|
89
|
+
RB_CAIRO_VAR VALUE rb_cCairo_Pattern;
|
90
|
+
RB_CAIRO_VAR VALUE rb_cCairo_SolidPattern;
|
91
|
+
RB_CAIRO_VAR VALUE rb_cCairo_SurfacePattern;
|
92
|
+
RB_CAIRO_VAR VALUE rb_cCairo_GradientPattern;
|
93
|
+
RB_CAIRO_VAR VALUE rb_cCairo_LinearPattern;
|
94
|
+
RB_CAIRO_VAR VALUE rb_cCairo_RadialPattern;
|
95
|
+
RB_CAIRO_VAR VALUE rb_cCairo_FontFace;
|
96
|
+
RB_CAIRO_VAR VALUE rb_cCairo_FontExtents;
|
97
|
+
RB_CAIRO_VAR VALUE rb_cCairo_FontOptions;
|
98
|
+
RB_CAIRO_VAR VALUE rb_cCairo_ScaledFont;
|
99
|
+
RB_CAIRO_VAR VALUE rb_cCairo_TextExtents;
|
100
|
+
RB_CAIRO_VAR VALUE rb_cCairo_Glyph;
|
101
|
+
RB_CAIRO_VAR VALUE rb_cCairo_Surface;
|
102
|
+
RB_CAIRO_VAR VALUE rb_cCairo_ImageSurface;
|
103
|
+
RB_CAIRO_VAR VALUE rb_cCairo_PDFSurface;
|
104
|
+
RB_CAIRO_VAR VALUE rb_cCairo_PSSurface;
|
105
|
+
RB_CAIRO_VAR VALUE rb_cCairo_SVGSurface;
|
106
|
+
RB_CAIRO_VAR VALUE rb_cCairo_Win32Surface;
|
107
|
+
/* For backward compatibility*/
|
108
|
+
#define rb_cCairo_WIN32Surface rb_cCairo_Win32Surface
|
109
|
+
RB_CAIRO_VAR VALUE rb_cCairo_QuartzSurface;
|
110
|
+
|
111
|
+
RB_CAIRO_VAR VALUE rb_mCairo_Operator;
|
112
|
+
RB_CAIRO_VAR VALUE rb_mCairo_Antialias;
|
113
|
+
RB_CAIRO_VAR VALUE rb_mCairo_FillRule;
|
114
|
+
RB_CAIRO_VAR VALUE rb_mCairo_LineCap;
|
115
|
+
RB_CAIRO_VAR VALUE rb_mCairo_LineJoin;
|
116
|
+
RB_CAIRO_VAR VALUE rb_mCairo_FontSlant;
|
117
|
+
RB_CAIRO_VAR VALUE rb_mCairo_FontWeight;
|
118
|
+
RB_CAIRO_VAR VALUE rb_mCairo_SubpixelOrder;
|
119
|
+
RB_CAIRO_VAR VALUE rb_mCairo_HintStyle;
|
120
|
+
RB_CAIRO_VAR VALUE rb_mCairo_HintMetrics;
|
121
|
+
RB_CAIRO_VAR VALUE rb_mCairo_FontType;
|
122
|
+
RB_CAIRO_VAR VALUE rb_mCairo_PathDataType;
|
123
|
+
RB_CAIRO_VAR VALUE rb_mCairo_Content;
|
124
|
+
RB_CAIRO_VAR VALUE rb_mCairo_SurfaceType;
|
125
|
+
RB_CAIRO_VAR VALUE rb_mCairo_Format;
|
126
|
+
RB_CAIRO_VAR VALUE rb_mCairo_PatternType;
|
127
|
+
RB_CAIRO_VAR VALUE rb_mCairo_Extend;
|
128
|
+
RB_CAIRO_VAR VALUE rb_mCairo_Filter;
|
129
|
+
RB_CAIRO_VAR VALUE rb_mCairo_SVGVersion;
|
130
|
+
RB_CAIRO_VAR VALUE rb_mCairo_Color;
|
131
|
+
RB_CAIRO_VAR VALUE rb_cCairo_Color_Base;
|
108
132
|
|
109
133
|
|
110
134
|
#define RVAL2CRCONTEXT(obj) (rb_cairo_context_from_ruby_object(obj))
|
@@ -218,4 +242,6 @@ void rb_cairo_check_status (cairo_status_t status);
|
|
218
242
|
#define RB_CAIRO_DEF_SETTERS(klass) rb_cairo_def_setters(klass);
|
219
243
|
void rb_cairo_def_setters (VALUE klass);
|
220
244
|
|
245
|
+
RB_CAIRO_END_DECLS
|
246
|
+
|
221
247
|
#endif
|
data/src/rb_cairo_context.c
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
5
|
* $Author: kou $
|
6
|
-
* $Date: 2007
|
6
|
+
* $Date: 2007-12-29 11:42:26 $
|
7
7
|
*
|
8
8
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
9
9
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
@@ -125,11 +125,14 @@ cr_save (VALUE self)
|
|
125
125
|
static VALUE
|
126
126
|
cr_pop_group (VALUE self)
|
127
127
|
{
|
128
|
+
VALUE rb_pattern;
|
128
129
|
cairo_pattern_t *pattern;
|
129
130
|
|
130
131
|
pattern = cairo_pop_group (_SELF);
|
131
132
|
cr_check_status (_SELF);
|
132
|
-
|
133
|
+
rb_pattern = CRPATTERN2RVAL (pattern);
|
134
|
+
cairo_pattern_destroy (pattern);
|
135
|
+
return rb_pattern;
|
133
136
|
}
|
134
137
|
|
135
138
|
static VALUE
|
@@ -287,8 +290,8 @@ cr_set_source_surface (VALUE self, VALUE surface, VALUE width, VALUE height)
|
|
287
290
|
{
|
288
291
|
cairo_set_source_surface (_SELF,
|
289
292
|
RVAL2CRSURFACE (surface),
|
290
|
-
|
291
|
-
|
293
|
+
NUM2DBL (width),
|
294
|
+
NUM2DBL (height));
|
292
295
|
cr_check_status (_SELF);
|
293
296
|
rb_ivar_set (self, cr_id_source, Qnil);
|
294
297
|
return self;
|
data/src/rb_cairo_private.h
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
5
|
* $Author: kou $
|
6
|
-
* $Date:
|
6
|
+
* $Date: 2008-01-11 08:03:39 $
|
7
7
|
*
|
8
8
|
* Copyright 2005 Kouhei Sutou <kou@cozmixng.org>
|
9
9
|
*
|
@@ -23,6 +23,16 @@
|
|
23
23
|
#define CBOOL2RVAL(bool) (bool ? Qtrue : Qfalse)
|
24
24
|
#define RVAL2CBOOL(bool) RTEST(bool)
|
25
25
|
|
26
|
+
#ifndef RSTRING_LEN
|
27
|
+
# define RSTRING_LEN(string) (RSTRING(string)->len)
|
28
|
+
#endif
|
29
|
+
|
30
|
+
#ifdef HAVE_RB_ERRINFO
|
31
|
+
# define RB_ERRINFO (rb_errinfo())
|
32
|
+
#else
|
33
|
+
# define RB_ERRINFO (ruby_errinfo)
|
34
|
+
#endif
|
35
|
+
|
26
36
|
extern void Init_cairo_private (void);
|
27
37
|
extern void Init_cairo_constants (void);
|
28
38
|
|
@@ -30,6 +40,7 @@ extern void Init_cairo_context (void);
|
|
30
40
|
extern void Init_cairo_path (void);
|
31
41
|
extern void Init_cairo_matrix (void);
|
32
42
|
extern void Init_cairo_surface (void);
|
43
|
+
extern void Init_cairo_quartz_surface (void);
|
33
44
|
extern void Init_cairo_exception (void);
|
34
45
|
extern void Init_cairo_font (void);
|
35
46
|
extern void Init_cairo_font_extents (void);
|
data/src/rb_cairo_surface.c
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
* Ruby Cairo Binding
|
4
4
|
*
|
5
5
|
* $Author: kou $
|
6
|
-
* $Date:
|
6
|
+
* $Date: 2008-01-11 12:19:44 $
|
7
7
|
*
|
8
8
|
* Copyright 2005 Øyvind Kolås <pippin@freedesktop.org>
|
9
9
|
* Copyright 2004-2005 MenTaLguY <mental@rydia.com>
|
@@ -26,10 +26,11 @@
|
|
26
26
|
|
27
27
|
VALUE rb_cCairo_Surface;
|
28
28
|
VALUE rb_cCairo_ImageSurface;
|
29
|
-
VALUE rb_cCairo_PDFSurface;
|
30
|
-
VALUE rb_cCairo_PSSurface;
|
31
|
-
VALUE rb_cCairo_SVGSurface;
|
32
|
-
VALUE
|
29
|
+
VALUE rb_cCairo_PDFSurface = Qnil;
|
30
|
+
VALUE rb_cCairo_PSSurface = Qnil;
|
31
|
+
VALUE rb_cCairo_SVGSurface = Qnil;
|
32
|
+
VALUE rb_cCairo_Win32Surface = Qnil;
|
33
|
+
VALUE rb_cCairo_QuartzSurface = Qnil;
|
33
34
|
|
34
35
|
static ID cr_id_target;
|
35
36
|
static ID cr_id_read;
|
@@ -66,7 +67,7 @@ cr_surface_get_klass (cairo_surface_t *surface)
|
|
66
67
|
klass = rb_cCairo_SVGSurface;
|
67
68
|
break;
|
68
69
|
case CAIRO_SURFACE_TYPE_WIN32:
|
69
|
-
klass =
|
70
|
+
klass = rb_cCairo_Win32Surface;
|
70
71
|
break;
|
71
72
|
default:
|
72
73
|
rb_raise (rb_eArgError, "unknown source type: %d", type);
|
@@ -115,7 +116,7 @@ cr_surface_io_func_rescue (VALUE io_closure)
|
|
115
116
|
{
|
116
117
|
cr_io_callback_closure_t *closure;
|
117
118
|
closure = (cr_io_callback_closure_t *)io_closure;
|
118
|
-
closure->error =
|
119
|
+
closure->error = RB_ERRINFO;
|
119
120
|
return Qnil;
|
120
121
|
}
|
121
122
|
|
@@ -133,13 +134,13 @@ cr_surface_write_func_invoke (VALUE write_closure)
|
|
133
134
|
output = closure->target;
|
134
135
|
data = rb_str_new ((const char *)closure->data, closure->length);
|
135
136
|
|
136
|
-
length =
|
137
|
+
length = RSTRING_LEN (data);
|
137
138
|
while (length != 0)
|
138
139
|
{
|
139
140
|
VALUE rb_written_bytes = rb_funcall (output, cr_id_write, 1, data);
|
140
141
|
written_bytes = NUM2LONG (rb_written_bytes);
|
141
142
|
data = rb_str_substr (data, written_bytes,
|
142
|
-
|
143
|
+
RSTRING_LEN (data) - written_bytes);
|
143
144
|
length -= written_bytes;
|
144
145
|
}
|
145
146
|
|
@@ -180,7 +181,7 @@ cr_surface_read_func_invoke (VALUE read_closure)
|
|
180
181
|
|
181
182
|
result = rb_str_new2 ("");
|
182
183
|
|
183
|
-
for (rest = length; rest != 0; rest = length -
|
184
|
+
for (rest = length; rest != 0; rest = length - RSTRING_LEN (result))
|
184
185
|
{
|
185
186
|
rb_str_concat (result, rb_funcall (input, cr_id_read, 1, INT2NUM (rest)));
|
186
187
|
}
|
@@ -830,6 +831,75 @@ cr_win32_surface_get_image (VALUE self)
|
|
830
831
|
}
|
831
832
|
#endif
|
832
833
|
|
834
|
+
#if CAIRO_HAS_QUARTZ_SURFACE
|
835
|
+
/* Quartz-surface functions */
|
836
|
+
|
837
|
+
#include <objc/objc-runtime.h>
|
838
|
+
|
839
|
+
VALUE ocobj_s_new (id ocid);
|
840
|
+
id rbobj_get_ocid (VALUE obj);
|
841
|
+
|
842
|
+
|
843
|
+
static VALUE
|
844
|
+
cr_quartz_surface_initialize (int argc, VALUE *argv, VALUE self)
|
845
|
+
{
|
846
|
+
id objc_object = nil;
|
847
|
+
CGContextRef context;
|
848
|
+
unsigned int width, height;
|
849
|
+
cairo_surface_t *surface = NULL;
|
850
|
+
cairo_format_t format = CAIRO_FORMAT_ARGB32;
|
851
|
+
VALUE arg1, arg2, arg3, rb_width, rb_height;
|
852
|
+
|
853
|
+
rb_scan_args (argc, argv, "21", &arg1, &arg2, &arg3);
|
854
|
+
|
855
|
+
if (argc == 2)
|
856
|
+
{
|
857
|
+
rb_width = arg1;
|
858
|
+
rb_height = arg2;
|
859
|
+
}
|
860
|
+
else
|
861
|
+
{
|
862
|
+
objc_object = rbobj_get_ocid (arg1);
|
863
|
+
if (objc_object == nil)
|
864
|
+
format = RVAL2CRFORMAT (arg1);
|
865
|
+
|
866
|
+
rb_width = arg2;
|
867
|
+
rb_height = arg3;
|
868
|
+
}
|
869
|
+
|
870
|
+
width = NUM2UINT (rb_width);
|
871
|
+
height = NUM2UINT (rb_height);
|
872
|
+
|
873
|
+
if (objc_object == nil)
|
874
|
+
{
|
875
|
+
surface = cairo_quartz_surface_create (format, width, height);
|
876
|
+
}
|
877
|
+
else
|
878
|
+
{
|
879
|
+
context = (CGContextRef)objc_object;
|
880
|
+
surface =
|
881
|
+
cairo_quartz_surface_create_for_cg_context (context, width, height);
|
882
|
+
}
|
883
|
+
|
884
|
+
cr_surface_check_status (surface);
|
885
|
+
DATA_PTR (self) = surface;
|
886
|
+
if (rb_block_given_p ())
|
887
|
+
yield_and_finish (self);
|
888
|
+
return Qnil;
|
889
|
+
}
|
890
|
+
|
891
|
+
static VALUE
|
892
|
+
cr_quartz_surface_get_cg_context (VALUE self)
|
893
|
+
{
|
894
|
+
CGContextRef context;
|
895
|
+
id objc_object;
|
896
|
+
|
897
|
+
context = cairo_quartz_surface_get_cg_context (_SELF);
|
898
|
+
objc_object = (id)context;
|
899
|
+
return ocobj_s_new (objc_object);
|
900
|
+
}
|
901
|
+
#endif
|
902
|
+
|
833
903
|
|
834
904
|
void
|
835
905
|
Init_cairo_surface (void)
|
@@ -909,8 +979,6 @@ Init_cairo_surface (void)
|
|
909
979
|
cr_ps_surface_dsc_begin_page_setup, 0);
|
910
980
|
|
911
981
|
RB_CAIRO_DEF_SETTERS (rb_cCairo_PSSurface);
|
912
|
-
#else
|
913
|
-
rb_cCairo_PSSurface = Qnil;
|
914
982
|
#endif
|
915
983
|
|
916
984
|
#if CAIRO_HAS_PDF_SURFACE
|
@@ -921,8 +989,6 @@ Init_cairo_surface (void)
|
|
921
989
|
cr_pdf_surface_set_size, 2);
|
922
990
|
|
923
991
|
RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface);
|
924
|
-
#else
|
925
|
-
rb_cCairo_PDFSurface = Qnil;
|
926
992
|
#endif
|
927
993
|
|
928
994
|
#if CAIRO_HAS_SVG_SURFACE
|
@@ -938,22 +1004,30 @@ Init_cairo_surface (void)
|
|
938
1004
|
cr_svg_surface_restrict_to_version, 1);
|
939
1005
|
|
940
1006
|
RB_CAIRO_DEF_SETTERS (rb_cCairo_SVGSurface);
|
941
|
-
#else
|
942
|
-
rb_cCairo_SVGSurface = Qnil;
|
943
1007
|
#endif
|
944
1008
|
|
945
1009
|
#if CAIRO_HAS_WIN32_SURFACE
|
946
|
-
/*
|
947
|
-
|
948
|
-
rb_define_class_under (rb_mCairo, "
|
1010
|
+
/* Win32-surface */
|
1011
|
+
rb_cCairo_Win32Surface =
|
1012
|
+
rb_define_class_under (rb_mCairo, "Win32Surface", rb_cCairo_Surface);
|
949
1013
|
|
950
|
-
rb_define_method (
|
1014
|
+
rb_define_method (rb_cCairo_Win32Surface, "initialize",
|
951
1015
|
cr_win32_surface_initialize, -1);
|
952
|
-
rb_define_method (
|
1016
|
+
rb_define_method (rb_cCairo_Win32Surface, "hdc",
|
953
1017
|
cr_win32_surface_get_hdc, 0);
|
954
|
-
rb_define_method (
|
1018
|
+
rb_define_method (rb_cCairo_Win32Surface, "image",
|
955
1019
|
cr_win32_surface_get_image, 0);
|
956
|
-
#
|
957
|
-
|
1020
|
+
#endif
|
1021
|
+
|
1022
|
+
#if CAIRO_HAS_QUARTZ_SURFACE
|
1023
|
+
/* Quartz-surface */
|
1024
|
+
|
1025
|
+
rb_cCairo_QuartzSurface =
|
1026
|
+
rb_define_class_under (rb_mCairo, "QuartzSurface", rb_cCairo_Surface);
|
1027
|
+
|
1028
|
+
rb_define_method (rb_cCairo_QuartzSurface, "initialize",
|
1029
|
+
cr_quartz_surface_initialize, -1);
|
1030
|
+
rb_define_method (rb_cCairo_QuartzSurface, "cg_context",
|
1031
|
+
cr_quartz_surface_get_cg_context, 0);
|
958
1032
|
#endif
|
959
1033
|
}
|
metadata
CHANGED
@@ -1,38 +1,30 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.0
|
3
|
-
specification_version: 1
|
4
2
|
name: cairo
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.5.
|
7
|
-
date: 2007-05-27 00:00:00 +09:00
|
8
|
-
summary: Ruby bindings for cairo
|
9
|
-
require_paths:
|
10
|
-
- src/lib
|
11
|
-
- src
|
12
|
-
email:
|
13
|
-
- cairo@cairographics.org
|
14
|
-
homepage: http://cairographics.org/rcairo
|
15
|
-
rubyforge_project: cairo
|
16
|
-
description: Ruby bindings for cairo
|
17
|
-
autorequire:
|
18
|
-
default_executable:
|
19
|
-
bindir: bin
|
20
|
-
has_rdoc: false
|
21
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
22
|
-
requirements:
|
23
|
-
- - ">"
|
24
|
-
- !ruby/object:Gem::Version
|
25
|
-
version: 0.0.0
|
26
|
-
version:
|
4
|
+
version: 1.5.1
|
27
5
|
platform: ruby
|
28
|
-
signing_key:
|
29
|
-
cert_chain:
|
30
|
-
post_install_message:
|
31
6
|
authors:
|
32
7
|
- Evan Marin
|
33
8
|
- "\xC3\x98yvind Kol\xC3\xA5s"
|
34
9
|
- MenTaLguY
|
35
10
|
- Kouhei Sutou
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
|
15
|
+
date: 2008-01-11 00:00:00 +09:00
|
16
|
+
default_executable:
|
17
|
+
dependencies: []
|
18
|
+
|
19
|
+
description: Ruby bindings for cairo
|
20
|
+
email:
|
21
|
+
- cairo@cairographics.org
|
22
|
+
executables: []
|
23
|
+
|
24
|
+
extensions:
|
25
|
+
- extconf.rb
|
26
|
+
extra_rdoc_files: []
|
27
|
+
|
36
28
|
files:
|
37
29
|
- AUTHORS
|
38
30
|
- COPYING
|
@@ -45,6 +37,9 @@ files:
|
|
45
37
|
- misc/update-colors.rb
|
46
38
|
- pkg-config.rb
|
47
39
|
- samples/.#blur.rb.1.1
|
40
|
+
- samples/agg/README
|
41
|
+
- samples/agg/aa_demo.rb
|
42
|
+
- samples/agg/aa_test.rb
|
48
43
|
- samples/blur.rb
|
49
44
|
- samples/pac.rb
|
50
45
|
- samples/pac2.rb
|
@@ -63,6 +58,7 @@ files:
|
|
63
58
|
- src/lib/cairo/context/color.rb
|
64
59
|
- src/lib/cairo/context/path.rb
|
65
60
|
- src/lib/cairo/context/rectangle.rb
|
61
|
+
- src/lib/cairo/context/triangle.rb
|
66
62
|
- src/lib/cairo/path.rb
|
67
63
|
- src/lib/cairo/point.rb
|
68
64
|
- src/rb_cairo.c
|
@@ -82,18 +78,33 @@ files:
|
|
82
78
|
- src/rb_cairo_scaled_font.c
|
83
79
|
- src/rb_cairo_surface.c
|
84
80
|
- src/rb_cairo_text_extents.c
|
85
|
-
|
86
|
-
|
81
|
+
has_rdoc: false
|
82
|
+
homepage: http://cairographics.org/rcairo
|
83
|
+
post_install_message:
|
87
84
|
rdoc_options:
|
88
85
|
- --main
|
89
86
|
- README.txt
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
-
|
87
|
+
require_paths:
|
88
|
+
- src/lib
|
89
|
+
- src
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: "0"
|
95
|
+
version:
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: "0"
|
101
|
+
version:
|
96
102
|
requirements: []
|
97
103
|
|
98
|
-
|
104
|
+
rubyforge_project: cairo
|
105
|
+
rubygems_version: 1.0.1
|
106
|
+
signing_key:
|
107
|
+
specification_version: 2
|
108
|
+
summary: Ruby bindings for cairo
|
109
|
+
test_files: []
|
99
110
|
|