cairo 1.10.0 → 1.10.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/Gemfile +14 -0
- data/NEWS +33 -0
- data/README.rdoc +115 -0
- data/Rakefile +69 -80
- data/ext/cairo/cairo.def +1 -1
- data/ext/cairo/depend +2 -0
- data/ext/cairo/extconf.rb +7 -5
- data/ext/cairo/rb_cairo.c +4 -1
- data/ext/cairo/rb_cairo.h +4 -0
- data/ext/cairo/rb_cairo_constants.c +6 -2
- data/ext/cairo/rb_cairo_context.c +3 -2
- data/ext/cairo/rb_cairo_device.c +8 -0
- data/ext/cairo/rb_cairo_font_face.c +1 -1
- data/ext/cairo/rb_cairo_surface.c +40 -0
- data/lib/cairo.rb +3 -3
- data/lib/cairo/color.rb +4 -4
- data/lib/cairo/context/path.rb +2 -1
- data/test/run-test.rb +1 -1
- data/test/test_context.rb +1 -1
- data/test/test_font_face.rb +1 -1
- data/test/test_recording_surface.rb +4 -1
- data/test/test_xml_surface.rb +2 -1
- metadata +147 -47
- data/extconf.rb +0 -45
- data/misc/update-colors.rb +0 -143
- data/samples/agg/README +0 -4
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- mode: ruby; coding: utf-8 -*-
|
2
|
+
|
3
|
+
source "http://rubygems.org/"
|
4
|
+
|
5
|
+
group :development, :test do
|
6
|
+
gem 'pkg-config'
|
7
|
+
gem "test-unit"
|
8
|
+
gem "test-unit-notify"
|
9
|
+
gem "rake"
|
10
|
+
gem "rake-compiler"
|
11
|
+
gem "jeweler"
|
12
|
+
gem "yard"
|
13
|
+
gem "packnga"
|
14
|
+
end
|
data/NEWS
CHANGED
@@ -1,3 +1,36 @@
|
|
1
|
+
Release 1.10.1 (2011-10-12) Kouhei Sutou <kou@cozmixng.org>)
|
2
|
+
============================================================
|
3
|
+
|
4
|
+
Features
|
5
|
+
--------
|
6
|
+
|
7
|
+
* Accepted Cairo::EXTEND_PAD as extend value.
|
8
|
+
* Suppressed a warning. [Stefan Salewski]
|
9
|
+
* Bound CAIRO_SURFACE_TYPE_XLIB and CAIRO_SURFACE_TYPE_XCB.
|
10
|
+
* Supported cairo 1.10.2.
|
11
|
+
* Fixed recording surface test. #4 [Mamoru Tasaka]
|
12
|
+
* AcceptedCairo::OPERATOR_HSL_LUMINDSITY as operator value.
|
13
|
+
#6 [Matt Bramlage]
|
14
|
+
* Suppressed warnings on Windows. [Nikolai Weibull]
|
15
|
+
* Added --without-vendor-override options to extconf.rb.
|
16
|
+
[Nikolai Weibull]
|
17
|
+
|
18
|
+
Thanks
|
19
|
+
------
|
20
|
+
|
21
|
+
* Stefan Salewski
|
22
|
+
* Mamoru Tasaka
|
23
|
+
* Matt Bramlage
|
24
|
+
* Nikolai Weibull
|
25
|
+
|
26
|
+
Release 1.10.0 (2010-09-12) Kouhei Sutou <kou@cozmixng.org>)
|
27
|
+
===========================================================
|
28
|
+
|
29
|
+
Features
|
30
|
+
--------
|
31
|
+
|
32
|
+
* Support cairo 1.10.0.
|
33
|
+
|
1
34
|
Release 1.8.5 (2010-08-28) Kouhei Sutou <kou@cozmixng.org>)
|
2
35
|
===========================================================
|
3
36
|
|
data/README.rdoc
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
= README
|
2
|
+
|
3
|
+
== Name
|
4
|
+
|
5
|
+
rcairo
|
6
|
+
|
7
|
+
== Description
|
8
|
+
|
9
|
+
Ruby bindings for cairo // cairo extension for Ruby
|
10
|
+
|
11
|
+
http://cairographics.org/
|
12
|
+
|
13
|
+
== Dependencies
|
14
|
+
|
15
|
+
* ruby >= 1.8 (1.9.2 also supported!)
|
16
|
+
* cairo >= 1.2.0 (1.10.0 also supported!)
|
17
|
+
|
18
|
+
== Install
|
19
|
+
|
20
|
+
=== Package
|
21
|
+
|
22
|
+
This way is recommended.
|
23
|
+
|
24
|
+
# gem install cairo
|
25
|
+
|
26
|
+
=== Self build
|
27
|
+
|
28
|
+
For experimental users.
|
29
|
+
|
30
|
+
Download rcairo-X.Y.Z.tar.gz from http://cairographics.org/releases/
|
31
|
+
|
32
|
+
Extracting:
|
33
|
+
% tar xvzf rcairo-X.Y.Z.tar.gz
|
34
|
+
|
35
|
+
Compiling:
|
36
|
+
% cd rcairo-X.Y.Z
|
37
|
+
% ruby extconf.rb # to check for dependencies and create Makefiles
|
38
|
+
% make # to compile
|
39
|
+
|
40
|
+
# make install # to install the cairo extension.
|
41
|
+
# The samples in the samples folder should be able
|
42
|
+
# to run before installation except text-on-path.rb
|
43
|
+
# and text2.rb. They uses Ruby/Pango with rcairo
|
44
|
+
# support. So you need to install rcairo and build
|
45
|
+
# Ruby/Pango with it before you run them.
|
46
|
+
|
47
|
+
Options to extconf.rb:
|
48
|
+
|
49
|
+
* --without-vendor-override: Use system libraries instead of those found in
|
50
|
+
vendor/local for compiling
|
51
|
+
|
52
|
+
== Windows
|
53
|
+
|
54
|
+
cairo-X.Y.Z-x86-mswin32.gem includes cairo related binaries.
|
55
|
+
|
56
|
+
* cairo related binaries:
|
57
|
+
http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/
|
58
|
+
|
59
|
+
* cairo-X.Y.Z-a_win32.zip
|
60
|
+
* cairo-dev-X.Y.Z-a_win32.zip
|
61
|
+
* libpng-X.Y.Z-a_win32.zip
|
62
|
+
* zlib-X.Y.Z-a_win32.zip
|
63
|
+
* expat_X.Y.Z-a_win32.zip
|
64
|
+
* fontconfig_X.Y.Z-a_win32.zip
|
65
|
+
* freetype_X.Y.Z-a_win32.zip
|
66
|
+
|
67
|
+
== Documents
|
68
|
+
|
69
|
+
* Reference manual:
|
70
|
+
http://cairo.rubyforge.org/doc/
|
71
|
+
* Repository of the reference manual:
|
72
|
+
http://github.com/rcairo/doc
|
73
|
+
* An article for rcairo on Rubyst Magazine a.k.a. RubiMa (in Japanese):
|
74
|
+
http://jp.rubyist.net/magazine/?0019-cairo
|
75
|
+
|
76
|
+
== Source
|
77
|
+
|
78
|
+
There is the rcairo repository at GitHub:
|
79
|
+
http://github.com/rcairo/rcairo
|
80
|
+
|
81
|
+
== Mailing list
|
82
|
+
|
83
|
+
If you have trouble with cairo or rcairo, or you have some ideas for how
|
84
|
+
it could be improved, please feel free to send a message to the cairo
|
85
|
+
mailinglist at cairo@cairographics.org , which is archived at
|
86
|
+
|
87
|
+
http://cairographics.org/cgi-bin/mailman/listinfo/cairo
|
88
|
+
|
89
|
+
== Thanks
|
90
|
+
|
91
|
+
* Yoshinao Muramatsu: win32 surface support patch.
|
92
|
+
* NANKI Haruo: some bug fix patches.
|
93
|
+
* Paul van Tilburg:
|
94
|
+
* some patches that support ruby 1.9.
|
95
|
+
* some suggestions.
|
96
|
+
* Binzo: some bug reports and fixed that.
|
97
|
+
* kimura wataru:
|
98
|
+
* some advices for RubyCocoa.
|
99
|
+
* reports a bug.
|
100
|
+
* OBATA Akio:
|
101
|
+
* reports a bug.
|
102
|
+
* some suggestions.
|
103
|
+
* James Healy: reports bugs.
|
104
|
+
* Carsten Bormann: A suggestion.
|
105
|
+
* Davide Rambaldi: A suggestion.
|
106
|
+
* Yusuke ENDOH: reports a bug.
|
107
|
+
* Yuta Taniguchi: a bug fix patch.
|
108
|
+
* kimura wataru:
|
109
|
+
* reports a bug.
|
110
|
+
* some patches.
|
111
|
+
* Masayas TARUI:
|
112
|
+
* Windows support.
|
113
|
+
* Stefan Salewski: reports a bug.
|
114
|
+
* Mamoru Tasaka: reports a bug.
|
115
|
+
* Nikolai Weibull: reports problems.
|
data/Rakefile
CHANGED
@@ -5,13 +5,13 @@ require 'English'
|
|
5
5
|
require 'find'
|
6
6
|
require 'fileutils'
|
7
7
|
require 'rubygems'
|
8
|
-
require '
|
8
|
+
require 'rubygems/package_task'
|
9
|
+
require 'yard'
|
10
|
+
require 'jeweler'
|
9
11
|
require 'rake/extensiontask'
|
12
|
+
require 'packnga'
|
10
13
|
|
11
14
|
base_dir = File.join(File.dirname(__FILE__))
|
12
|
-
truncate_base_dir = Proc.new do |x|
|
13
|
-
x.gsub(/^#{Regexp.escape(base_dir + File::SEPARATOR)}/, '')
|
14
|
-
end
|
15
15
|
|
16
16
|
cairo_ext_dir = File.join(base_dir, 'ext', 'cairo')
|
17
17
|
cairo_lib_dir = File.join(base_dir, 'lib')
|
@@ -19,79 +19,67 @@ $LOAD_PATH.unshift(cairo_ext_dir)
|
|
19
19
|
$LOAD_PATH.unshift(cairo_lib_dir)
|
20
20
|
ENV["RUBYLIB"] = "#{cairo_lib_dir}:#{cairo_ext_dir}:#{ENV['RUBYLIB']}"
|
21
21
|
|
22
|
-
def guess_rcairo_version
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
extconf.rb pkg-config.rb)
|
32
|
-
excluded_components = %w(.cvsignore .gdb_history CVS depend Makefile pkg
|
33
|
-
.test-result .gitignore .git vendor)
|
34
|
-
excluded_suffixes = %w(.png .ps .pdf .o .so .a .txt .~ .log)
|
35
|
-
Find.find(base_dir) do |target|
|
36
|
-
target = truncate_base_dir[target]
|
37
|
-
components = target.split(File::SEPARATOR)
|
38
|
-
if components.size == 1 and !File.directory?(target)
|
39
|
-
next unless base_dir_included_components.include?(components[0])
|
22
|
+
def guess_rcairo_version(cairo_ext_dir)
|
23
|
+
version = {}
|
24
|
+
File.open(File.join(cairo_ext_dir, "rb_cairo.h")) do |rb_cairo_h|
|
25
|
+
rb_cairo_h.each_line do |line|
|
26
|
+
case line
|
27
|
+
when /\A#define RB_CAIRO_VERSION_([A-Z]+) (\d+)/
|
28
|
+
version[$1.downcase] = $2
|
29
|
+
end
|
30
|
+
end
|
40
31
|
end
|
41
|
-
|
42
|
-
next if excluded_suffixes.include?(File.extname(target))
|
43
|
-
manifest_contents << target if File.file?(target)
|
32
|
+
[version["major"], version["minor"], version["micro"]].join(".")
|
44
33
|
end
|
45
34
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
FileUtils.rm_f("History.txt")
|
56
|
-
FileUtils.rm_f(manifest)
|
57
|
-
end
|
58
|
-
|
59
|
-
ENV["VERSION"] ||= guess_rcairo_version
|
60
|
-
version = ENV["VERSION"]
|
61
|
-
project = Hoe.spec('cairo') do |project|
|
62
|
-
project.version = version
|
63
|
-
project.rubyforge_name = 'cairo'
|
35
|
+
ENV["VERSION"] ||= guess_rcairo_version(cairo_ext_dir)
|
36
|
+
version = ENV["VERSION"].dup
|
37
|
+
spec = nil
|
38
|
+
Jeweler::Tasks.new do |_spec|
|
39
|
+
spec = _spec
|
40
|
+
spec.name = "cairo"
|
41
|
+
spec.version = version
|
42
|
+
spec.rubyforge_project = 'cairo'
|
43
|
+
spec.homepage = 'http://cairographics.org/rcairo'
|
64
44
|
authors = File.join(base_dir, "AUTHORS")
|
65
|
-
|
45
|
+
spec.authors = File.readlines(authors).collect do |line|
|
66
46
|
if /\s*<[^<>]*>$/ =~ line
|
67
47
|
$PREMATCH
|
68
48
|
else
|
69
49
|
nil
|
70
50
|
end
|
71
51
|
end.compact
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
project.extra_deps << ['pkg-config', '>= 0']
|
82
|
-
platform = ENV["FORCE_PLATFORM"]
|
83
|
-
project.spec_extras[:platform] = platform if platform
|
84
|
-
news = File.join(base_dir, "NEWS")
|
85
|
-
project.changes = File.read(news).gsub(/\n+^Release(?m:.*)/, '')
|
86
|
-
project.description = "Ruby bindings for cairo"
|
87
|
-
project.need_tar = false
|
88
|
-
project.remote_rdoc_dir = "doc"
|
52
|
+
spec.email = ['cairo@cairographics.org']
|
53
|
+
spec.summary = 'Ruby bindings for cairo'
|
54
|
+
spec.description = "Ruby bindings for cairo"
|
55
|
+
spec.license = "Ruby's"
|
56
|
+
spec.files = FileList["{lib,samples}/**/*.rb",
|
57
|
+
"ext/**/{*.def,depend,*.rb,*.c,*.h}",
|
58
|
+
"AUTHORS", "COPYING", "GPL", "Gemfile",
|
59
|
+
"NEWS", "README.rdoc", "Rakefile"]
|
60
|
+
spec.test_files = FileList["test/**/*.rb"]
|
89
61
|
end
|
90
62
|
|
91
|
-
|
63
|
+
Rake::Task["release"].prerequisites.clear
|
64
|
+
Jeweler::RubygemsDotOrgTasks.new do
|
65
|
+
end
|
66
|
+
|
67
|
+
Gem::PackageTask.new(spec) do |pkg|
|
68
|
+
pkg.need_tar_gz = true
|
69
|
+
end
|
70
|
+
|
71
|
+
document_task = Packnga::DocumentTask.new(spec) do |t|
|
72
|
+
t.yard do |yard_task|
|
73
|
+
yard_task.files += FileList["ext/**/*.c"]
|
74
|
+
# yard_task.options += ["--markup", "textile"]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
Packnga::ReleaseTask.new(spec) do |task|
|
79
|
+
end
|
92
80
|
|
93
81
|
binary_dir = File.join("vendor", "local")
|
94
|
-
Rake::ExtensionTask.new("cairo",
|
82
|
+
Rake::ExtensionTask.new("cairo", spec) do |ext|
|
95
83
|
ext.cross_compile = true
|
96
84
|
ext.cross_compiling do |spec|
|
97
85
|
if /mingw|mswin/ =~ spec.platform.to_s
|
@@ -111,8 +99,7 @@ task 'cross' => "download_windows_binaries"
|
|
111
99
|
def download_windows_binaries(binary_dir)
|
112
100
|
base_url = "http://ftp.gnome.org/pub/gnome/binaries/win32/dependencies/"
|
113
101
|
dependencies = [
|
114
|
-
["cairo", "1.10.
|
115
|
-
["cairo-dev", "1.10.0-1"],
|
102
|
+
["cairo", "1.10.2-1"],
|
116
103
|
["libpng", "1.4.3-1"],
|
117
104
|
["zlib", "1.2.5-2"],
|
118
105
|
["expat", "2.0.1-1"],
|
@@ -120,15 +107,24 @@ def download_windows_binaries(binary_dir)
|
|
120
107
|
["freetype", "2.4.2-1"],
|
121
108
|
]
|
122
109
|
dependencies.each do |name, version|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
110
|
+
["", "-dev"].each do |suffix|
|
111
|
+
file_name = "#{name}#{suffix}_#{version}_win32.zip"
|
112
|
+
full_file_name = File.join(binary_dir, file_name)
|
113
|
+
next if File.exist?(full_file_name)
|
114
|
+
open("#{base_url}#{file_name}", "rb") do |input|
|
115
|
+
File.open(full_file_name, "wb") do |output|
|
116
|
+
output.print(input.read)
|
117
|
+
end
|
129
118
|
end
|
119
|
+
sh("unzip", "-o", full_file_name, "-d", binary_dir)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
Dir.glob("#{binary_dir}/lib/pkgconfig/*.pc") do |pc_path|
|
123
|
+
pc = File.read(pc_path)
|
124
|
+
pc = pc.gsub(/\Aprefix=.+$/) {"prefix=#{File.expand_path(binary_dir)}"}
|
125
|
+
File.open(pc_path, "w") do |pc_file|
|
126
|
+
pc_file.print(pc)
|
130
127
|
end
|
131
|
-
sh("unzip", full_file_name, "-d", binary_dir)
|
132
128
|
end
|
133
129
|
end
|
134
130
|
|
@@ -140,17 +136,10 @@ task "download_windows_binaries" do
|
|
140
136
|
end
|
141
137
|
end
|
142
138
|
|
143
|
-
# fix Hoe's incorrect guess.
|
144
|
-
project.spec.executables.clear
|
145
|
-
|
146
|
-
task(:release).prerequisites.reject! {|name| name == "clean"}
|
147
|
-
task(:release_to_rubyforge).prerequisites.reject! {|name| name == "clean"}
|
148
|
-
|
149
139
|
# for releasing
|
150
|
-
task :dist
|
140
|
+
task :dist do
|
151
141
|
sh "./dist.sh", version
|
152
142
|
end
|
153
|
-
task :gem => [:docs]
|
154
143
|
|
155
144
|
# for documentation
|
156
145
|
langs = [
|
data/ext/cairo/cairo.def
CHANGED
data/ext/cairo/depend
ADDED
data/ext/cairo/extconf.rb
CHANGED
@@ -34,11 +34,13 @@ checking_for(checking_message("Win32 OS")) do
|
|
34
34
|
import_library_name = "libruby-#{module_name}.a"
|
35
35
|
$DLDFLAGS << " -Wl,--out-implib=#{import_library_name}"
|
36
36
|
$cleanfiles << import_library_name
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
if with_config('vendor-override', true)
|
38
|
+
binary_base_dir = base_dir + "vendor" + "local"
|
39
|
+
$CFLAGS += " -I#{binary_base_dir}/include"
|
40
|
+
pkg_config_dir = binary_base_dir + "lib" + "pkgconfig"
|
41
|
+
PKGConfig.add_path(pkg_config_dir.to_s)
|
42
|
+
PKGConfig.set_override_variable("prefix", binary_base_dir.to_s)
|
43
|
+
end
|
42
44
|
true
|
43
45
|
else
|
44
46
|
false
|
data/ext/cairo/rb_cairo.c
CHANGED
@@ -76,7 +76,10 @@ Init_cairo ()
|
|
76
76
|
|
77
77
|
rb_define_const (rb_mCairo, "BINDINGS_VERSION",
|
78
78
|
rb_ary_new3 (4,
|
79
|
-
INT2FIX (
|
79
|
+
INT2FIX (RB_CAIRO_VERSION_MAJOR),
|
80
|
+
INT2FIX (RB_CAIRO_VERSION_MINOR),
|
81
|
+
INT2FIX (RB_CAIRO_VERSION_MICRO),
|
82
|
+
Qnil));
|
80
83
|
|
81
84
|
rb_define_module_function (rb_mCairo, "satisfied_version?",
|
82
85
|
rb_cairo_satisfied_version, -1);
|
data/ext/cairo/rb_cairo.h
CHANGED
@@ -71,6 +71,10 @@ RB_CAIRO_BEGIN_DECLS
|
|
71
71
|
# define RB_CAIRO_VAR extern
|
72
72
|
#endif
|
73
73
|
|
74
|
+
#define RB_CAIRO_VERSION_MAJOR 1
|
75
|
+
#define RB_CAIRO_VERSION_MINOR 10
|
76
|
+
#define RB_CAIRO_VERSION_MICRO 1
|
77
|
+
|
74
78
|
RB_CAIRO_VAR VALUE rb_mCairo;
|
75
79
|
RB_CAIRO_VAR VALUE rb_cCairo_Context;
|
76
80
|
RB_CAIRO_VAR VALUE rb_cCairo_Point;
|
@@ -41,7 +41,11 @@ VALUE rb_mCairo_MimeType = Qnil;
|
|
41
41
|
VALUE rb_mCairo_RegionOverlap = Qnil;
|
42
42
|
|
43
43
|
#define CAIRO_OPERATOR_MIN CAIRO_OPERATOR_CLEAR
|
44
|
-
#
|
44
|
+
#if CAIRO_CHECK_VERSION(1, 10, 0)
|
45
|
+
# define CAIRO_OPERATOR_MAX CAIRO_OPERATOR_HSL_LUMINOSITY
|
46
|
+
#else
|
47
|
+
# define CAIRO_OPERATOR_MAX CAIRO_OPERATOR_SATURATE
|
48
|
+
#endif
|
45
49
|
|
46
50
|
#define CAIRO_ANTIALIAS_MIN CAIRO_ANTIALIAS_DEFAULT
|
47
51
|
#define CAIRO_ANTIALIAS_MAX CAIRO_ANTIALIAS_SUBPIXEL
|
@@ -80,7 +84,7 @@ VALUE rb_mCairo_RegionOverlap = Qnil;
|
|
80
84
|
#define CAIRO_FORMAT_MAX CAIRO_FORMAT_RGB16_565
|
81
85
|
|
82
86
|
#define CAIRO_EXTEND_MIN CAIRO_EXTEND_NONE
|
83
|
-
#define CAIRO_EXTEND_MAX
|
87
|
+
#define CAIRO_EXTEND_MAX CAIRO_EXTEND_PAD
|
84
88
|
|
85
89
|
#define CAIRO_FILTER_MIN CAIRO_FILTER_FAST
|
86
90
|
#define CAIRO_FILTER_MAX CAIRO_FILTER_GAUSSIAN
|
@@ -1450,12 +1450,13 @@ static VALUE
|
|
1450
1450
|
cr_get_target (VALUE self)
|
1451
1451
|
{
|
1452
1452
|
cairo_surface_t *surface;
|
1453
|
-
VALUE rb_surface;
|
1453
|
+
VALUE rb_surface = Qnil;
|
1454
1454
|
|
1455
1455
|
surface = cairo_get_target (_SELF);
|
1456
1456
|
rb_cairo_check_status (cairo_surface_status (surface));
|
1457
1457
|
|
1458
|
-
|
1458
|
+
if (RTEST (rb_ivar_defined (self, cr_id_surface)))
|
1459
|
+
rb_surface = rb_ivar_get (self, cr_id_surface);
|
1459
1460
|
if (NIL_P (rb_surface) || RVAL2CRSURFACE (rb_surface) != surface)
|
1460
1461
|
{
|
1461
1462
|
rb_surface = CRSURFACE2RVAL (surface);
|
data/ext/cairo/rb_cairo_device.c
CHANGED
@@ -22,6 +22,10 @@
|
|
22
22
|
# include <cairo-xml.h>
|
23
23
|
#endif
|
24
24
|
|
25
|
+
#if defined(CAIRO_HAS_SCRIPT_SURFACE) || defined(CAIRO_HAS_XML_SURFACE)
|
26
|
+
# define NEED_DEFINE_OUTPUT_INITIALIZE 1
|
27
|
+
#endif
|
28
|
+
|
25
29
|
VALUE rb_cCairo_Device = Qnil;
|
26
30
|
VALUE rb_cCairo_DRMDevice = Qnil;
|
27
31
|
VALUE rb_cCairo_GLDevice = Qnil;
|
@@ -97,6 +101,7 @@ rb_cairo_device_from_ruby_object (VALUE obj)
|
|
97
101
|
return device;
|
98
102
|
}
|
99
103
|
|
104
|
+
#ifdef NEED_DEFINE_OUTPUT_INITIALIZE
|
100
105
|
static rb_cairo__object_holder_t *
|
101
106
|
cr_object_holder_new (VALUE object)
|
102
107
|
{
|
@@ -108,6 +113,7 @@ cr_object_holder_free (void *ptr)
|
|
108
113
|
{
|
109
114
|
rb_cairo__object_holder_free (rb_cCairo_Device, ptr);
|
110
115
|
}
|
116
|
+
#endif
|
111
117
|
|
112
118
|
static void
|
113
119
|
cr_device_free (void *ptr)
|
@@ -227,6 +233,7 @@ cr_finish_all_guarded_devices_at_end (VALUE data)
|
|
227
233
|
Qnil);
|
228
234
|
}
|
229
235
|
|
236
|
+
#ifdef NEED_DEFINE_OUTPUT_INITIALIZE
|
230
237
|
static void
|
231
238
|
yield_and_finish (VALUE self)
|
232
239
|
{
|
@@ -238,6 +245,7 @@ yield_and_finish (VALUE self)
|
|
238
245
|
if (!cairo_device_get_user_data (device, &cr_finished_key))
|
239
246
|
cr_device_finish (self);
|
240
247
|
}
|
248
|
+
#endif
|
241
249
|
|
242
250
|
#define DEFINE_OUTPUT_INITIALIZE(type) \
|
243
251
|
static VALUE \
|
@@ -211,7 +211,7 @@ cr_user_font_face_invoke_rescue (VALUE user_data, VALUE exception)
|
|
211
211
|
data = (cr_user_font_face_invoke_data_t *)user_data;
|
212
212
|
*(data->status) = rb_cairo__exception_to_status (exception);
|
213
213
|
|
214
|
-
if (*(data->status) == -1)
|
214
|
+
if (*(data->status) == (cairo_status_t)-1)
|
215
215
|
rb_exc_raise (exception);
|
216
216
|
|
217
217
|
return Qnil;
|
@@ -62,6 +62,8 @@ VALUE rb_cCairo_Surface;
|
|
62
62
|
VALUE rb_cCairo_ImageSurface;
|
63
63
|
VALUE rb_cCairo_PDFSurface = Qnil;
|
64
64
|
VALUE rb_cCairo_PSSurface = Qnil;
|
65
|
+
VALUE rb_cCairo_XLibSurface = Qnil;
|
66
|
+
VALUE rb_cCairo_XCBSurface = Qnil;
|
65
67
|
VALUE rb_cCairo_SVGSurface = Qnil;
|
66
68
|
VALUE rb_cCairo_Win32Surface = Qnil;
|
67
69
|
VALUE rb_cCairo_Win32PrintingSurface = Qnil;
|
@@ -129,6 +131,12 @@ cr_surface_get_klass (cairo_surface_t *surface)
|
|
129
131
|
case CAIRO_SURFACE_TYPE_PS:
|
130
132
|
klass = rb_cCairo_PSSurface;
|
131
133
|
break;
|
134
|
+
case CAIRO_SURFACE_TYPE_XLIB:
|
135
|
+
klass = rb_cCairo_XLibSurface;
|
136
|
+
break;
|
137
|
+
case CAIRO_SURFACE_TYPE_XCB:
|
138
|
+
klass = rb_cCairo_XCBSurface;
|
139
|
+
break;
|
132
140
|
case CAIRO_SURFACE_TYPE_QUARTZ:
|
133
141
|
klass = rb_cCairo_QuartzSurface;
|
134
142
|
break;
|
@@ -978,6 +986,24 @@ cr_pdf_surface_restrict_to_version (VALUE self, VALUE version)
|
|
978
986
|
# endif
|
979
987
|
#endif
|
980
988
|
|
989
|
+
#ifdef CAIRO_HAS_XLIB_SURFACE
|
990
|
+
static VALUE
|
991
|
+
cr_xlib_surface_initialize (int argc, VALUE *argv, VALUE self)
|
992
|
+
{
|
993
|
+
rb_notimplement();
|
994
|
+
return Qnil;
|
995
|
+
}
|
996
|
+
#endif
|
997
|
+
|
998
|
+
#ifdef CAIRO_HAS_XCB_SURFACE
|
999
|
+
static VALUE
|
1000
|
+
cr_xcb_surface_initialize (int argc, VALUE *argv, VALUE self)
|
1001
|
+
{
|
1002
|
+
rb_notimplement();
|
1003
|
+
return Qnil;
|
1004
|
+
}
|
1005
|
+
#endif
|
1006
|
+
|
981
1007
|
#ifdef CAIRO_HAS_SVG_SURFACE
|
982
1008
|
/* SVG-surface functions */
|
983
1009
|
DEFINE_SURFACE(svg)
|
@@ -1720,6 +1746,20 @@ Init_cairo_surface (void)
|
|
1720
1746
|
RB_CAIRO_DEF_SETTERS (rb_cCairo_PDFSurface);
|
1721
1747
|
#endif
|
1722
1748
|
|
1749
|
+
#ifdef CAIRO_HAS_XLIB_SURFACE
|
1750
|
+
/* XLib-surface */
|
1751
|
+
INIT_SURFACE(xlib, XLib)
|
1752
|
+
|
1753
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_XLibSurface);
|
1754
|
+
#endif
|
1755
|
+
|
1756
|
+
#ifdef CAIRO_HAS_XCB_SURFACE
|
1757
|
+
/* XLib-surface */
|
1758
|
+
INIT_SURFACE(xcb, XCB)
|
1759
|
+
|
1760
|
+
RB_CAIRO_DEF_SETTERS (rb_cCairo_XCBSurface);
|
1761
|
+
#endif
|
1762
|
+
|
1723
1763
|
#ifdef CAIRO_HAS_SVG_SURFACE
|
1724
1764
|
/* SVG-surface */
|
1725
1765
|
INIT_SURFACE(svg, SVG)
|
data/lib/cairo.rb
CHANGED
@@ -12,7 +12,7 @@ if /mingw|mswin|mswin32/ =~ RUBY_PLATFORM
|
|
12
12
|
else
|
13
13
|
require 'rbconfig'
|
14
14
|
ENV['PATH'] = %w(bin lib).collect do |dir|
|
15
|
-
"#{
|
15
|
+
"#{RbConfig::CONFIG["prefix"]}\\lib\\GTK\\#{dir};"
|
16
16
|
end.join('') + ENV['PATH']
|
17
17
|
end
|
18
18
|
end
|
@@ -40,7 +40,7 @@ require 'cairo/color'
|
|
40
40
|
require 'cairo/paper'
|
41
41
|
|
42
42
|
begin
|
43
|
-
major, minor,
|
43
|
+
major, minor, _ = RUBY_VERSION.split(/\./)
|
44
44
|
require "#{major}.#{minor}/cairo.so"
|
45
45
|
rescue LoadError
|
46
46
|
require 'cairo.so'
|
@@ -128,7 +128,7 @@ module Cairo
|
|
128
128
|
def rotate(radians); dup.rotate!(radians); end
|
129
129
|
def invert; dup.invert!; end
|
130
130
|
def multiply(other); dup.multiply!(other); end
|
131
|
-
|
131
|
+
alias_method :*, :multiply
|
132
132
|
end
|
133
133
|
|
134
134
|
class FontOptions
|
data/lib/cairo/color.rb
CHANGED
@@ -11,7 +11,7 @@ module Cairo
|
|
11
11
|
when :hsv, :hsva
|
12
12
|
HSV.new(*value[1..-1])
|
13
13
|
else
|
14
|
-
|
14
|
+
_, *value = value if [:rgb, :rgba].include?(value.first)
|
15
15
|
RGB.new(*value)
|
16
16
|
end
|
17
17
|
when /\A#/ #
|
@@ -35,11 +35,11 @@ module Cairo
|
|
35
35
|
def parse_hex_color(value)
|
36
36
|
case value
|
37
37
|
when /\A#((?:#{HEX_RE}){3,4})\z/ #
|
38
|
-
RGB.new(*$1.scan(/./).collect {|
|
38
|
+
RGB.new(*$1.scan(/./).collect {|part| part.hex / 15.0})
|
39
39
|
when /\A#((?:#{HEX_RE}{2,2}){3,4})\z/ #
|
40
|
-
RGB.new(*$1.scan(/.{2,2}/).collect {|
|
40
|
+
RGB.new(*$1.scan(/.{2,2}/).collect {|part| part.hex / 255.0})
|
41
41
|
when /\A#((?:#{HEX_RE}{4,4}){3,4})\z/ #
|
42
|
-
RGB.new(*$1.scan(/.{4,4}/).collect {|
|
42
|
+
RGB.new(*$1.scan(/.{4,4}/).collect {|part| part.hex / 65535.0})
|
43
43
|
else
|
44
44
|
message = "invalid hex color format: #{value} should be "
|
45
45
|
message << "#RGB, #RGBA, #RRGGBB, #RRGGBBAA, #RRRRGGGGBBBB "
|
data/lib/cairo/context/path.rb
CHANGED
data/test/run-test.rb
CHANGED
@@ -5,7 +5,7 @@ ext_dir = File.join(base_dir, "ext", "cairo")
|
|
5
5
|
lib_dir = File.join(base_dir, "lib")
|
6
6
|
test_dir = File.join(base_dir, "test")
|
7
7
|
|
8
|
-
if system("which make
|
8
|
+
if system("which make >/dev/null 2>&1")
|
9
9
|
Dir.chdir(base_dir) do
|
10
10
|
system("make > /dev/null") or exit(1)
|
11
11
|
end
|
data/test/test_context.rb
CHANGED
@@ -74,7 +74,7 @@ class ContextTest < Test::Unit::TestCase
|
|
74
74
|
face = context.font_face
|
75
75
|
default_font_family = ""
|
76
76
|
# default_font_family = "Helvetica" if quartz?
|
77
|
-
|
77
|
+
default_font_family = "Arial" if win32?
|
78
78
|
assert_equal([default_font_family,
|
79
79
|
Cairo::FONT_SLANT_NORMAL,
|
80
80
|
Cairo::FONT_WEIGHT_NORMAL],
|
data/test/test_font_face.rb
CHANGED
@@ -9,7 +9,7 @@ class FontFaceTest < Test::Unit::TestCase
|
|
9
9
|
face = Cairo::ToyFontFace.new
|
10
10
|
default_font_family = ""
|
11
11
|
# default_font_family = "Helvetica" if quartz?
|
12
|
-
|
12
|
+
default_font_family = "Arial" if win32?
|
13
13
|
assert_equal([default_font_family,
|
14
14
|
Cairo::FONT_SLANT_NORMAL,
|
15
15
|
Cairo::FONT_WEIGHT_NORMAL],
|
@@ -13,6 +13,9 @@ class RecordingSurfaceTest < Test::Unit::TestCase
|
|
13
13
|
context.line_to(80, 100)
|
14
14
|
context.stroke
|
15
15
|
end
|
16
|
-
|
16
|
+
# https://bugs.freedesktop.org/show_bug.cgi?id=24688
|
17
|
+
# causes expected value change. It is introduced between
|
18
|
+
# cairo 1.10.0 and 1.10.2.
|
19
|
+
assert_equal([14.0, 29.0, 67.0, 72.0], surface.ink_extents)
|
17
20
|
end
|
18
21
|
end
|
data/test/test_xml_surface.rb
CHANGED
@@ -24,7 +24,8 @@ class XMLSurfaceTest < Test::Unit::TestCase
|
|
24
24
|
<source-pattern>
|
25
25
|
<solid>0 0 0 1</solid>
|
26
26
|
</source-pattern>
|
27
|
-
<path> 15 30 m 80 100 l
|
27
|
+
<path> 15 30 m 80 100 l</path>
|
28
|
+
<tolerance>0.1</tolerance>
|
28
29
|
<antialias>ANTIALIAS_DEFAULT</antialias>
|
29
30
|
</stroke>
|
30
31
|
EOX
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cairo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 61
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 10
|
9
|
-
-
|
10
|
-
version: 1.10.
|
9
|
+
- 1
|
10
|
+
version: 1.10.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Evan Marin
|
@@ -18,13 +18,66 @@ autorequire:
|
|
18
18
|
bindir: bin
|
19
19
|
cert_chain: []
|
20
20
|
|
21
|
-
date:
|
22
|
-
default_executable:
|
21
|
+
date: 2011-10-12 00:00:00 Z
|
23
22
|
dependencies:
|
24
23
|
- !ruby/object:Gem::Dependency
|
24
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
25
33
|
name: pkg-config
|
26
34
|
prerelease: false
|
27
|
-
|
35
|
+
type: :development
|
36
|
+
requirement: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
name: test-unit
|
48
|
+
prerelease: false
|
49
|
+
type: :development
|
50
|
+
requirement: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
name: test-unit-notify
|
62
|
+
prerelease: false
|
63
|
+
type: :development
|
64
|
+
requirement: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
name: rake
|
76
|
+
prerelease: false
|
77
|
+
type: :development
|
78
|
+
requirement: *id004
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
28
81
|
none: false
|
29
82
|
requirements:
|
30
83
|
- - ">="
|
@@ -33,24 +86,52 @@ dependencies:
|
|
33
86
|
segments:
|
34
87
|
- 0
|
35
88
|
version: "0"
|
36
|
-
|
37
|
-
|
89
|
+
name: rake-compiler
|
90
|
+
prerelease: false
|
91
|
+
type: :development
|
92
|
+
requirement: *id005
|
38
93
|
- !ruby/object:Gem::Dependency
|
39
|
-
|
94
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
hash: 3
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
version: "0"
|
103
|
+
name: jeweler
|
40
104
|
prerelease: false
|
41
|
-
|
105
|
+
type: :development
|
106
|
+
requirement: *id006
|
107
|
+
- !ruby/object:Gem::Dependency
|
108
|
+
version_requirements: &id007 !ruby/object:Gem::Requirement
|
42
109
|
none: false
|
43
110
|
requirements:
|
44
111
|
- - ">="
|
45
112
|
- !ruby/object:Gem::Version
|
46
|
-
hash:
|
113
|
+
hash: 3
|
47
114
|
segments:
|
48
|
-
- 2
|
49
115
|
- 0
|
50
|
-
|
51
|
-
|
116
|
+
version: "0"
|
117
|
+
name: yard
|
118
|
+
prerelease: false
|
52
119
|
type: :development
|
53
|
-
|
120
|
+
requirement: *id007
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
version_requirements: &id008 !ruby/object:Gem::Requirement
|
123
|
+
none: false
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
hash: 3
|
128
|
+
segments:
|
129
|
+
- 0
|
130
|
+
version: "0"
|
131
|
+
name: packnga
|
132
|
+
prerelease: false
|
133
|
+
type: :development
|
134
|
+
requirement: *id008
|
54
135
|
description: Ruby bindings for cairo
|
55
136
|
email:
|
56
137
|
- cairo@cairographics.org
|
@@ -58,15 +139,18 @@ executables: []
|
|
58
139
|
|
59
140
|
extensions:
|
60
141
|
- ext/cairo/extconf.rb
|
61
|
-
extra_rdoc_files:
|
62
|
-
|
142
|
+
extra_rdoc_files:
|
143
|
+
- README.rdoc
|
63
144
|
files:
|
64
145
|
- AUTHORS
|
65
146
|
- COPYING
|
66
147
|
- GPL
|
148
|
+
- Gemfile
|
67
149
|
- NEWS
|
150
|
+
- README.rdoc
|
68
151
|
- Rakefile
|
69
152
|
- ext/cairo/cairo.def
|
153
|
+
- ext/cairo/depend
|
70
154
|
- ext/cairo/extconf.rb
|
71
155
|
- ext/cairo/rb_cairo.c
|
72
156
|
- ext/cairo/rb_cairo.h
|
@@ -90,7 +174,6 @@ files:
|
|
90
174
|
- ext/cairo/rb_cairo_surface.c
|
91
175
|
- ext/cairo/rb_cairo_text_cluster.c
|
92
176
|
- ext/cairo/rb_cairo_text_extents.c
|
93
|
-
- extconf.rb
|
94
177
|
- lib/cairo.rb
|
95
178
|
- lib/cairo/color.rb
|
96
179
|
- lib/cairo/colors.rb
|
@@ -106,8 +189,6 @@ files:
|
|
106
189
|
- lib/cairo/papers.rb
|
107
190
|
- lib/cairo/path.rb
|
108
191
|
- lib/cairo/point.rb
|
109
|
-
- misc/update-colors.rb
|
110
|
-
- samples/agg/README
|
111
192
|
- samples/agg/aa_test.rb
|
112
193
|
- samples/blur.rb
|
113
194
|
- samples/pac-nomralize.rb
|
@@ -117,36 +198,34 @@ files:
|
|
117
198
|
- samples/scalable.rb
|
118
199
|
- samples/text-on-path.rb
|
119
200
|
- samples/text2.rb
|
120
|
-
- test/cairo-test-utils.rb
|
121
|
-
- test/run-test.rb
|
122
|
-
- test/test_color.rb
|
123
|
-
- test/test_constants.rb
|
124
|
-
- test/test_context.rb
|
125
|
-
- test/test_exception.rb
|
126
|
-
- test/test_font_extents.rb
|
127
|
-
- test/test_font_face.rb
|
128
|
-
- test/test_font_options.rb
|
129
|
-
- test/test_paper.rb
|
130
|
-
- test/test_recording_surface.rb
|
131
|
-
- test/test_region.rb
|
132
|
-
- test/test_scaled_font.rb
|
133
|
-
- test/test_script_device.rb
|
134
|
-
- test/test_script_surface.rb
|
135
201
|
- test/test_surface.rb
|
202
|
+
- test/test_scaled_font.rb
|
203
|
+
- test/test_recording_surface.rb
|
204
|
+
- test/test_text_to_glyphs_data.rb
|
205
|
+
- test/test_font_extents.rb
|
136
206
|
- test/test_tee_surface.rb
|
137
|
-
- test/test_text_cluster.rb
|
138
207
|
- test/test_text_extents.rb
|
139
|
-
- test/
|
208
|
+
- test/test_paper.rb
|
209
|
+
- test/test_context.rb
|
210
|
+
- test/cairo-test-utils.rb
|
140
211
|
- test/test_xml_device.rb
|
212
|
+
- test/run-test.rb
|
213
|
+
- test/test_script_surface.rb
|
214
|
+
- test/test_region.rb
|
215
|
+
- test/test_font_face.rb
|
216
|
+
- test/test_script_device.rb
|
141
217
|
- test/test_xml_surface.rb
|
142
|
-
|
218
|
+
- test/test_exception.rb
|
219
|
+
- test/test_text_cluster.rb
|
220
|
+
- test/test_color.rb
|
221
|
+
- test/test_font_options.rb
|
222
|
+
- test/test_constants.rb
|
143
223
|
homepage: http://cairographics.org/rcairo
|
144
|
-
licenses:
|
145
|
-
|
224
|
+
licenses:
|
225
|
+
- Ruby's
|
146
226
|
post_install_message:
|
147
|
-
rdoc_options:
|
148
|
-
|
149
|
-
- README.txt
|
227
|
+
rdoc_options: []
|
228
|
+
|
150
229
|
require_paths:
|
151
230
|
- lib
|
152
231
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -170,9 +249,30 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
249
|
requirements: []
|
171
250
|
|
172
251
|
rubyforge_project: cairo
|
173
|
-
rubygems_version: 1.
|
252
|
+
rubygems_version: 1.8.10
|
174
253
|
signing_key:
|
175
254
|
specification_version: 3
|
176
255
|
summary: Ruby bindings for cairo
|
177
|
-
test_files:
|
178
|
-
|
256
|
+
test_files:
|
257
|
+
- test/test_surface.rb
|
258
|
+
- test/test_scaled_font.rb
|
259
|
+
- test/test_recording_surface.rb
|
260
|
+
- test/test_text_to_glyphs_data.rb
|
261
|
+
- test/test_font_extents.rb
|
262
|
+
- test/test_tee_surface.rb
|
263
|
+
- test/test_text_extents.rb
|
264
|
+
- test/test_paper.rb
|
265
|
+
- test/test_context.rb
|
266
|
+
- test/cairo-test-utils.rb
|
267
|
+
- test/test_xml_device.rb
|
268
|
+
- test/run-test.rb
|
269
|
+
- test/test_script_surface.rb
|
270
|
+
- test/test_region.rb
|
271
|
+
- test/test_font_face.rb
|
272
|
+
- test/test_script_device.rb
|
273
|
+
- test/test_xml_surface.rb
|
274
|
+
- test/test_exception.rb
|
275
|
+
- test/test_text_cluster.rb
|
276
|
+
- test/test_color.rb
|
277
|
+
- test/test_font_options.rb
|
278
|
+
- test/test_constants.rb
|
data/extconf.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'pathname'
|
4
|
-
require 'mkmf'
|
5
|
-
require 'rbconfig'
|
6
|
-
require 'fileutils'
|
7
|
-
|
8
|
-
base_dir = Pathname(__FILE__).dirname.expand_path
|
9
|
-
ext_dir = base_dir + "ext" + "cairo"
|
10
|
-
|
11
|
-
ruby = File.join(RbConfig::CONFIG['bindir'],
|
12
|
-
RbConfig::CONFIG['ruby_install_name'] +
|
13
|
-
RbConfig::CONFIG["EXEEXT"])
|
14
|
-
|
15
|
-
Dir.chdir(ext_dir.to_s) do
|
16
|
-
system(ruby, "extconf.rb", *ARGV) || exit(false)
|
17
|
-
end
|
18
|
-
|
19
|
-
create_makefile("cairo")
|
20
|
-
FileUtils.mv("Makefile", "Makefile.lib")
|
21
|
-
|
22
|
-
File.open("Makefile", "w") do |makefile|
|
23
|
-
makefile.puts(<<-EOM)
|
24
|
-
all:
|
25
|
-
(cd ext/cairo && $(MAKE))
|
26
|
-
$(MAKE) -f Makefile.lib
|
27
|
-
|
28
|
-
install:
|
29
|
-
(cd ext/cairo && $(MAKE) install)
|
30
|
-
$(MAKE) -f Makefile.lib install
|
31
|
-
|
32
|
-
site-install:
|
33
|
-
(cd ext/cairo && $(MAKE) site-install)
|
34
|
-
$(MAKE) -f Makefile.lib site-install
|
35
|
-
|
36
|
-
clean:
|
37
|
-
(cd ext/cairo && $(MAKE) clean)
|
38
|
-
$(MAKE) -f Makefile.lib clean
|
39
|
-
|
40
|
-
distclean:
|
41
|
-
(cd ext/cairo && $(MAKE) distclean)
|
42
|
-
$(MAKE) -f Makefile.lib distclean
|
43
|
-
@rm -f Makefile.lib
|
44
|
-
EOM
|
45
|
-
end
|
data/misc/update-colors.rb
DELETED
@@ -1,143 +0,0 @@
|
|
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
|
data/samples/agg/README
DELETED