magickwand 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +20 -0
- data/README +2 -0
- data/Rakefile +28 -0
- data/ext/magickwand/extconf.rb +81 -0
- data/ext/magickwand/gc.c +464 -0
- data/ext/magickwand/magickwand.c +152 -0
- data/ext/magickwand/magickwand.h +91 -0
- data/ext/magickwand/utility.c +819 -0
- data/ext/magickwand/wand.c +2296 -0
- data/lib/magickwand.rb +28 -0
- data/test/Button_0.gif +0 -0
- data/test/Button_1.gif +0 -0
- data/test/Button_2.gif +0 -0
- data/test/Button_3.gif +0 -0
- data/test/Button_4.gif +0 -0
- data/test/Button_5.gif +0 -0
- data/test/Button_6.gif +0 -0
- data/test/Button_7.gif +0 -0
- data/test/Button_8.gif +0 -0
- data/test/Button_9.gif +0 -0
- data/test/bridges.jpg +0 -0
- data/test/test_magickwand.rb +1100 -0
- metadata +78 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Timothy Paul Hunter
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
20
|
+
|
data/README
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "rake/extensiontask"
|
2
|
+
|
3
|
+
spec = Gem::Specification.new do |s|
|
4
|
+
s.name = "magickwand"
|
5
|
+
s.version = "0.1.0"
|
6
|
+
s.platform = Gem::Platform::RUBY
|
7
|
+
s.extensions = FileList["ext/magickwand/extconf.rb"]
|
8
|
+
s.authors = ["Tim Hunter"]
|
9
|
+
s.files = ["README", "LICENSE", "Rakefile", "lib/magickwand.rb" ] + Dir["ext/magickwand/*"]
|
10
|
+
s.test_files = Dir["test/*"]
|
11
|
+
s.date = Date.today.to_s
|
12
|
+
s.licenses = "MIT License" if s.respond_to? :licences
|
13
|
+
s.summary = "A binding to ImageMagick"
|
14
|
+
s.email = "rmagick@rubyforge.org"
|
15
|
+
s.homepage = "http://magickwand.rubyforge.org/"
|
16
|
+
s.rubyforge_project = "magickwand"
|
17
|
+
s.description = "MagickWand for Ruby is a binding to the ImageMagick image processing library."
|
18
|
+
s.required_ruby_version = Gem::Requirement.new(">= 1.8.6")
|
19
|
+
s.rdoc_options = %w{--exclude lib --exclude ext}
|
20
|
+
s.extra_rdoc_files = %w{README}
|
21
|
+
s.specification_version = 1 if s.respond_to? :specification_version
|
22
|
+
end
|
23
|
+
|
24
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
25
|
+
end
|
26
|
+
|
27
|
+
Rake::ExtensionTask.new("magickwand", spec)
|
28
|
+
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'mkmf'
|
2
|
+
|
3
|
+
MAGICKWAND_VERSION = "0.1.0"
|
4
|
+
MIN_IM_VERS = "6.5.0"
|
5
|
+
MIN_IM_VERS_NO = MIN_IM_VERS.tr(".","").to_i
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
def exit_failure(reason)
|
10
|
+
msg = "\n*** Can't install MagickWand #{MAGICKWAND_VERSION}. #{reason} ***\n\n"
|
11
|
+
Logging::message msg
|
12
|
+
message msg
|
13
|
+
exit(1)
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
unless find_executable("Magick-config")
|
20
|
+
exit_failure "Can't find Magick-config in #{ENV['PATH']}"
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# Ensure minimum ImageMagick version
|
25
|
+
unless checking_for("ImageMagick version >= #{MIN_IM_VERS}") do
|
26
|
+
version = `Magick-config --version`.chomp.tr(".","").to_i
|
27
|
+
version >= MIN_IM_VERS_NO
|
28
|
+
end
|
29
|
+
exit_failure "You must have ImageMagick #{MIN_IM_VERS} or later."
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
$CFLAGS = ENV['CFLAGS'].to_s + " " + `Magick-config --cflags`.chomp
|
34
|
+
$CPPFLAGS = ENV['CPPFLAGS'].to_s + " " + `Magick-config --cppflags`.chomp
|
35
|
+
$LDLAGS = ENV['LDFLAGS'].to_s + " " + `Magick-config --ldflags`.chomp
|
36
|
+
$LOCAL_LIBS = ENV['LIBS'].to_s + " " + `Magick-config --libs`.chomp
|
37
|
+
|
38
|
+
# MagickWand.h dependencies
|
39
|
+
headers = %w{stdio.h stdlib.h math.h}
|
40
|
+
|
41
|
+
unless have_header("wand/MagickWand.h")
|
42
|
+
exit_failure "Can't install MagickWand. Can't find MagickWand.h."
|
43
|
+
end
|
44
|
+
|
45
|
+
headers += %w{wand/MagickWand.h assert.h ctype.h math.h time.h}
|
46
|
+
|
47
|
+
|
48
|
+
unless have_library("MagickWand", "MagickWandGenesis", headers)
|
49
|
+
exit_failure "Can't find libMagickWand or one of its dependent libraries. Check the mkmf.log file for more information."
|
50
|
+
end
|
51
|
+
|
52
|
+
# ImageMagick features Release added
|
53
|
+
["MagickSetColorspace", # 6.5.1
|
54
|
+
"MagickSetImageFuzz" # 6.5.1
|
55
|
+
].each do |func|
|
56
|
+
have_func(func, headers)
|
57
|
+
end
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
# Ruby version
|
63
|
+
headers = %w{ruby.h}
|
64
|
+
if have_header("ruby/io.h")
|
65
|
+
headers << "ruby/io.h"
|
66
|
+
else
|
67
|
+
headers << "rubyio.h"
|
68
|
+
end
|
69
|
+
|
70
|
+
|
71
|
+
have_func("rb_frame_this_func", headers)
|
72
|
+
have_func("rb_enumeratorize", headers)
|
73
|
+
have_func("rb_obj_type", headers)
|
74
|
+
|
75
|
+
$defs.push('-DMAGICKWAND_VERSION="\"' + MAGICKWAND_VERSION + '\""')
|
76
|
+
create_header()
|
77
|
+
|
78
|
+
# Force re-compilation if the generated Makefile changed
|
79
|
+
$config_h = "Makefile magickwand.h"
|
80
|
+
create_makefile("magickwand")
|
81
|
+
|
data/ext/magickwand/gc.c
ADDED
@@ -0,0 +1,464 @@
|
|
1
|
+
|
2
|
+
/*
|
3
|
+
* gc.c
|
4
|
+
* $Id: gc.c 118 2009-05-30 20:11:39Z rmagick $
|
5
|
+
* Copyright (C) 2009 Timothy Paul Hunter
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include "magickwand.h"
|
9
|
+
|
10
|
+
|
11
|
+
static void gc_destroy(void *);
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
static VALUE gc_allocate(VALUE klass)
|
16
|
+
{
|
17
|
+
GC *gc;
|
18
|
+
return Data_Make_Struct(klass, GC, NULL, gc_destroy, gc);
|
19
|
+
}
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
static void gc_destroy(void *p)
|
25
|
+
{
|
26
|
+
GC *gc = (GC *)p;
|
27
|
+
|
28
|
+
if (gc->drawingwand)
|
29
|
+
{
|
30
|
+
gc->drawingwand = DestroyDrawingWand(gc->drawingwand);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
/*
|
38
|
+
* Construct a new GC object
|
39
|
+
*/
|
40
|
+
VALUE mwr_gc_new(void)
|
41
|
+
{
|
42
|
+
VALUE obj;
|
43
|
+
GC *gc;
|
44
|
+
|
45
|
+
obj = Data_Make_Struct(mwr_cGC, GC, NULL, gc_destroy, gc);
|
46
|
+
gc->drawingwand = NewDrawingWand();
|
47
|
+
return obj;
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
/*
|
54
|
+
* :align => string
|
55
|
+
* set text alignment
|
56
|
+
*/
|
57
|
+
static VALUE gc_set_align(VALUE obj, VALUE align)
|
58
|
+
{
|
59
|
+
GC *gc;
|
60
|
+
AlignType type;
|
61
|
+
|
62
|
+
rb_check_frozen(obj);
|
63
|
+
type = mwr_string_to_aligntype(align, LeftAlign, RaiseUndefinedOption);
|
64
|
+
Data_Get_Struct(obj, GC, gc);
|
65
|
+
DrawSetTextAlignment(gc->drawingwand, type);
|
66
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
67
|
+
return obj;
|
68
|
+
}
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
|
74
|
+
/*
|
75
|
+
* :antialias => boolean
|
76
|
+
* turn text antialias on or off
|
77
|
+
*/
|
78
|
+
static VALUE gc_set_antialias(VALUE obj, VALUE antialias)
|
79
|
+
{
|
80
|
+
GC *gc;
|
81
|
+
|
82
|
+
rb_check_frozen(obj);
|
83
|
+
Data_Get_Struct(obj, GC, gc);
|
84
|
+
DrawSetTextAntialias(gc->drawingwand, RTEST(antialias) ? MagickTrue : MagickFalse);
|
85
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
86
|
+
return obj;
|
87
|
+
}
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
/*
|
93
|
+
* :decoration => string
|
94
|
+
*/
|
95
|
+
static VALUE gc_set_decoration(VALUE obj, VALUE decoration)
|
96
|
+
{
|
97
|
+
GC *gc;
|
98
|
+
DecorationType type;
|
99
|
+
|
100
|
+
rb_check_frozen(obj);
|
101
|
+
type = mwr_string_to_decorationtype(decoration, NoDecoration, RaiseUndefinedOption);
|
102
|
+
Data_Get_Struct(obj, GC, gc);
|
103
|
+
DrawSetTextDecoration(gc->drawingwand, type);
|
104
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
105
|
+
return obj;
|
106
|
+
}
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
/*
|
112
|
+
* :encoding => string
|
113
|
+
*/
|
114
|
+
static VALUE gc_set_encoding(VALUE obj, VALUE encoding)
|
115
|
+
{
|
116
|
+
GC *gc;
|
117
|
+
|
118
|
+
rb_check_frozen(obj);
|
119
|
+
Data_Get_Struct(obj, GC, gc);
|
120
|
+
DrawSetTextEncoding(gc->drawingwand, StringValuePtr(encoding));
|
121
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
122
|
+
return obj;
|
123
|
+
}
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
/*
|
128
|
+
* :family => string
|
129
|
+
*/
|
130
|
+
static VALUE gc_set_family(VALUE obj, VALUE family)
|
131
|
+
{
|
132
|
+
GC *gc;
|
133
|
+
|
134
|
+
rb_check_frozen(obj);
|
135
|
+
Data_Get_Struct(obj, GC, gc);
|
136
|
+
DrawSetFontFamily(gc->drawingwand, StringValuePtr(family));
|
137
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
138
|
+
return obj;
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
/*
|
145
|
+
* :fill => string
|
146
|
+
*/
|
147
|
+
static VALUE gc_set_fill(VALUE obj, VALUE fill)
|
148
|
+
{
|
149
|
+
GC *gc;
|
150
|
+
PixelWand *pixelwand;
|
151
|
+
|
152
|
+
rb_check_frozen(obj);
|
153
|
+
pixelwand = NewPixelWand();
|
154
|
+
|
155
|
+
PixelSetColor(pixelwand, StringValuePtr(fill));
|
156
|
+
mwr_check_pixelwand_error(pixelwand);
|
157
|
+
Data_Get_Struct(obj, GC, gc);
|
158
|
+
DrawSetFillColor(gc->drawingwand, pixelwand);
|
159
|
+
pixelwand = DestroyPixelWand(pixelwand);
|
160
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
161
|
+
return obj;
|
162
|
+
}
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
/*
|
168
|
+
* :fill_opacity => float
|
169
|
+
*/
|
170
|
+
static VALUE gc_set_fill_opacity(VALUE obj, VALUE fill_opacity)
|
171
|
+
{
|
172
|
+
GC *gc;
|
173
|
+
double opacity;
|
174
|
+
|
175
|
+
rb_check_frozen(obj);
|
176
|
+
opacity = NUM2DBL(fill_opacity);
|
177
|
+
if (opacity < 0.0)
|
178
|
+
{
|
179
|
+
opacity = 0.0;
|
180
|
+
}
|
181
|
+
else if (opacity > 1.0)
|
182
|
+
{
|
183
|
+
opacity = 1.0;
|
184
|
+
}
|
185
|
+
|
186
|
+
Data_Get_Struct(obj, GC, gc);
|
187
|
+
DrawSetFillOpacity(gc->drawingwand, opacity);
|
188
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
189
|
+
return obj;
|
190
|
+
}
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
/*
|
196
|
+
* :font => string
|
197
|
+
*/
|
198
|
+
static VALUE gc_set_font(VALUE obj, VALUE font)
|
199
|
+
{
|
200
|
+
GC *gc;
|
201
|
+
|
202
|
+
rb_check_frozen(obj);
|
203
|
+
Data_Get_Struct(obj, GC, gc);
|
204
|
+
DrawSetFont(gc->drawingwand, StringValuePtr(font));
|
205
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
206
|
+
return obj;
|
207
|
+
}
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
/*
|
213
|
+
* :gravity => string
|
214
|
+
*/
|
215
|
+
static VALUE gc_set_gravity(VALUE obj, VALUE gravity)
|
216
|
+
{
|
217
|
+
GC *gc;
|
218
|
+
GravityType type;
|
219
|
+
|
220
|
+
rb_check_frozen(obj);
|
221
|
+
type = mwr_string_to_gravitytype(gravity, NorthWestGravity, RaiseUndefinedOption);
|
222
|
+
Data_Get_Struct(obj, GC, gc);
|
223
|
+
DrawSetGravity(gc->drawingwand, type);
|
224
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
225
|
+
return obj;
|
226
|
+
}
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
/*
|
232
|
+
* :interword_spacing => float
|
233
|
+
*/
|
234
|
+
static VALUE gc_set_interword_spacing(VALUE obj, VALUE interword_spacing)
|
235
|
+
{
|
236
|
+
GC *gc;
|
237
|
+
|
238
|
+
rb_check_frozen(obj);
|
239
|
+
Data_Get_Struct(obj, GC, gc);
|
240
|
+
DrawSetTextInterwordSpacing(gc->drawingwand, NUM2DBL(interword_spacing));
|
241
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
242
|
+
return obj;
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
/*
|
249
|
+
* :kerning => float
|
250
|
+
*/
|
251
|
+
static VALUE gc_set_kerning(VALUE obj, VALUE kerning)
|
252
|
+
{
|
253
|
+
GC *gc;
|
254
|
+
|
255
|
+
rb_check_frozen(obj);
|
256
|
+
Data_Get_Struct(obj, GC, gc);
|
257
|
+
DrawSetTextKerning(gc->drawingwand, NUM2DBL(kerning));
|
258
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
259
|
+
return obj;
|
260
|
+
}
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
|
265
|
+
/*
|
266
|
+
* :pointsize => float
|
267
|
+
*/
|
268
|
+
static VALUE gc_set_pointsize(VALUE obj, VALUE pointsize)
|
269
|
+
{
|
270
|
+
GC *gc;
|
271
|
+
|
272
|
+
rb_check_frozen(obj);
|
273
|
+
Data_Get_Struct(obj, GC, gc);
|
274
|
+
DrawSetFontSize(gc->drawingwand, NUM2DBL(pointsize));
|
275
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
276
|
+
return obj;
|
277
|
+
}
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
/*
|
283
|
+
* :stretch => string
|
284
|
+
*/
|
285
|
+
static VALUE gc_set_stretch(VALUE obj, VALUE stretch)
|
286
|
+
{
|
287
|
+
GC *gc;
|
288
|
+
StretchType type;
|
289
|
+
|
290
|
+
rb_check_frozen(obj);
|
291
|
+
type = mwr_string_to_stretchtype(stretch, AnyStretch, RaiseUndefinedOption);
|
292
|
+
Data_Get_Struct(obj, GC, gc);
|
293
|
+
DrawSetFontStretch(gc->drawingwand, type);
|
294
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
295
|
+
return obj;
|
296
|
+
}
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
/*
|
301
|
+
* :stroke => string
|
302
|
+
*/
|
303
|
+
static VALUE gc_set_stroke(VALUE obj, VALUE stroke)
|
304
|
+
{
|
305
|
+
GC *gc;
|
306
|
+
PixelWand *pixelwand;
|
307
|
+
|
308
|
+
rb_check_frozen(obj);
|
309
|
+
pixelwand = NewPixelWand();
|
310
|
+
|
311
|
+
PixelSetColor(pixelwand, StringValuePtr(stroke));
|
312
|
+
mwr_check_pixelwand_error(pixelwand);
|
313
|
+
Data_Get_Struct(obj, GC, gc);
|
314
|
+
DrawSetStrokeColor(gc->drawingwand, pixelwand);
|
315
|
+
pixelwand = DestroyPixelWand(pixelwand);
|
316
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
317
|
+
return obj;
|
318
|
+
}
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
/*
|
324
|
+
* :stroke_opacity => float
|
325
|
+
*/
|
326
|
+
static VALUE gc_set_stroke_opacity(VALUE obj, VALUE stroke_opacity)
|
327
|
+
{
|
328
|
+
GC *gc;
|
329
|
+
double opacity;
|
330
|
+
|
331
|
+
rb_check_frozen(obj);
|
332
|
+
opacity = NUM2DBL(stroke_opacity);
|
333
|
+
if (opacity < 0.0)
|
334
|
+
{
|
335
|
+
opacity = 0.0;
|
336
|
+
}
|
337
|
+
else if (opacity > 1.0)
|
338
|
+
{
|
339
|
+
opacity = 1.0;
|
340
|
+
}
|
341
|
+
|
342
|
+
Data_Get_Struct(obj, GC, gc);
|
343
|
+
DrawSetStrokeOpacity(gc->drawingwand, opacity);
|
344
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
345
|
+
return obj;
|
346
|
+
}
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
|
351
|
+
/*
|
352
|
+
* :strokewidth => float
|
353
|
+
*/
|
354
|
+
static VALUE gc_set_strokewidth(VALUE obj, VALUE strokewidth)
|
355
|
+
{
|
356
|
+
GC *gc;
|
357
|
+
|
358
|
+
rb_check_frozen(obj);
|
359
|
+
Data_Get_Struct(obj, GC, gc);
|
360
|
+
DrawSetStrokeWidth(gc->drawingwand, NUM2DBL(strokewidth));
|
361
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
362
|
+
return obj;
|
363
|
+
}
|
364
|
+
|
365
|
+
|
366
|
+
|
367
|
+
|
368
|
+
/*
|
369
|
+
* :style => string
|
370
|
+
*/
|
371
|
+
static VALUE gc_set_style(VALUE obj, VALUE style)
|
372
|
+
{
|
373
|
+
GC *gc;
|
374
|
+
StyleType type;
|
375
|
+
|
376
|
+
rb_check_frozen(obj);
|
377
|
+
type = mwr_string_to_styletype(style, NormalStyle, RaiseUndefinedOption);
|
378
|
+
Data_Get_Struct(obj, GC, gc);
|
379
|
+
DrawSetFontStyle(gc->drawingwand, type);
|
380
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
381
|
+
return obj;
|
382
|
+
}
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
/*
|
388
|
+
* :undercolor => string
|
389
|
+
*/
|
390
|
+
static VALUE gc_set_undercolor(VALUE obj, VALUE undercolor)
|
391
|
+
{
|
392
|
+
GC *gc;
|
393
|
+
PixelWand *pixelwand;
|
394
|
+
|
395
|
+
rb_check_frozen(obj);
|
396
|
+
pixelwand = NewPixelWand();
|
397
|
+
|
398
|
+
PixelSetColor(pixelwand, StringValuePtr(undercolor));
|
399
|
+
mwr_check_pixelwand_error(pixelwand);
|
400
|
+
Data_Get_Struct(obj, GC, gc);
|
401
|
+
DrawSetTextUnderColor(gc->drawingwand, pixelwand);
|
402
|
+
pixelwand = DestroyPixelWand(pixelwand);
|
403
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
404
|
+
return obj;
|
405
|
+
}
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
|
410
|
+
/*
|
411
|
+
* :weight => fixnum
|
412
|
+
*/
|
413
|
+
static VALUE gc_set_weight(VALUE obj, VALUE weight)
|
414
|
+
{
|
415
|
+
GC *gc;
|
416
|
+
unsigned long w;
|
417
|
+
|
418
|
+
rb_check_frozen(obj);
|
419
|
+
if (TYPE(weight) == T_STRING)
|
420
|
+
{
|
421
|
+
w = mwr_string_to_weight(weight, 0, RaiseUndefinedOption);
|
422
|
+
}
|
423
|
+
else
|
424
|
+
{
|
425
|
+
w = FIX2ULONG(weight);
|
426
|
+
}
|
427
|
+
Data_Get_Struct(obj, GC, gc);
|
428
|
+
DrawSetFontWeight(gc->drawingwand, w);
|
429
|
+
mwr_check_drawingwand_error(gc->drawingwand);
|
430
|
+
return obj;
|
431
|
+
}
|
432
|
+
|
433
|
+
|
434
|
+
|
435
|
+
|
436
|
+
/*
|
437
|
+
* MagickWand::GC class
|
438
|
+
*/
|
439
|
+
void mwr_init_GC(void)
|
440
|
+
{
|
441
|
+
mwr_cGC = rb_define_class_under(mwr_mMagickWand, "GC", rb_cObject);
|
442
|
+
rb_define_alloc_func(mwr_cGC, gc_allocate);
|
443
|
+
|
444
|
+
// Private property setters are called during option processing.
|
445
|
+
rb_define_private_method(mwr_cGC, "set_align", gc_set_align, 1);
|
446
|
+
rb_define_private_method(mwr_cGC, "set_antialias", gc_set_antialias, 1);
|
447
|
+
rb_define_private_method(mwr_cGC, "set_decoration", gc_set_decoration, 1);
|
448
|
+
rb_define_private_method(mwr_cGC, "set_encoding", gc_set_encoding, 1);
|
449
|
+
rb_define_private_method(mwr_cGC, "set_family", gc_set_family, 1);
|
450
|
+
rb_define_private_method(mwr_cGC, "set_fill", gc_set_fill, 1);
|
451
|
+
rb_define_private_method(mwr_cGC, "set_fill_opacity", gc_set_fill_opacity, 1);
|
452
|
+
rb_define_private_method(mwr_cGC, "set_font", gc_set_font, 1);
|
453
|
+
rb_define_private_method(mwr_cGC, "set_gravity", gc_set_gravity, 1);
|
454
|
+
rb_define_private_method(mwr_cGC, "set_interword_spacing", gc_set_interword_spacing, 1);
|
455
|
+
rb_define_private_method(mwr_cGC, "set_kerning", gc_set_kerning, 1);
|
456
|
+
rb_define_private_method(mwr_cGC, "set_pointsize", gc_set_pointsize, 1);
|
457
|
+
rb_define_private_method(mwr_cGC, "set_stretch", gc_set_stretch, 1);
|
458
|
+
rb_define_private_method(mwr_cGC, "set_stroke", gc_set_stroke, 1);
|
459
|
+
rb_define_private_method(mwr_cGC, "set_stroke_opacity", gc_set_stroke_opacity, 1);
|
460
|
+
rb_define_private_method(mwr_cGC, "set_strokewidth", gc_set_strokewidth, 1);
|
461
|
+
rb_define_private_method(mwr_cGC, "set_style", gc_set_style, 1);
|
462
|
+
rb_define_private_method(mwr_cGC, "set_undercolor", gc_set_undercolor, 1);
|
463
|
+
rb_define_private_method(mwr_cGC, "set_weight", gc_set_weight, 1);
|
464
|
+
}
|