cairo 1.4.1 → 1.5.0
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 +259 -0
- data/NEWS +32 -0
- data/README +5 -0
- data/Rakefile +88 -4
- data/misc/update-colors.rb +143 -0
- data/samples/.#blur.rb.1.1 +36 -0
- data/samples/blur.rb +47 -0
- data/samples/pac.rb +22 -28
- data/samples/pac2.rb +26 -32
- data/samples/png.rb +34 -31
- data/samples/scalable.rb +24 -26
- data/samples/text-on-path.rb +6 -7
- data/samples/text2.rb +16 -18
- data/src/cairo.def +31 -0
- data/src/lib/cairo.rb +25 -7
- data/src/lib/cairo/color.rb +255 -0
- data/src/lib/cairo/colors.rb +656 -0
- data/src/lib/cairo/constants.rb +21 -0
- data/src/lib/cairo/context.rb +16 -2
- data/src/lib/cairo/context/blur.rb +45 -0
- data/src/lib/cairo/context/circle.rb +2 -2
- data/src/lib/cairo/context/color.rb +11 -0
- data/src/lib/cairo/context/path.rb +17 -28
- data/src/lib/cairo/path.rb +15 -0
- data/src/lib/cairo/point.rb +7 -0
- data/src/rb_cairo.c +8 -17
- data/src/rb_cairo.h +44 -3
- data/src/rb_cairo_constants.c +129 -137
- data/src/rb_cairo_context.c +224 -112
- data/src/rb_cairo_font_extents.c +4 -3
- data/src/rb_cairo_font_face.c +3 -10
- data/src/rb_cairo_font_options.c +6 -4
- data/src/rb_cairo_glyph.c +4 -3
- data/src/rb_cairo_matrix.c +97 -4
- data/src/rb_cairo_path.c +408 -24
- data/src/rb_cairo_pattern.c +130 -70
- data/src/rb_cairo_private.c +40 -13
- data/src/rb_cairo_private.h +40 -2
- data/src/rb_cairo_scaled_font.c +3 -10
- data/src/rb_cairo_surface.c +172 -50
- data/src/rb_cairo_text_extents.c +3 -2
- metadata +15 -5
- data/src/lib/cairo/context/quad.rb +0 -19
data/ChangeLog
CHANGED
@@ -1,3 +1,262 @@
|
|
1
|
+
2007-05-27 Kouhei Sutou <kou@cozmixng.org>
|
2
|
+
|
3
|
+
* Rakefile: improved current release NEWS extraction.
|
4
|
+
|
5
|
+
* NEWS: updated.
|
6
|
+
|
7
|
+
* Rakefile: supported document update.
|
8
|
+
|
9
|
+
* src/depend (install-so): used install-so instead of install.
|
10
|
+
|
11
|
+
* src/rb_cairo_font_options.c (Cairo::FontOptions#merge): renamed
|
12
|
+
to merge! because the method is destructive.
|
13
|
+
|
14
|
+
* src/lib/cairo.rb (Cairo::FontOptions#merge): added
|
15
|
+
non-destructive version.
|
16
|
+
|
17
|
+
2007-05-23 Kouhei Sutou <kou@cozmixng.org>
|
18
|
+
|
19
|
+
* src/lib/cairo.rb (Cairo.normalize_const_name): treated "." as
|
20
|
+
ignore character.
|
21
|
+
|
22
|
+
* src/rb_cairo.c (Cairo::BINDINGS_VERSION): 1.6.0 -> 1.5.0.
|
23
|
+
|
24
|
+
2007-05-22 Kouhei Sutou <kou@cozmixng.org>
|
25
|
+
|
26
|
+
* src/rb_cairo_pattern.c (cr_radial_pattern_get_radial_circles):
|
27
|
+
returned [[x0, y0, r0], [x1, y1, r1]] instead of [x0, y0, r0, x1,
|
28
|
+
y1, r1].
|
29
|
+
|
30
|
+
* src/rb_cairo_path.c: used super.
|
31
|
+
|
32
|
+
* src/rb_cairo_path.c (Cairo::PathMoveTo, Cairo::PathLineTo,
|
33
|
+
Cairo::PathCurveTo, Cairo::PathClosePath): defined each path data
|
34
|
+
type as class.
|
35
|
+
|
36
|
+
2007-05-21 Kouhei Sutou <kou@cozmixng.org>
|
37
|
+
|
38
|
+
* src/rb_cairo_matrix.c (Cairo::Matrix#transform_distance): fixed
|
39
|
+
a typo.
|
40
|
+
|
41
|
+
* src/rb_cairo_matrix.c: added accessors.
|
42
|
+
|
43
|
+
* src/rb_cairo_surface.c: supported 64bit platform. Thanks to
|
44
|
+
Yoshinao Muramatsu!
|
45
|
+
|
46
|
+
2007-05-20 Kouhei Sutou <kou@cozmixng.org>
|
47
|
+
|
48
|
+
* src/rb_cairo_surface.c (cr_win32_surface_initialize): fixed a
|
49
|
+
typo. Thanks to Yoshinao Muramatsu!
|
50
|
+
|
51
|
+
* src/rb_cairo_font_face.c, src/lib/cairo/constants.rb: followed
|
52
|
+
up the previous commit.
|
53
|
+
|
54
|
+
* src/cairo.def, src/rb_cairo_pattern.c, src/rb_cairo_surface.c,
|
55
|
+
src/rb_cairo_font_face.c: removed needless methods XXX#type.
|
56
|
+
|
57
|
+
* src/rb_cairo.h, src/rb_cairo_pattern.c, src/rb_cairo_surface.c:
|
58
|
+
always detected surface and pattern type dynamically.
|
59
|
+
* src/rb_cairo_context.c: followed the above changes.
|
60
|
+
|
61
|
+
* src/rb_cairo.h, src/rb_cairo_surface.c: improved win32 surface
|
62
|
+
support. Thanks to Yoshinao Muramatsu!
|
63
|
+
|
64
|
+
* src/rb_cairo.h, src/cairo.def, src/rb_cairo_constants.rb:
|
65
|
+
added a module for each enum type.
|
66
|
+
* src/lib/cairo/constants.rb: kept the backward compatibility.
|
67
|
+
|
68
|
+
2007-05-19 Kouhei Sutou <kou@cozmixng.org>
|
69
|
+
|
70
|
+
* src/lib/cairo/context/circle.rb (Cairo::Context::Circle#circle):
|
71
|
+
renamed parameter name to be more self-descriptive.
|
72
|
+
|
73
|
+
* src/rb_cairo.h, src/cairo.def, src/rb_cairo_surface.c:
|
74
|
+
supported win32 surface. Thanks to Yoshinao Muramatsu!!!
|
75
|
+
|
76
|
+
* README: added an entry for Yoshinao Muramatsu.
|
77
|
+
|
78
|
+
2007-05-18 Kouhei Sutou <kou@cozmixng.org>
|
79
|
+
|
80
|
+
* src/rb_cairo_private.[ch] (rb_cairo__glyphs_to_array,
|
81
|
+
RB_CAIRO__GLYPHS_TO_ARRAY): fixed wrong memory allocation.
|
82
|
+
* src/rb_cairo_context.c, src/rb_cairo_scaled_font.c: used
|
83
|
+
RB_CAIRO__GLYPHS_TO_ARRAY instead of rb_cairo__glyphs_to_array().
|
84
|
+
|
85
|
+
* src/rb_cairo_context.c (cr_set_dash):
|
86
|
+
- made offset optional.
|
87
|
+
- accepted a number for dash_array.
|
88
|
+
|
89
|
+
2007-05-15 Kouhei Sutou <kou@cozmixng.org>
|
90
|
+
|
91
|
+
* src/rb_cairo_context.c (cr_get_group_target): added NULL check.
|
92
|
+
|
93
|
+
* src/rb_cairo_context.c (cr_get_font_face): checked status of got
|
94
|
+
font face not context.
|
95
|
+
|
96
|
+
* src/rb_cairo_context.c (cr_set_font_face): accepted nil as font
|
97
|
+
face.
|
98
|
+
|
99
|
+
* src/rb_cairo_context.c (cr_copy_path, cr_copy_path_flat):
|
100
|
+
checked status of copied path not context.
|
101
|
+
|
102
|
+
2007-05-10 Kouhei Sutou <kou@cozmixng.org>
|
103
|
+
|
104
|
+
* src/rb_cairo_surface.c (cr_surface_create_similar): retrieved
|
105
|
+
corresponding Ruby class by cairo_surface_get_type().
|
106
|
+
|
107
|
+
2007-05-06 Kouhei Sutou <kou@cozmixng.org>
|
108
|
+
|
109
|
+
* src/rb_cairo_path.c, src/lib/cairo.rb, src/lib/cairo/path.rb:
|
110
|
+
added path related methods such as move_to, line_to and curve_to
|
111
|
+
to Cairo::Path.
|
112
|
+
|
113
|
+
* src/lib/cairo/context/path.rb
|
114
|
+
(Cairo::Context::Path#transform_path): multi-thread safe.
|
115
|
+
|
116
|
+
2007-05-03 Kouhei Sutou <kou@cozmixng.org>
|
117
|
+
|
118
|
+
* src/rb_cairo_path.c
|
119
|
+
(Cairo::PathData#move_to?, Cairo::PathData#line_to?,
|
120
|
+
Cairo::PathData#curve_to?, Cairo::PathData#close_path?): added.
|
121
|
+
|
122
|
+
* src/rb_cairo_private.h
|
123
|
+
(CBOOL2RVAL, RVAL2CBOOL): added.
|
124
|
+
(rb_cairo__is_kind_of): added.
|
125
|
+
* src/*.c: used rb_cairo__is_kind_of() instead of
|
126
|
+
RTEST(rb_obj_is_kind_of(...)).
|
127
|
+
|
128
|
+
* src/rb_cairo_path.c
|
129
|
+
(Cairo::Path#size, Cairo::Path#length, Cairo::Path#empty?): added.
|
130
|
+
(Cairo::Path#[]): supported negative index.
|
131
|
+
|
132
|
+
* src/rb_cairo_path.c (Cairo::PathData#each): added.
|
133
|
+
|
134
|
+
* src/rb_cairo.h, src/rb_cairo_path.c: added Cairo::Point and
|
135
|
+
Cairo::PathData.
|
136
|
+
|
137
|
+
* src/lib/cairo/point.rb (Cairo::Point#distance): moved from
|
138
|
+
Cairo::Context::Path::Point.
|
139
|
+
* src/lib/cairo/context/path.rb (Cairo::Context::Path::Point):
|
140
|
+
removed.
|
141
|
+
* src/lib/cairo.rb, src/lib/cairo/context/path.rb: used Cairo::Point.
|
142
|
+
|
143
|
+
2007-05-01 Kouhei Sutou <kou@cozmixng.org>
|
144
|
+
|
145
|
+
* src/rb_cairo_pattern.c
|
146
|
+
(cr_gradient_pattern_get_color_stop_color): cleanup.
|
147
|
+
|
148
|
+
* src/rb_cairo.[ch]: exported Cairo::Color and Cairo::Color::Base.
|
149
|
+
* src/lib/cairo.rb: require cairo/color before cairo.so to export
|
150
|
+
Cairo::Color to cairo.so.
|
151
|
+
|
152
|
+
* src/rb_cairo_pattern.c: implemented src/lib/cairo/pattern.rb
|
153
|
+
methods in C.
|
154
|
+
* src/lib/cairo/pattern.rb: removed.
|
155
|
+
* src/lib/cairo.rb: removed cairo/pattern.
|
156
|
+
|
157
|
+
* src/rb_cairo_private.[ch] (rb_cairo__const_get,
|
158
|
+
Init_cairo_private): added.
|
159
|
+
* src/rb_cairo.c: moved Init_* declarations to rb_cairo_private.h.
|
160
|
+
* src/rb_cairo_constants.c: supported abbrev notation for constant
|
161
|
+
name. We can write just like
|
162
|
+
context.antialias = :none
|
163
|
+
instead of
|
164
|
+
context.antialias = Cairo::ANTIALIAS_NONE
|
165
|
+
|
166
|
+
* src/lib/cairo.rb (Cairo.normalize_const_name): added.
|
167
|
+
* src/lib/cairo/color.rb: used Cairo.normalize_const_name.
|
168
|
+
|
169
|
+
2007-04-30 Kouhei Sutou <kou@cozmixng.org>
|
170
|
+
|
171
|
+
* src/lib/cairo/context.rb, src/lib/cairo/context/quad.rb: moved
|
172
|
+
quadratic Bézier curve support to ...
|
173
|
+
* src/rb_cairo_context.c: ... here.
|
174
|
+
|
175
|
+
* src/lib/cairo/context/path.rb
|
176
|
+
(Cairo::Context::Path#map_path_onto): fixed a boundary value bug.
|
177
|
+
|
178
|
+
2007-04-19 Kouhei Sutou <kou@cozmixng.org>
|
179
|
+
|
180
|
+
* src/rb_cairo_context.c (Cairo::Context#stroke,
|
181
|
+
Cairo::Context#fill, Cairo::Context#clip): accept 'preserve' option
|
182
|
+
to change XXX and XXX_preserve.
|
183
|
+
* src/lib/cairo/context.rb (Cairo::Context#stroke_preserve,
|
184
|
+
Cairo::Context#fill_preserve, Cairo::Context#clip_preserve): moved
|
185
|
+
from src/rb_cairo_context.c.
|
186
|
+
|
187
|
+
2007-04-18 Kouhei Sutou <kou@cozmixng.org>
|
188
|
+
|
189
|
+
* src/lib/cairo/color.rb (Cairo::Color.parse):
|
190
|
+
- supported :hsv and :hsva.
|
191
|
+
- added robust parse mode.
|
192
|
+
|
193
|
+
* samples/blur.rb: used convenience interface of Cairo::ImageSurface.new.
|
194
|
+
|
195
|
+
* src/lib/cairo/color.rb: supported HSV.
|
196
|
+
|
197
|
+
2007-04-16 Kouhei Sutou <kou@cozmixng.org>
|
198
|
+
|
199
|
+
* src/lib/cairo/color.rb, src/lib/cairo/pattern.rb,
|
200
|
+
src/lib/cairo/context/color.rb, src/rb_cairo_pattern.c: improved
|
201
|
+
Cairo::Color interface.
|
202
|
+
|
203
|
+
* sample/: used Cairo::Color.
|
204
|
+
|
205
|
+
* src/lib/cairo/color.rb: added validation.
|
206
|
+
|
207
|
+
* misc/update-colors.rb: supported X11 color names.
|
208
|
+
* src/lib/cairo/colors.rb: updated.
|
209
|
+
|
210
|
+
* misc/update-colors.rb: added colors.rb generator that extracts
|
211
|
+
popular colors from Wikipedia:List_of_colors page.
|
212
|
+
|
213
|
+
* src/lib/cairo/colors.rb: added popular colors generated by
|
214
|
+
updated-colors.rb.
|
215
|
+
|
216
|
+
* src/lib/cairo/color.rb: added high-level color class including
|
217
|
+
CMYK support.
|
218
|
+
|
219
|
+
* src/rb_cairo_pattern.c, src/lib/cairo.rb,
|
220
|
+
src/lib/cairo/context.rb, src/lib/cairo/pattern.rb: supported
|
221
|
+
Cairo::Color.
|
222
|
+
|
223
|
+
2007-04-15 Kouhei Sutou <kou@cozmixng.org>
|
224
|
+
|
225
|
+
* src/rb_cairo_context.c
|
226
|
+
(cr_push_group): added error handling.
|
227
|
+
(cr_pop_group_to_source): updated source class.
|
228
|
+
|
229
|
+
* src/lib/cairo/context.rb, src/lib/cairo/context/blur.rb: added
|
230
|
+
Cairo::Context#pseudo_blur.
|
231
|
+
|
232
|
+
* samples/blur.rb: added a sample script for Cairo::Context#pseudo_blur.
|
233
|
+
|
234
|
+
* src/rb_cairo_context.c
|
235
|
+
(cr_pop_group): returned pattern.
|
236
|
+
(cr_push_group): returned popped pattern if not pop_to_source.
|
237
|
+
|
238
|
+
2007-04-13 Kouhei Sutou <kou@cozmixng.org>
|
239
|
+
|
240
|
+
* Rakefile: supported 'rake release'.
|
241
|
+
|
242
|
+
* extconf.rb, Rakefile: supported RubyGems.
|
243
|
+
|
244
|
+
2007-04-08 Kouhei Sutou <kou@cozmixng.org>
|
245
|
+
|
246
|
+
* src/rb_cairo_surface.c (yield_and_finish):
|
247
|
+
- renamed from ensure_finish_proc().
|
248
|
+
- don't use ensure.
|
249
|
+
|
250
|
+
* src/rb_cairo_surface.c (ensure_finish_proc): supported
|
251
|
+
Cairo::Surface.new with block. If block is exited, a surface is
|
252
|
+
finished automatically.
|
253
|
+
|
254
|
+
* sample/*.rb: followed the above change.
|
255
|
+
|
256
|
+
2007-03-10 Kouhei Sutou <kou@cozmixng.org>
|
257
|
+
|
258
|
+
* src/rb_cairo.c (Cairo::BINDINGS_VERSION): 1.4.1 -> 1.6.0.
|
259
|
+
|
1
260
|
2007-03-10 Kouhei Sutou <kou@cozmixng.org>
|
2
261
|
|
3
262
|
* NEWS: added 1.4.1 entry.
|
data/NEWS
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
Release 1.5.0 (2007-05-27) Kouhei Sutou <kou@cozmixng.org>)
|
2
|
+
==========================================================
|
3
|
+
|
4
|
+
Many API improvement.
|
5
|
+
|
6
|
+
Features
|
7
|
+
--------
|
8
|
+
* Support Cairo::Surface.new with block.
|
9
|
+
* Support RubyGems.
|
10
|
+
* Add experimental API Cairo::Context#pseudo_blur. (API
|
11
|
+
may be changed.)
|
12
|
+
* Fix strange Cairo::Context#push_group and
|
13
|
+
Cairo::Context#pop_group behaviour.
|
14
|
+
* Fix Cairo::Context::Path#map_path_onto.
|
15
|
+
* Add high-level color interface. (Cairo::Color)
|
16
|
+
* Improve color related API. For example:
|
17
|
+
From:
|
18
|
+
context.set_source_rgb(1, 0, 0)
|
19
|
+
To:
|
20
|
+
context.set_source_color(:red)
|
21
|
+
|
22
|
+
* Support RGB/CMYK/HSV conversion.
|
23
|
+
* Many default color definitions.
|
24
|
+
* Support path creation using Cairo::Path without
|
25
|
+
Cairo::Context.
|
26
|
+
* Improve constant value specify API. For example:
|
27
|
+
From:
|
28
|
+
Cairo::ImageSurface.new(Cairo::FORMAT_ARGB32, 100, 100)
|
29
|
+
To:
|
30
|
+
Cairo::ImageSurface.new(:argb32, 100, 100)
|
31
|
+
* Support win32 surface. (Yoshinao Muramatsu)
|
32
|
+
|
1
33
|
Release 1.4.1 (2007-03-10 Kouhei Sutou <kou@cozmixng.org>)
|
2
34
|
==========================================================
|
3
35
|
|
data/README
CHANGED
@@ -30,3 +30,8 @@ it could be improved, please feel free to send a message to the cairo
|
|
30
30
|
mailinglist at cairo@cairographics.org , which is archived at
|
31
31
|
|
32
32
|
http://cairographics.org/cgi-bin/mailman/listinfo/cairo
|
33
|
+
|
34
|
+
Thanks
|
35
|
+
------
|
36
|
+
|
37
|
+
* Yoshinao Muramatsu: win32 surface support patch.
|
data/Rakefile
CHANGED
@@ -12,8 +12,11 @@ truncate_base_dir = Proc.new do |x|
|
|
12
12
|
x.gsub(/^#{Regexp.escape(base_dir + File::SEPARATOR)}/, '')
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
cairo_ext_dir = File.join(base_dir, 'src')
|
16
|
+
cairo_lib_dir = File.join(cairo_ext_dir, 'lib')
|
17
|
+
$LOAD_PATH.unshift(cairo_ext_dir)
|
18
|
+
$LOAD_PATH.unshift(cairo_lib_dir)
|
19
|
+
ENV["RUBYLIB"] = "#{cairo_lib_dir}:#{cairo_ext_dir}:#{ENV['RUBYLIB']}"
|
17
20
|
require 'cairo'
|
18
21
|
|
19
22
|
manifest = File.join(base_dir, "Manifest.txt")
|
@@ -42,7 +45,8 @@ at_exit do
|
|
42
45
|
end
|
43
46
|
|
44
47
|
ENV["VERSION"] ||= Cairo.bindings_version
|
45
|
-
|
48
|
+
version = ENV["VERSION"]
|
49
|
+
project = Hoe.new('cairo', version) do |project|
|
46
50
|
project.rubyforge_name = 'cairo'
|
47
51
|
authors = File.join(base_dir, "AUTHORS")
|
48
52
|
project.author = File.readlines(authors).collect do |line|
|
@@ -62,9 +66,10 @@ project = Hoe.new('cairo', ENV["VERSION"]) do |project|
|
|
62
66
|
:has_rdoc => false,
|
63
67
|
}
|
64
68
|
news = File.join(base_dir, "NEWS")
|
65
|
-
project.changes =
|
69
|
+
project.changes = File.read(news).gsub(/\n+^Release(?m:.*)/, '')
|
66
70
|
project.description = "Ruby bindings for cairo"
|
67
71
|
project.need_tar = false
|
72
|
+
project.remote_rdoc_dir = "doc"
|
68
73
|
end
|
69
74
|
|
70
75
|
project.spec.dependencies.delete_if {|dependency| dependency.name == "hoe"}
|
@@ -101,3 +106,82 @@ task :uninstall do
|
|
101
106
|
rm_f project.bin_files.collect {|f| f.sub(/^bin#{File::SEPARATOR}/, '')}
|
102
107
|
end
|
103
108
|
end
|
109
|
+
|
110
|
+
|
111
|
+
# for releasing
|
112
|
+
task :dist do
|
113
|
+
sh "./dist.sh", version
|
114
|
+
end
|
115
|
+
|
116
|
+
# for documentation
|
117
|
+
langs = [
|
118
|
+
["en", "English"],
|
119
|
+
["ja", "日本語"],
|
120
|
+
]
|
121
|
+
|
122
|
+
rcairo_doc_dir = File.expand_path(File.join(base_dir, "..", "rcairo-doc"))
|
123
|
+
rcairo_doc_css = File.join(rcairo_doc_dir, "doc.css")
|
124
|
+
rcairo_doc_title_image = File.join(rcairo_doc_dir, "rcairo-title.png")
|
125
|
+
doc_dir = "doc"
|
126
|
+
doc_index = File.join(doc_dir, "index.html")
|
127
|
+
doc_css = File.join(doc_dir, "doc.css")
|
128
|
+
doc_title_image = File.join(doc_dir, "rcairo-title.png")
|
129
|
+
task(doc_index).instance_variable_get("@actions").clear
|
130
|
+
|
131
|
+
file doc_index => doc_dir do
|
132
|
+
mkdir_p doc_dir
|
133
|
+
end
|
134
|
+
|
135
|
+
file doc_title_image => rcairo_doc_title_image do
|
136
|
+
cp rcairo_doc_title_image, doc_title_image
|
137
|
+
end
|
138
|
+
|
139
|
+
file doc_css => [rcairo_doc_css, doc_title_image] do
|
140
|
+
cp rcairo_doc_css, doc_css
|
141
|
+
end
|
142
|
+
|
143
|
+
file doc_index => doc_css do
|
144
|
+
File.open(doc_index, "w") do |index|
|
145
|
+
index << <<-EOH
|
146
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
147
|
+
<html>
|
148
|
+
<head>
|
149
|
+
<title>rcairo reference manual</title>
|
150
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
151
|
+
</head>
|
152
|
+
|
153
|
+
<body>
|
154
|
+
<h1>rcairo reference manual</h1>
|
155
|
+
|
156
|
+
<ul>
|
157
|
+
EOH
|
158
|
+
|
159
|
+
langs.each do |lang, native_lang|
|
160
|
+
index << <<-EOH
|
161
|
+
<li><a href="#{lang}/">#{native_lang}</a></li>
|
162
|
+
EOH
|
163
|
+
end
|
164
|
+
|
165
|
+
index << <<-EOH
|
166
|
+
</ui>
|
167
|
+
|
168
|
+
<p><a href="../">Up</a></p>
|
169
|
+
</body>
|
170
|
+
</html>
|
171
|
+
EOH
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
langs.each do |lang,|
|
176
|
+
lang_doc_index = File.join(doc_dir, lang, "index.html")
|
177
|
+
task doc_index => lang_doc_index
|
178
|
+
file lang_doc_index do
|
179
|
+
lang_doc_dir = File.join(doc_dir, lang)
|
180
|
+
lang_rcairo_doc_dir = File.join(rcairo_doc_dir, lang)
|
181
|
+
mkdir_p lang_doc_dir
|
182
|
+
cp Dir[File.join(lang_rcairo_doc_dir, "*.rd")], lang_doc_dir
|
183
|
+
ruby File.join(rcairo_doc_dir, "update-html.rb"), lang_doc_dir
|
184
|
+
ruby File.join(rcairo_doc_dir, "update-html.rb"), lang_doc_dir
|
185
|
+
rm Dir[File.join(lang_doc_dir, "*.{rd,rdc,rbl}")]
|
186
|
+
end
|
187
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'scrapi'
|
5
|
+
rescue LoadError
|
6
|
+
require 'rubygems'
|
7
|
+
require 'scrapi'
|
8
|
+
end
|
9
|
+
|
10
|
+
def collect_popular_colors(src=nil)
|
11
|
+
src ||= URI("http://en.wikipedia.org/wiki/List_of_colors")
|
12
|
+
|
13
|
+
row = Scraper.define do
|
14
|
+
process "th > a:first-child", :name => :text
|
15
|
+
process "td:nth-child(3)", :hex_triplet => :text
|
16
|
+
process "td:nth-child(4)", :red => :text
|
17
|
+
process "td:nth-child(5)", :green => :text
|
18
|
+
process "td:nth-child(6)", :blue => :text
|
19
|
+
result :name, :hex_triplet, :red, :green, :blue
|
20
|
+
end
|
21
|
+
|
22
|
+
scraper = Scraper.define do
|
23
|
+
process "table > tr", "rows[]" => row
|
24
|
+
result :rows
|
25
|
+
end
|
26
|
+
|
27
|
+
scraper.scrape(src)
|
28
|
+
end
|
29
|
+
|
30
|
+
def collect_x11_colors(src=nil)
|
31
|
+
src ||= URI("http://en.wikipedia.org/wiki/X11_color_names")
|
32
|
+
|
33
|
+
row = Scraper.define do
|
34
|
+
process "th", :name => :text
|
35
|
+
process "td:nth-child(2)", :hex_triplet => "@bgcolor"
|
36
|
+
process "td:nth-child(6)", :red => :text
|
37
|
+
process "td:nth-child(7)", :green => :text
|
38
|
+
process "td:nth-child(8)", :blue => :text
|
39
|
+
result :name, :hex_triplet, :red, :green, :blue
|
40
|
+
end
|
41
|
+
|
42
|
+
scraper = Scraper.define do
|
43
|
+
process "table > tr", "rows[]" => row
|
44
|
+
result :rows
|
45
|
+
end
|
46
|
+
|
47
|
+
x11_colors = scraper.scrape(src)
|
48
|
+
x11_colors.collect do |color|
|
49
|
+
if color.name
|
50
|
+
color.name = color.name.gsub(/([a-z]|[A-Z]+)([A-Z])/, "\\1 \\2")
|
51
|
+
end
|
52
|
+
color
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def constanize_color_name(name)
|
57
|
+
names = name.gsub(/é/, "e").upcase.split(/(?:\s*\(|\)\s*)/)
|
58
|
+
names = names.collect {|name| name.gsub(/[ \-]/, "_")}
|
59
|
+
if names[1] and ["WEB", "COLOR_WHEEL", "X11"].include?(names[1])
|
60
|
+
real_names = [names.join("_")]
|
61
|
+
if names == ["ORANGE", "COLOR_WHEEL"]
|
62
|
+
real_names << names.first
|
63
|
+
end
|
64
|
+
names = real_names
|
65
|
+
end
|
66
|
+
names
|
67
|
+
end
|
68
|
+
|
69
|
+
colors = collect_popular_colors
|
70
|
+
x11_colors = collect_x11_colors
|
71
|
+
|
72
|
+
top_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
73
|
+
colors_rb = File.join(top_dir, "src", "lib", "cairo", "colors.rb")
|
74
|
+
File.open(colors_rb, "w") do |rb|
|
75
|
+
rb.puts <<-HEADER
|
76
|
+
require 'cairo/color'
|
77
|
+
|
78
|
+
module Cairo
|
79
|
+
module Color
|
80
|
+
HEADER
|
81
|
+
|
82
|
+
[
|
83
|
+
[colors, nil],
|
84
|
+
[x11_colors, "X11"]
|
85
|
+
].each do |colors, mod|
|
86
|
+
indent = " " * 2
|
87
|
+
if mod
|
88
|
+
rb.puts("#{indent}module #{mod}")
|
89
|
+
indent << " "
|
90
|
+
end
|
91
|
+
colors.each do |color|
|
92
|
+
if color.name and color.hex_triplet and
|
93
|
+
color.red and color.green and color.blue
|
94
|
+
begin
|
95
|
+
names = constanize_color_name(color.name)
|
96
|
+
|
97
|
+
hexes = color.hex_triplet.scan(/[\da-f]{2,2}/i)
|
98
|
+
red_hex, green_hex, blue_hex = hexes.collect {|hex| hex.hex}
|
99
|
+
|
100
|
+
red = Integer(color.red)
|
101
|
+
green = Integer(color.green)
|
102
|
+
blue = Integer(color.blue)
|
103
|
+
|
104
|
+
if [red_hex, green_hex, blue_hex] != [red, green, blue]
|
105
|
+
warning_message = "Hex triplet(#{color.hex_triplet}) of "
|
106
|
+
warning_message << "#{color.name} is difference from RGB"
|
107
|
+
warning_message << "(#{red}, #{green}, #{blue}). "
|
108
|
+
if ["Alice Blue", "Old Rose"].include?(color.name)
|
109
|
+
warning_message << "Use hex triplet value."
|
110
|
+
red, green, blue = red_hex, green_hex, blue_hex
|
111
|
+
else
|
112
|
+
warning_message << "Use RGB value."
|
113
|
+
end
|
114
|
+
puts warning_message
|
115
|
+
end
|
116
|
+
|
117
|
+
r, g, b = [red, green, blue].collect {|v| v / 255.0}
|
118
|
+
|
119
|
+
rb.puts("#{indent}# #{color.name}: #{color.hex_triplet}")
|
120
|
+
name, *alias_names = names
|
121
|
+
rb.puts("#{indent}#{name} = RGB.new(#{r}, #{g}, #{b})")
|
122
|
+
alias_names.each do |alias_name|
|
123
|
+
rb.puts("#{indent}#{alias_name} = #{name}")
|
124
|
+
end
|
125
|
+
rescue ArgumentError
|
126
|
+
next
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
if mod
|
132
|
+
indent = indent[0..-3]
|
133
|
+
rb.puts("#{indent}end")
|
134
|
+
rb.puts("#{indent}include #{mod}")
|
135
|
+
rb.puts
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
rb.puts <<-FOOTER
|
140
|
+
end
|
141
|
+
end
|
142
|
+
FOOTER
|
143
|
+
end
|