ruby-gd 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Changes +54 -0
- data/GD.c +2602 -0
- data/doc/INSTALL.en +83 -0
- data/doc/INSTALL.ja +91 -0
- data/doc/manual.html +891 -0
- data/doc/manual.rd +969 -0
- data/doc/manual_index.html +146 -0
- data/extconf.rb +79 -0
- data/readme.en +55 -0
- data/readme.ja +74 -0
- data/sample/example.rb +28 -0
- data/sample/gdtestttf.png +0 -0
- data/sample/gdtestttf.rb +62 -0
- data/sample/webpng.rb +111 -0
- metadata +59 -0
@@ -0,0 +1,146 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
2
|
+
<HTML>
|
3
|
+
<HEAD>
|
4
|
+
<TITLE>Method Index --- manual.rmi </TITLE>
|
5
|
+
</HEAD>
|
6
|
+
<BODY>
|
7
|
+
<H1>Method Index -- manual.rmi</H1>
|
8
|
+
<HR>
|
9
|
+
<DL>
|
10
|
+
</UL></DD>
|
11
|
+
<DT>GD
|
12
|
+
<DD><UL>
|
13
|
+
<LI><A HREF="manual.html#label:13">GD::AlphaOpaque</A>
|
14
|
+
<LI><A HREF="manual.html#label:12">GD::AlphaTransparent</A>
|
15
|
+
<LI><A HREF="manual.html#label:14">GD::Arc</A>
|
16
|
+
<LI><A HREF="manual.html#label:4">GD::Brushed</A>
|
17
|
+
<LI><A HREF="manual.html#label:15">GD::Chord</A>
|
18
|
+
<LI><A HREF="manual.html#label:18">GD::Edged</A>
|
19
|
+
<LI><A HREF="manual.html#label:9">GD::GD2_FMT_COMPRESSED</A>
|
20
|
+
<LI><A HREF="manual.html#label:10">GD::GD2_FMT_RAW</A>
|
21
|
+
<LI><A HREF="manual.html#label:17">GD::NoFill</A>
|
22
|
+
<LI><A HREF="manual.html#label:16">GD::Pie</A>
|
23
|
+
<LI><A HREF="manual.html#label:5">GD::Styled</A>
|
24
|
+
<LI><A HREF="manual.html#label:6">GD::StyledBrushed</A>
|
25
|
+
<LI><A HREF="manual.html#label:7">GD::Tiled</A>
|
26
|
+
<LI><A HREF="manual.html#label:8">GD::Transparent</A>
|
27
|
+
</UL></DD>
|
28
|
+
<DT>GD::Font
|
29
|
+
<DD><UL>
|
30
|
+
<LI><A HREF="manual.html#label:157">GD::Font::GiantFont</A>
|
31
|
+
<LI><A HREF="manual.html#label:158">GD::Font::LargeFont</A>
|
32
|
+
<LI><A HREF="manual.html#label:159">GD::Font::MediumFont</A>
|
33
|
+
<LI><A HREF="manual.html#label:160">GD::Font::SmallFont</A>
|
34
|
+
<LI><A HREF="manual.html#label:161">GD::Font::TinyFont</A>
|
35
|
+
<LI><A HREF="manual.html#label:150">GD::Font.new</A>
|
36
|
+
<LI><A HREF="manual.html#label:152">GD::Font#height</A>
|
37
|
+
<LI><A HREF="manual.html#label:153">GD::Font#nchars</A>
|
38
|
+
<LI><A HREF="manual.html#label:154">GD::Font#offset</A>
|
39
|
+
<LI><A HREF="manual.html#label:155">GD::Font#width</A>
|
40
|
+
</UL></DD>
|
41
|
+
<DT>GD::Image
|
42
|
+
<DD><UL>
|
43
|
+
<LI><A HREF="manual.html#label:22">GD::Image.new</A>
|
44
|
+
<LI><A HREF="manual.html#label:23">GD::Image.newFromGd</A>
|
45
|
+
<LI><A HREF="manual.html#label:25">GD::Image.newFromGd2</A>
|
46
|
+
<LI><A HREF="manual.html#label:27">GD::Image.newFromGd2Part</A>
|
47
|
+
<LI><A HREF="manual.html#label:29">GD::Image.newFromJpeg</A>
|
48
|
+
<LI><A HREF="manual.html#label:31">GD::Image.newFromPng</A>
|
49
|
+
<LI><A HREF="manual.html#label:33">GD::Image.newFromXbm</A>
|
50
|
+
<LI><A HREF="manual.html#label:35">GD::Image.newFromXpm</A>
|
51
|
+
<LI><A HREF="manual.html#label:41">GD::Image.newTrueColor</A>
|
52
|
+
<LI><A HREF="manual.html#label:24">GD::Image.new_from_gd</A>
|
53
|
+
<LI><A HREF="manual.html#label:26">GD::Image.new_from_gd2</A>
|
54
|
+
<LI><A HREF="manual.html#label:28">GD::Image.new_from_gd2_part</A>
|
55
|
+
<LI><A HREF="manual.html#label:30">GD::Image.new_from_jpeg</A>
|
56
|
+
<LI><A HREF="manual.html#label:32">GD::Image.new_from_png</A>
|
57
|
+
<LI><A HREF="manual.html#label:34">GD::Image.new_from_xbm</A>
|
58
|
+
<LI><A HREF="manual.html#label:36">GD::Image.new_from_xpm</A>
|
59
|
+
<LI><A HREF="manual.html#label:39">GD::Image.stringFT</A>
|
60
|
+
<LI><A HREF="manual.html#label:38">GD::Image.stringTTF</A>
|
61
|
+
<LI><A HREF="manual.html#label:42">GD::Image.trueColor</A>
|
62
|
+
<LI><A HREF="manual.html#label:45">GD::Image.trueColorAlpha</A>
|
63
|
+
<LI><A HREF="manual.html#label:119">GD::Image#alpha</A>
|
64
|
+
<LI><A HREF="manual.html#label:118">GD::Image#alphaBlending=</A>
|
65
|
+
<LI><A HREF="manual.html#label:61">GD::Image#arc</A>
|
66
|
+
<LI><A HREF="manual.html#label:90">GD::Image#blue</A>
|
67
|
+
<LI><A HREF="manual.html#label:88">GD::Image#bounds</A>
|
68
|
+
<LI><A HREF="manual.html#label:89">GD::Image#boundsSafe</A>
|
69
|
+
<LI><A HREF="manual.html#label:81">GD::Image#char</A>
|
70
|
+
<LI><A HREF="manual.html#label:82">GD::Image#charUp</A>
|
71
|
+
<LI><A HREF="manual.html#label:50">GD::Image#colorAllocate</A>
|
72
|
+
<LI><A HREF="manual.html#label:110">GD::Image#colorAllocateAlpha</A>
|
73
|
+
<LI><A HREF="manual.html#label:52">GD::Image#colorClosest</A>
|
74
|
+
<LI><A HREF="manual.html#label:114">GD::Image#colorClosestAlpha</A>
|
75
|
+
<LI><A HREF="manual.html#label:54">GD::Image#colorDeallocate</A>
|
76
|
+
<LI><A HREF="manual.html#label:55">GD::Image#colorExact</A>
|
77
|
+
<LI><A HREF="manual.html#label:112">GD::Image#colorExactAlpha</A>
|
78
|
+
<LI><A HREF="manual.html#label:57">GD::Image#colorResolve</A>
|
79
|
+
<LI><A HREF="manual.html#label:116">GD::Image#colorResolveAlpha</A>
|
80
|
+
<LI><A HREF="manual.html#label:91">GD::Image#colorsTotal</A>
|
81
|
+
<LI><A HREF="manual.html#label:75">GD::Image#copy</A>
|
82
|
+
<LI><A HREF="manual.html#label:76">GD::Image#copyMerge</A>
|
83
|
+
<LI><A HREF="manual.html#label:77">GD::Image#copyMergeGray</A>
|
84
|
+
<LI><A HREF="manual.html#label:121">GD::Image#copyResampled</A>
|
85
|
+
<LI><A HREF="manual.html#label:78">GD::Image#copyResized</A>
|
86
|
+
<LI><A HREF="manual.html#label:62">GD::Image#dashedLine</A>
|
87
|
+
<LI><A HREF="manual.html#label:47">GD::Image#destroy</A>
|
88
|
+
<LI><A HREF="manual.html#label:63">GD::Image#fill</A>
|
89
|
+
<LI><A HREF="manual.html#label:66">GD::Image#fillToBorder</A>
|
90
|
+
<LI><A HREF="manual.html#label:123">GD::Image#filledArc</A>
|
91
|
+
<LI><A HREF="manual.html#label:122">GD::Image#filledEllipse</A>
|
92
|
+
<LI><A HREF="manual.html#label:64">GD::Image#filledPolygon</A>
|
93
|
+
<LI><A HREF="manual.html#label:65">GD::Image#filledRectangle</A>
|
94
|
+
<LI><A HREF="manual.html#label:101">GD::Image#gd</A>
|
95
|
+
<LI><A HREF="manual.html#label:102">GD::Image#gd2</A>
|
96
|
+
<LI><A HREF="manual.html#label:93">GD::Image#getPixel</A>
|
97
|
+
<LI><A HREF="manual.html#label:92">GD::Image#getTransparent</A>
|
98
|
+
<LI><A HREF="manual.html#label:94">GD::Image#green</A>
|
99
|
+
<LI><A HREF="manual.html#label:95">GD::Image#height</A>
|
100
|
+
<LI><A HREF="manual.html#label:96">GD::Image#interlace</A>
|
101
|
+
<LI><A HREF="manual.html#label:48">GD::Image#interlace=</A>
|
102
|
+
<LI><A HREF="manual.html#label:127">GD::Image#is_palette?</A>
|
103
|
+
<LI><A HREF="manual.html#label:126">GD::Image#is_trueColor?</A>
|
104
|
+
<LI><A HREF="manual.html#label:103">GD::Image#jpeg</A>
|
105
|
+
<LI><A HREF="manual.html#label:104">GD::Image#jpegStr</A>
|
106
|
+
<LI><A HREF="manual.html#label:67">GD::Image#line</A>
|
107
|
+
<LI><A HREF="manual.html#label:79">GD::Image#paletteCopy</A>
|
108
|
+
<LI><A HREF="manual.html#label:105">GD::Image#png</A>
|
109
|
+
<LI><A HREF="manual.html#label:106">GD::Image#pngStr</A>
|
110
|
+
<LI><A HREF="manual.html#label:68">GD::Image#polygon</A>
|
111
|
+
<LI><A HREF="manual.html#label:69">GD::Image#rectangle</A>
|
112
|
+
<LI><A HREF="manual.html#label:97">GD::Image#red</A>
|
113
|
+
<LI><A HREF="manual.html#label:98">GD::Image#rgb</A>
|
114
|
+
<LI><A HREF="manual.html#label:70">GD::Image#setBrush</A>
|
115
|
+
<LI><A HREF="manual.html#label:71">GD::Image#setPixel</A>
|
116
|
+
<LI><A HREF="manual.html#label:72">GD::Image#setStyle</A>
|
117
|
+
<LI><A HREF="manual.html#label:73">GD::Image#setTile</A>
|
118
|
+
<LI><A HREF="manual.html#label:83">GD::Image#string</A>
|
119
|
+
<LI><A HREF="manual.html#label:86">GD::Image#stringFT</A>
|
120
|
+
<LI><A HREF="manual.html#label:85">GD::Image#stringTTF</A>
|
121
|
+
<LI><A HREF="manual.html#label:84">GD::Image#stringUp</A>
|
122
|
+
<LI><A HREF="manual.html#label:128">GD::Image#thickness=</A>
|
123
|
+
<LI><A HREF="manual.html#label:124">GD::Image#to_paletteImage</A>
|
124
|
+
<LI><A HREF="manual.html#label:59">GD::Image#transparent</A>
|
125
|
+
<LI><A HREF="manual.html#label:107">GD::Image#wbmp</A>
|
126
|
+
<LI><A HREF="manual.html#label:99">GD::Image#width</A>
|
127
|
+
</UL></DD>
|
128
|
+
<DT>GD::Polygon
|
129
|
+
<DD><UL>
|
130
|
+
<LI><A HREF="manual.html#label:131">GD::Polygon.new</A>
|
131
|
+
<LI><A HREF="manual.html#label:134">GD::Polygon#addPt</A>
|
132
|
+
<LI><A HREF="manual.html#label:145">GD::Polygon#bounds</A>
|
133
|
+
<LI><A HREF="manual.html#label:135">GD::Polygon#deletePt</A>
|
134
|
+
<LI><A HREF="manual.html#label:136">GD::Polygon#getPt</A>
|
135
|
+
<LI><A HREF="manual.html#label:146">GD::Polygon#length</A>
|
136
|
+
<LI><A HREF="manual.html#label:137">GD::Polygon#map</A>
|
137
|
+
<LI><A HREF="manual.html#label:139">GD::Polygon#offset</A>
|
138
|
+
<LI><A HREF="manual.html#label:142">GD::Polygon#scale</A>
|
139
|
+
<LI><A HREF="manual.html#label:140">GD::Polygon#setPt</A>
|
140
|
+
<LI><A HREF="manual.html#label:141">GD::Polygon#toPt</A>
|
141
|
+
<LI><A HREF="manual.html#label:143">GD::Polygon#transform</A>
|
142
|
+
<LI><A HREF="manual.html#label:147">GD::Polygon#vertices</A>
|
143
|
+
</DD>
|
144
|
+
</DL>
|
145
|
+
</BODY>
|
146
|
+
</HTML>
|
data/extconf.rb
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
=begin
|
2
|
+
|
3
|
+
usage: ruby extconf.rb [options ...]
|
4
|
+
configure options:
|
5
|
+
--with-xpm : enables Xpm support
|
6
|
+
--with-ttf : enables TrueType font support
|
7
|
+
--with-jpeg : enables Jpeg support
|
8
|
+
--with-freetype : enables FreeType 2.x support
|
9
|
+
|
10
|
+
--with-gd-dir=dir
|
11
|
+
--with-gd-include=dir
|
12
|
+
--with-gd-lib=dir
|
13
|
+
|
14
|
+
--enable-gd2_0 : enable new features provided by gd-2.0.x(beta).
|
15
|
+
=end
|
16
|
+
require 'mkmf'
|
17
|
+
|
18
|
+
def delete_link(libname)
|
19
|
+
lib_ary = $libs.split
|
20
|
+
libname = '-l'+libname
|
21
|
+
lib_ary.delete libname
|
22
|
+
$libs = lib_ary.join " "
|
23
|
+
end
|
24
|
+
|
25
|
+
dir_config("gd", "/usr/local/include", "/usr/local/lib")
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
if with_config("xpm")
|
30
|
+
dir_config("X11", "/usr/X11R6/include", "/usr/X11R6/lib")
|
31
|
+
end
|
32
|
+
|
33
|
+
if with_config('jpeg')
|
34
|
+
have_library('jpeg')
|
35
|
+
end
|
36
|
+
|
37
|
+
if with_config('ttf')
|
38
|
+
have_library('ttf')
|
39
|
+
end
|
40
|
+
|
41
|
+
if with_config('xpm')
|
42
|
+
have_library('X11')
|
43
|
+
have_library('Xpm')
|
44
|
+
end
|
45
|
+
|
46
|
+
if with_config('freetype')
|
47
|
+
have_library('freetype')
|
48
|
+
end
|
49
|
+
|
50
|
+
if have_library('z') and have_library('png') and
|
51
|
+
have_library('gd', 'gdImagePng') and have_library('m')
|
52
|
+
|
53
|
+
if with_config('ttf') and not have_func('gdImageStringTTF')
|
54
|
+
delete_link('ttf')
|
55
|
+
end
|
56
|
+
|
57
|
+
have_func('gdImageColorResolve')
|
58
|
+
|
59
|
+
if with_config('xpm') and not have_func('gdImageCreateFromXpm')
|
60
|
+
delete_link('Xpm')
|
61
|
+
delete_link('X11')
|
62
|
+
end
|
63
|
+
|
64
|
+
if with_config('jpeg') and not have_func('gdImageCreateFromJpeg')
|
65
|
+
delete_link('jpeg')
|
66
|
+
end
|
67
|
+
|
68
|
+
if with_config('freetype') and not have_func('gdImageStringFT')
|
69
|
+
delete_link('freetype')
|
70
|
+
end
|
71
|
+
|
72
|
+
if enable_config("gd2_0", false)
|
73
|
+
if have_func("gdImageAlphaBlending")
|
74
|
+
$CFLAGS += ' -DENABLE_GD_2_0'
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
create_makefile('GD')
|
79
|
+
end
|
data/readme.en
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
= Ruby/GD 0.7.4
|
2
|
+
|
3
|
+
An extension library to use Thomas Boutell's gd graphics library from
|
4
|
+
Ruby. You can create PNG or JPEG images with your Ruby script.
|
5
|
+
|
6
|
+
Ruby/GD requires gd library with PNG support(i.e. the version 1.6 or
|
7
|
+
later). See 'doc/INSTALL.en' for detail.
|
8
|
+
|
9
|
+
The latest version is available from:
|
10
|
+
http://kirara.prec.kyoto-u.ac.jp/~tam/GD/
|
11
|
+
|
12
|
+
Ruby/GD is formerly known as "GD", originally written and maintained
|
13
|
+
by Yukihiro "matz" Matsumoto (matz@ruby-lang.org). From this release
|
14
|
+
of 0.7.0, Ruby/GD is maintained by Ryuichi Tamura (tam@kais.kyoto-u.ac.jp).
|
15
|
+
|
16
|
+
== Changes from the version 0.6.2
|
17
|
+
|
18
|
+
* GIF I/O are no longer supported. You can use PNG I/O instead.
|
19
|
+
* Support for API provided by the newest version of gd (gd-1.8.4).
|
20
|
+
|
21
|
+
== Contents
|
22
|
+
|
23
|
+
readme.en this file
|
24
|
+
readme.ja Japanese version of this file
|
25
|
+
extconf.rb ruby script generating Makefile for this extension library
|
26
|
+
GD.c source file
|
27
|
+
|
28
|
+
doc/INSTALL.en how to install (in English)
|
29
|
+
doc/INSTALL.ja how to install (in Japanese)
|
30
|
+
doc/manual.rd Reference manual written with RD format
|
31
|
+
doc/manual.html manual converted into HTML
|
32
|
+
|
33
|
+
sample/example.rb sample script to show the basic usage of Ruby/GD library
|
34
|
+
sample/gdtestttf.rb translated Ruby script from gdtestttf.c
|
35
|
+
sample/gdtestttf.png ./gdtestttf.rb > gdtestttf.png
|
36
|
+
sample/webpng.rb translated Ruby script from webpng.c
|
37
|
+
|
38
|
+
== Install
|
39
|
+
|
40
|
+
see 'doc/INSTALL.en'
|
41
|
+
|
42
|
+
== Reference
|
43
|
+
|
44
|
+
see 'doc/manual.html'
|
45
|
+
|
46
|
+
== Licence
|
47
|
+
|
48
|
+
Ruby Libraru Licence
|
49
|
+
|
50
|
+
== Maintainer
|
51
|
+
|
52
|
+
Ryuichi Tamura (tam@kais.kyoto-u.ac.jp)
|
53
|
+
|
54
|
+
Bug reports, comments, suggestions to this maintainer are welcome, but
|
55
|
+
ruby-talk mailing list would be the best place for discussion :-).
|
data/readme.ja
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
= Ruby/GD 0.7.4
|
2
|
+
|
3
|
+
Thomas Boutell��ˤ��gd�饤�֥���Ruby�������Ѥ��뤿��γ�ĥ�饤�֥�
|
4
|
+
��Ǥ���PNG��JPEG�ե����ޥåȤΥ�������ڤ˺������뤳�Ȥ��Ǥ��ޤ���
|
5
|
+
|
6
|
+
Ruby/GD�Ϥ�Ȥ��"GD"��̾�Τ� �ޤĤ�� �椭�Ҥ���(matz@ruby-lang.org)
|
7
|
+
�ˤ�äƳ�ȯ����ӥ��ƥʥ��Ԥ��Ƥ��ޤ��������θ塤�ܲ�gd�ε�ǽ
|
8
|
+
���ѹ�/��ĥ��ȼ�äơ�Ruby���ꥹ�ȥ��С�����������¿���Υѥ�
|
9
|
+
��������ޤ�����
|
10
|
+
|
11
|
+
Version 0.7.0 �Ǥ�GD-0.6.2���Ȥˤ����Υѥå�������ߡ����Ĥ���̤
|
12
|
+
�б��ε�ǽ���ɲä��ޤ�����̾�Τ�GD����Ruby/GD���ѹ�����Ƥ��ޤ���
|
13
|
+
|
14
|
+
�ǿ��Ǥ� http://kirara.prec.kyoto-u.ac.jp/~tam/GD/ ������ꤹ�뤳�Ȥ�
|
15
|
+
�Ǥ��ޤ���
|
16
|
+
|
17
|
+
== ��С������(��Ρ�GD-0.6.2.tar.gz)����μ���ѹ���
|
18
|
+
|
19
|
+
* GIF���ݡ��Ȥ��Ǥ��ڤ�
|
20
|
+
|
21
|
+
gd�饤�֥���version 1.6�ʹߡ�GIF������������ϥ��ݡ��Ȥ���ߤ� ��
|
22
|
+
������PNG(Portable Network Graphics)��������б�����褦�ˤʤä�
|
23
|
+
���ޤ�������˽��äơ�Ruby/GD 0.7.0��GIF�˴ؤ��륵�ݡ��Ȥ����Ƽ��ʧ��
|
24
|
+
�ޤ�������äơ�Ruby/GD�� gd-1.4 �ʤ�GIF���ݡ��Ȥ�Ԥ�gd�饤�֥�� ��
|
25
|
+
���б����Ƥ��ޤ���
|
26
|
+
|
27
|
+
* �ǿ���gd�ε�ǽ�ˤ��б�
|
28
|
+
|
29
|
+
gd-2.0�ʹߤDz�ǽ�Ȥʤä� ��TrueColor������䥢��ե�����ͥ�ΰ�����
|
30
|
+
���б����Ƥ��ޤ���
|
31
|
+
|
32
|
+
== ����ʪ
|
33
|
+
|
34
|
+
readme.ja ���Υե����롣
|
35
|
+
readme.en ���Υե�����αѸ��ǡ�
|
36
|
+
extconf.rb ��ĥ�饤�֥����Makefile����������ץ�
|
37
|
+
GD.c ������
|
38
|
+
|
39
|
+
doc/INSTALL.ja ���ȡ�����ˡ(���ܸ�)
|
40
|
+
doc/INSTALL.en ���ȡ�����ˡ(English)
|
41
|
+
doc/manual.rd �ޥ˥奢��(English) RD�ե����ޥåȤǽ�Ƥ��ޤ���
|
42
|
+
doc/manual.html ��Υޥ˥奢���HTML���Ѵ�������Ρ�
|
43
|
+
doc/manual_index.html ��åɤκ����ե����롣
|
44
|
+
doc/manual.css �ޥ˥奢��Υ������륷���ȡ�
|
45
|
+
sample/example.rb Ruby/GD �δ���Ū�ʻȤ���������ץ륹����ץ�
|
46
|
+
sample/gdtestttf.rb gd-1.8.3 �˴ޤޤ��gdtestttf.c��Ruby�˰ܿ�������Ρ�
|
47
|
+
sample/gdtestttf.png ./gdtestttf.rb > gdtestttf.png
|
48
|
+
sample/webpng.rb gd-1.8.3 �˴ޤޤ��webpng.c ��Ruby�˰ܿ�������Ρ�
|
49
|
+
|
50
|
+
== ���ȡ�����ˡ
|
51
|
+
|
52
|
+
'doc/INSTALL.ja' ���ɤ߲�������
|
53
|
+
|
54
|
+
== �ɥ������
|
55
|
+
|
56
|
+
'doc/manual.html' �Ȥ��Ʋ�������
|
57
|
+
|
58
|
+
== ���۾��
|
59
|
+
|
60
|
+
Ruby Library License �˽����ޤ���
|
61
|
+
|
62
|
+
== ���ƥ�
|
63
|
+
|
64
|
+
��¼ ζ��(tam@kais.kyoto-u.ac.jp)
|
65
|
+
|
66
|
+
�Х��������ȡ���Ƥʤɤ�Ruby ���ꥹ�Ȥ���Ƥ��뤫���⤷����
|
67
|
+
�嵭�Υ��ƥʤޤǥ������äƤ���������
|
68
|
+
|
69
|
+
== �ռ�
|
70
|
+
|
71
|
+
* GD��ĥ�饤�֥��θ���ԤǤ��餻����ޤĤ�� �椭�Ҥ�����
|
72
|
+
|
73
|
+
* GD-0.6.2 �����ʹߥѥå���������줿��¼ŵ�̤���ǽ����ˤ�����
|
74
|
+
��GD �饤�֥��ȯŸ�Τ���ˤ����Ϥ��줿Ruby ���ꥹ�Ȥγ��͡�
|
data/sample/example.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "GD"
|
4
|
+
|
5
|
+
# create a new image
|
6
|
+
im = GD::Image.new(100,100)
|
7
|
+
|
8
|
+
# allocate some colors
|
9
|
+
white = im.colorAllocate(255,255,255)
|
10
|
+
black = im.colorAllocate(0,0,0)
|
11
|
+
red = im.colorAllocate(255,0,0)
|
12
|
+
blue = im.colorAllocate(0,0,255)
|
13
|
+
|
14
|
+
# make the background transparent and interlaced
|
15
|
+
im.transparent(white)
|
16
|
+
im.interlace = true
|
17
|
+
|
18
|
+
# Put a black frame around the picture
|
19
|
+
im.rectangle(0,0,99,99,black)
|
20
|
+
|
21
|
+
# Draw a blue oval
|
22
|
+
im.arc(50,50,95,75,0,360,blue)
|
23
|
+
|
24
|
+
# And fill it with red
|
25
|
+
im.fill(50,50,red)
|
26
|
+
|
27
|
+
# Convert the image to PNG and print it on standard output
|
28
|
+
im.png STDOUT
|
Binary file
|
data/sample/gdtestttf.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
=begin
|
3
|
+
|
4
|
+
gdtestttf.rb -
|
5
|
+
|
6
|
+
=end
|
7
|
+
|
8
|
+
require 'GD'
|
9
|
+
|
10
|
+
# change this to be suitable for your Environment
|
11
|
+
fontpath = "/mnt/windows/FONTS/times.ttf"
|
12
|
+
|
13
|
+
def deg2rad(degree)
|
14
|
+
degree*(Math::PI/180.0)
|
15
|
+
end
|
16
|
+
|
17
|
+
def maxx(brect)
|
18
|
+
[[brect[0],brect[2]].max, [brect[4],brect[6]].max].max
|
19
|
+
end
|
20
|
+
|
21
|
+
def maxy(brect)
|
22
|
+
[[brect[1],brect[3]].max, [brect[5],brect[7]].max].max
|
23
|
+
end
|
24
|
+
|
25
|
+
def minx(brect)
|
26
|
+
[[brect[0],brect[2]].min, [brect[4],brect[6]].min].min
|
27
|
+
end
|
28
|
+
|
29
|
+
def miny(brect)
|
30
|
+
[[brect[1],brect[3]].min, [brect[5],brect[7]].min].min
|
31
|
+
end
|
32
|
+
|
33
|
+
str = "Ruby/GD version 0.7.2"
|
34
|
+
angle = deg2rad(20)
|
35
|
+
sz = 36.0
|
36
|
+
# obtain brect so that we can size the image
|
37
|
+
err,brect = GD::Image.stringTTF(0, fontpath, sz, angle, 0, 0, str)
|
38
|
+
|
39
|
+
if err
|
40
|
+
puts err
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
|
44
|
+
x = maxx(brect) - minx(brect) + 6
|
45
|
+
y = maxy(brect) - miny(brect) + 6
|
46
|
+
im = GD::Image.new(x,y)
|
47
|
+
|
48
|
+
white = im.colorResolve(255,255,255)
|
49
|
+
black = im.colorResolve(0,0,0)
|
50
|
+
|
51
|
+
x = 0 - minx(brect) + 3
|
52
|
+
y = 0 - miny(brect) + 3
|
53
|
+
|
54
|
+
(err, brect) = im.stringTTF(black, fontpath, sz, angle, x, y, str)
|
55
|
+
if err
|
56
|
+
puts err
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
|
60
|
+
im.png $stdout
|
61
|
+
|
62
|
+
im.destroy
|