rmagick 1.8.3 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rmagick might be problematic. Click here for more details.
- data/ChangeLog +5 -0
- data/README.html +8 -8
- data/README.txt +6 -6
- data/configure +12 -11
- data/configure.ac +2 -2
- data/doc/draw.html +10 -10
- data/doc/ex/InitialCoords.rb +1 -2
- data/doc/ex/NewCoordSys.rb +1 -2
- data/doc/ex/OrigCoordSys.rb +1 -2
- data/doc/ex/PreserveAspectRatio.rb +4 -5
- data/doc/ex/RotateScale.rb +1 -2
- data/doc/ex/Skew.rb +1 -2
- data/doc/ex/Use01.rb +3 -4
- data/doc/ex/Use02.rb +3 -4
- data/doc/ex/Use03.rb +3 -4
- data/doc/ex/ViewBox.rb +1 -2
- data/doc/ex/arcs01.rb +2 -3
- data/doc/ex/arcs02.rb +3 -4
- data/doc/ex/baseline_shift01.rb +1 -2
- data/doc/ex/circle01.rb +2 -3
- data/doc/ex/cubic01.rb +2 -3
- data/doc/ex/cubic02.rb +2 -3
- data/doc/ex/ellipse01.rb +2 -3
- data/doc/ex/evenodd.rb +3 -4
- data/doc/ex/font_styles.rb +1 -2
- data/doc/ex/group.rb +3 -4
- data/doc/ex/image.rb +1 -2
- data/doc/ex/line01.rb +2 -3
- data/doc/ex/nested_rvg.rb +2 -3
- data/doc/ex/nonzero.rb +3 -4
- data/doc/ex/polygon01.rb +2 -3
- data/doc/ex/polyline01.rb +2 -3
- data/doc/ex/quad01.rb +2 -3
- data/doc/ex/rect01.rb +2 -3
- data/doc/ex/rect02.rb +2 -3
- data/doc/ex/rvg_clippath.rb +3 -4
- data/doc/ex/rvg_linecap.rb +2 -3
- data/doc/ex/rvg_linejoin.rb +2 -3
- data/doc/ex/rvg_opacity.rb +1 -2
- data/doc/ex/rvg_pattern.rb +3 -4
- data/doc/ex/rvg_stroke_dasharray.rb +1 -2
- data/doc/ex/stegano.rb +23 -7
- data/doc/ex/stroke_fill.rb +1 -2
- data/doc/ex/text01.rb +2 -3
- data/doc/ex/text_styles.rb +1 -2
- data/doc/ex/tref01.rb +3 -4
- data/doc/ex/triangle01.rb +2 -3
- data/doc/ex/tspan01.rb +2 -3
- data/doc/ex/tspan02.rb +2 -3
- data/doc/ex/tspan03.rb +2 -3
- data/doc/ex/writing_mode01.rb +2 -3
- data/doc/ex/writing_mode02.rb +2 -3
- data/doc/imageattrs.html +92 -1
- data/doc/info.html +29 -0
- data/doc/magick.html +12 -6
- data/doc/rvgstyle.html +0 -2
- data/ext/RMagick/MANIFEST +1 -1
- data/ext/RMagick/rmagick.h +8 -2
- data/ext/RMagick/rmagick_config.h.in +2 -0
- data/ext/RMagick/rmdraw.c +9 -4
- data/ext/RMagick/rmimage.c +37 -1
- data/ext/RMagick/rminfo.c +34 -1
- data/ext/RMagick/rmmain.c +10 -3
- data/ext/RMagick/rmutil.c +33 -2
- data/lib/RMagick.rb +30 -9
- data/lib/rvg/embellishable.rb +9 -9
- data/lib/rvg/misc.rb +17 -17
- data/lib/rvg/paint.rb +2 -2
- data/lib/rvg/rvg.rb +13 -13
- data/lib/rvg/text.rb +6 -6
- data/rmagick.gemspec +1 -1
- metadata +2 -2
data/ext/RMagick/rmutil.c
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
/* $Id: rmutil.c,v 1.
|
1
|
+
/* $Id: rmutil.c,v 1.53 2005/06/21 22:55:01 rmagick Exp $ */
|
2
2
|
/*============================================================================\
|
3
3
|
| Copyright (C) 2005 by Timothy P. Hunter
|
4
4
|
| Name: rmutil.c
|
@@ -2760,9 +2760,40 @@ void rm_handle_all_errors(Image *seq)
|
|
2760
2760
|
}
|
2761
2761
|
}
|
2762
2762
|
|
2763
|
+
/*
|
2764
|
+
Extern: rm_progress_monitor
|
2765
|
+
Purpose: SetImage(Info)ProgressMonitor exit
|
2766
|
+
Notes: ImageMagick's "tag" argument is unused. We pass along the method name instead.
|
2767
|
+
*/
|
2768
|
+
#if defined(HAVE_SETIMAGEPROGRESSMONITOR)
|
2769
|
+
MagickBooleanType rm_progress_monitor(
|
2770
|
+
const char *tag,
|
2771
|
+
const MagickOffsetType of,
|
2772
|
+
const MagickSizeType sp,
|
2773
|
+
void *client_data)
|
2774
|
+
{
|
2775
|
+
volatile VALUE rval;
|
2776
|
+
volatile VALUE method, offset, span;
|
2777
|
+
|
2778
|
+
#if defined(HAVE_LONG_LONG) // defined in Ruby's defines.h
|
2779
|
+
offset = rb_ll2inum(of);
|
2780
|
+
span = rb_ull2inum(sp);
|
2781
|
+
#else
|
2782
|
+
offset = rb_int2big((long)of);
|
2783
|
+
span = rb_uint2big((unsigned long)sp);
|
2784
|
+
#endif
|
2785
|
+
|
2786
|
+
method = rb_str_new2(rb_id2name(rb_frame_last_func()));
|
2787
|
+
|
2788
|
+
rval = rb_funcall((VALUE)client_data, ID_call, 3, method, offset, span);
|
2789
|
+
|
2790
|
+
return RTEST(rval) ? MagickTrue : MagickFalse;
|
2791
|
+
}
|
2792
|
+
#endif
|
2793
|
+
|
2763
2794
|
|
2764
2795
|
/*
|
2765
|
-
Extern:
|
2796
|
+
Extern: rm_split
|
2766
2797
|
Purpose: Remove the ImageMagick links between images in an scene
|
2767
2798
|
sequence.
|
2768
2799
|
Notes: The images remain grouped via the ImageList
|
data/lib/RMagick.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: RMagick.rb,v 1.
|
1
|
+
# $Id: RMagick.rb,v 1.25 2005/07/12 23:34:04 rmagick Exp $
|
2
2
|
#==============================================================================
|
3
3
|
# Copyright (C) 2005 by Timothy P. Hunter
|
4
4
|
# Name: RMagick.rb
|
@@ -163,6 +163,17 @@ class Draw
|
|
163
163
|
ObliqueStyle.to_i => 'oblique',
|
164
164
|
AnyStyle.to_i => 'all'
|
165
165
|
}
|
166
|
+
|
167
|
+
private
|
168
|
+
def enquote(str)
|
169
|
+
if str.length > 2 && /\A(?:\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})\z/.match(str)
|
170
|
+
return str
|
171
|
+
else
|
172
|
+
return '"' + str + '"'
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
public
|
166
177
|
|
167
178
|
# Apply coordinate transformations to support scaling (s), rotation (r),
|
168
179
|
# and translation (t). Angles are specified in radians.
|
@@ -227,7 +238,7 @@ class Draw
|
|
227
238
|
if ( DECORATION_TYPE_NAMES.has_key?(decoration.to_i) )
|
228
239
|
primitive "decorate #{DECORATION_TYPE_NAMES[decoration.to_i]}"
|
229
240
|
else
|
230
|
-
primitive "decorate #{decoration}"
|
241
|
+
primitive "decorate #{enquote(decoration)}"
|
231
242
|
end
|
232
243
|
end
|
233
244
|
|
@@ -263,7 +274,7 @@ class Draw
|
|
263
274
|
|
264
275
|
# Specify object fill, a color name or pattern name
|
265
276
|
def fill(colorspec)
|
266
|
-
primitive "fill #{colorspec}"
|
277
|
+
primitive "fill #{enquote(colorspec)}"
|
267
278
|
end
|
268
279
|
alias fill_color fill
|
269
280
|
alias fill_pattern fill
|
@@ -463,7 +474,7 @@ class Draw
|
|
463
474
|
|
464
475
|
# Specify the object stroke, a color name or pattern name.
|
465
476
|
def stroke(colorspec)
|
466
|
-
primitive "stroke #{colorspec}"
|
477
|
+
primitive "stroke #{enquote(colorspec)}"
|
467
478
|
end
|
468
479
|
alias stroke_color stroke
|
469
480
|
alias stroke_pattern stroke
|
@@ -525,13 +536,23 @@ class Draw
|
|
525
536
|
primitive "stroke-width #{pixels}"
|
526
537
|
end
|
527
538
|
|
528
|
-
# Draw text at position x,y.
|
529
|
-
# quotes. For example,
|
530
|
-
# gc.text(100, 100, "'embedded blanks'")
|
539
|
+
# Draw text at position x,y. Add quotes to text that is not already quoted.
|
531
540
|
def text(x, y, text)
|
532
541
|
if text.to_s.empty?
|
533
542
|
raise ArgumentError, "missing text argument"
|
534
|
-
end
|
543
|
+
end
|
544
|
+
if text.length > 2 && /\A(?:\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})\z/.match(text)
|
545
|
+
; # text already quoted
|
546
|
+
elsif !text['\'']
|
547
|
+
text = '\''+text+'\''
|
548
|
+
elsif !text['"']
|
549
|
+
text = '"'+text+'"'
|
550
|
+
elsif !(text['{'] || text['}'])
|
551
|
+
text = '{'+text+'}'
|
552
|
+
else
|
553
|
+
# escape existing braces, surround with braces
|
554
|
+
text = '{' + text.gsub(/[}]/) { |b| '\\' + b } + '}'
|
555
|
+
end
|
535
556
|
primitive "text #{x},#{y} #{text}"
|
536
557
|
end
|
537
558
|
|
@@ -559,7 +580,7 @@ class Draw
|
|
559
580
|
|
560
581
|
# Specify color underneath text
|
561
582
|
def text_undercolor(color)
|
562
|
-
primitive "text-undercolor #{color}"
|
583
|
+
primitive "text-undercolor #{enquote(color)}"
|
563
584
|
end
|
564
585
|
|
565
586
|
# Specify center of coordinate space to use for subsequent drawing
|
data/lib/rvg/embellishable.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# $Id: embellishable.rb,v 1.
|
2
|
+
# $Id: embellishable.rb,v 1.5 2005/07/15 20:48:50 rmagick Exp $
|
3
3
|
# Copyright (C) 2005 Timothy P. Hunter
|
4
4
|
#++
|
5
5
|
|
@@ -28,7 +28,7 @@ class Magick::RVG
|
|
28
28
|
# Use the RVG::ShapeConstructors#circle method to create Circle objects in a container.
|
29
29
|
def initialize(r, cx=0, cy=0)
|
30
30
|
super()
|
31
|
-
r, cx, cy = RVG.convert_to_float(r, cx, cy)
|
31
|
+
r, cx, cy = Magick::RVG.convert_to_float(r, cx, cy)
|
32
32
|
if r < 0
|
33
33
|
raise ArgumentError, "radius must be >= 0 (#{r} given)"
|
34
34
|
end
|
@@ -46,7 +46,7 @@ class Magick::RVG
|
|
46
46
|
# Use the RVG::ShapeConstructors#ellipse method to create Ellipse objects in a container.
|
47
47
|
def initialize(rx, ry, cx=0, cy=0)
|
48
48
|
super()
|
49
|
-
rx, ry, cx, cy = RVG.convert_to_float(rx, ry, cx, cy)
|
49
|
+
rx, ry, cx, cy = Magick::RVG.convert_to_float(rx, ry, cx, cy)
|
50
50
|
if rx < 0 || ry < 0
|
51
51
|
raise ArgumentError, "radii must be >= 0 (#{rx}, #{ry} given)"
|
52
52
|
end
|
@@ -89,7 +89,7 @@ class Magick::RVG
|
|
89
89
|
# Use the RVG::ShapeConstructors#rect method to create Rect objects in a container.
|
90
90
|
def initialize(width, height, x=0, y=0)
|
91
91
|
super()
|
92
|
-
width, height, x, y = RVG.convert_to_float(width, height, x, y)
|
92
|
+
width, height, x, y = Magick::RVG.convert_to_float(width, height, x, y)
|
93
93
|
if width < 0 || height < 0
|
94
94
|
raise ArgumentError, "width, height must be >= 0 (#{width}, #{height} given)"
|
95
95
|
end
|
@@ -100,7 +100,7 @@ class Magick::RVG
|
|
100
100
|
# Specify optional rounded corners for a rectangle. The arguments
|
101
101
|
# are the x- and y-axis radii. If y is omitted it defaults to x.
|
102
102
|
def round(rx, ry=nil)
|
103
|
-
rx, ry = RVG.convert_to_float(rx, ry || rx)
|
103
|
+
rx, ry = Magick::RVG.convert_to_float(rx, ry || rx)
|
104
104
|
if rx < 0 || ry < 0
|
105
105
|
raise ArgumentError, "rx, ry must be >= 0 (#{rx}, #{ry} given)"
|
106
106
|
end
|
@@ -133,7 +133,7 @@ class Magick::RVG
|
|
133
133
|
if n < 4 || n % 2 != 0
|
134
134
|
raise ArgumentError, "insufficient/odd number of points specified: #{n}"
|
135
135
|
end
|
136
|
-
return RVG.convert_to_float(*points)
|
136
|
+
return Magick::RVG.convert_to_float(*points)
|
137
137
|
end
|
138
138
|
|
139
139
|
end # class PolyShape
|
@@ -164,7 +164,7 @@ class Magick::RVG
|
|
164
164
|
super()
|
165
165
|
points = polypoints(points)
|
166
166
|
@primitive = :polyline
|
167
|
-
@args = RVG.convert_to_float(*points)
|
167
|
+
@args = Magick::RVG.convert_to_float(*points)
|
168
168
|
end
|
169
169
|
|
170
170
|
end # class Polyline
|
@@ -236,7 +236,7 @@ class Magick::RVG
|
|
236
236
|
def initialize(image, width=nil, height=nil, x=0, y=0)
|
237
237
|
super() # run module initializers
|
238
238
|
@image = image.copy # use a copy of the image in case app. re-uses the argument
|
239
|
-
@x, @y, @width, @height = RVG.convert_to_float(x, y, width || @image.columns, height || @image.rows)
|
239
|
+
@x, @y, @width, @height = Magick::RVG.convert_to_float(x, y, width || @image.columns, height || @image.rows)
|
240
240
|
if @width < 0 || @height < 0
|
241
241
|
raise ArgumentError, "width, height must be >= 0"
|
242
242
|
end
|
@@ -353,7 +353,7 @@ class Magick::RVG
|
|
353
353
|
# contained within, unless overridden by an inner container or
|
354
354
|
# the contained object itself.
|
355
355
|
def rvg(cols, rows, x=0, y=0, &block)
|
356
|
-
rvg = RVG.new(cols, rows, &block)
|
356
|
+
rvg = Magick::RVG.new(cols, rows, &block)
|
357
357
|
begin
|
358
358
|
x, y = Float(x), Float(y)
|
359
359
|
rescue ArgumentError
|
data/lib/rvg/misc.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# $Id: misc.rb,v 1.
|
1
|
+
# $Id: misc.rb,v 1.8 2005/07/15 20:48:50 rmagick Exp $
|
2
2
|
# Copyright (C) 2005 Timothy P. Hunter
|
3
3
|
class Magick::RVG
|
4
4
|
|
@@ -95,8 +95,8 @@ module Magick::RVG::Utility
|
|
95
95
|
end
|
96
96
|
|
97
97
|
# escape existing braces, surround with braces
|
98
|
-
|
99
|
-
return '{' +
|
98
|
+
text.gsub!(/[}]/) { |b| '\\' + b }
|
99
|
+
return '{' + text + '}'
|
100
100
|
end
|
101
101
|
|
102
102
|
def glyph_metrics(glyph_orientation, glyph)
|
@@ -343,7 +343,7 @@ module Magick::RVG::Utility
|
|
343
343
|
|
344
344
|
def initialize()
|
345
345
|
@affine = Array.new
|
346
|
-
@affine << AffineMatrix.new(1, 0, 0, 1, 0, 0)
|
346
|
+
@affine << Magick::AffineMatrix.new(1, 0, 0, 1, 0, 0)
|
347
347
|
@baseline_shift = Array.new
|
348
348
|
@baseline_shift << :baseline
|
349
349
|
@glyph_orientation_horizontal = Array.new
|
@@ -526,9 +526,9 @@ module Magick::RVG::Utility
|
|
526
526
|
attr_reader :gc, :text_attrs
|
527
527
|
|
528
528
|
def initialize()
|
529
|
-
@gc = Draw.new
|
529
|
+
@gc = Magick::Draw.new
|
530
530
|
@shadow = Array.new
|
531
|
-
@shadow << Draw.new
|
531
|
+
@shadow << Magick::Draw.new
|
532
532
|
@text_attrs = TextAttributes.new
|
533
533
|
init_matrix()
|
534
534
|
end
|
@@ -538,7 +538,7 @@ module Magick::RVG::Utility
|
|
538
538
|
end
|
539
539
|
|
540
540
|
def affine(sx, rx, ry, sy, tx, ty)
|
541
|
-
sx, rx, ry, sy, tx, ty = RVG.convert_to_float(sx, rx, ry, sy, tx, ty)
|
541
|
+
sx, rx, ry, sy, tx, ty = Magick::RVG.convert_to_float(sx, rx, ry, sy, tx, ty)
|
542
542
|
@gc.affine(sx, rx, ry, sy, tx, ty)
|
543
543
|
@text_attrs.set_affine(sx, rx, ry, sy, tx, ty)
|
544
544
|
nil
|
@@ -597,13 +597,13 @@ module Magick::RVG::Utility
|
|
597
597
|
end
|
598
598
|
|
599
599
|
def glyph_orientation_horizontal(deg)
|
600
|
-
deg = RVG.convert_one_to_float(deg)
|
600
|
+
deg = Magick::RVG.convert_one_to_float(deg)
|
601
601
|
@text_attrs.glyph_orientation_horizontal = (deg % 360) / 90 * 90
|
602
602
|
nil
|
603
603
|
end
|
604
604
|
|
605
605
|
def glyph_orientation_vertical(deg)
|
606
|
-
deg = RVG.convert_one_to_float(deg)
|
606
|
+
deg = Magick::RVG.convert_one_to_float(deg)
|
607
607
|
@text_attrs.glyph_orientation_vertical = (deg % 360) / 90 * 90
|
608
608
|
nil
|
609
609
|
end
|
@@ -613,7 +613,7 @@ module Magick::RVG::Utility
|
|
613
613
|
end
|
614
614
|
|
615
615
|
def letter_spacing(value)
|
616
|
-
@text_attrs.letter_spacing = RVG.convert_one_to_float(value)
|
616
|
+
@text_attrs.letter_spacing = Magick::RVG.convert_one_to_float(value)
|
617
617
|
nil
|
618
618
|
end
|
619
619
|
|
@@ -632,7 +632,7 @@ module Magick::RVG::Utility
|
|
632
632
|
end
|
633
633
|
|
634
634
|
def rotate(degrees)
|
635
|
-
degrees = RVG.convert_one_to_float(degrees)
|
635
|
+
degrees = Magick::RVG.convert_one_to_float(degrees)
|
636
636
|
@gc.rotate(degrees)
|
637
637
|
@sx = Math.cos(GraphicContext.degrees_to_radians(degrees))
|
638
638
|
@rx = Math.sin(GraphicContext.degrees_to_radians(degrees))
|
@@ -643,7 +643,7 @@ module Magick::RVG::Utility
|
|
643
643
|
end
|
644
644
|
|
645
645
|
def scale(sx, sy)
|
646
|
-
sx, sy = RVG.convert_to_float(sx, sy)
|
646
|
+
sx, sy = Magick::RVG.convert_to_float(sx, sy)
|
647
647
|
@gc.scale(sx, sy)
|
648
648
|
@sx, @sy = sx, sy
|
649
649
|
concat_matrix()
|
@@ -655,7 +655,7 @@ module Magick::RVG::Utility
|
|
655
655
|
end
|
656
656
|
|
657
657
|
def skewX(degrees)
|
658
|
-
degrees = RVG.convert_one_to_float(degrees)
|
658
|
+
degrees = Magick::RVG.convert_one_to_float(degrees)
|
659
659
|
@gc.skewX(degrees)
|
660
660
|
@ry = Math.tan(GraphicContext.degrees_to_radians(degrees))
|
661
661
|
concat_matrix()
|
@@ -663,7 +663,7 @@ module Magick::RVG::Utility
|
|
663
663
|
end
|
664
664
|
|
665
665
|
def skewY(degrees)
|
666
|
-
degrees = RVG.convert_one_to_float(degrees)
|
666
|
+
degrees = Magick::RVG.convert_one_to_float(degrees)
|
667
667
|
@gc.skewY(degrees)
|
668
668
|
@rx = Math.tan(GraphicContext.degrees_to_radians(degrees))
|
669
669
|
concat_matrix()
|
@@ -671,7 +671,7 @@ module Magick::RVG::Utility
|
|
671
671
|
end
|
672
672
|
|
673
673
|
def stroke_width(width)
|
674
|
-
width = RVG.convert_one_to_float(width)
|
674
|
+
width = Magick::RVG.convert_one_to_float(width)
|
675
675
|
@gc.stroke_width(width)
|
676
676
|
@shadow[-1].stroke_width = width
|
677
677
|
nil
|
@@ -706,7 +706,7 @@ module Magick::RVG::Utility
|
|
706
706
|
end
|
707
707
|
|
708
708
|
def translate(tx, ty)
|
709
|
-
tx, ty = RVG.convert_to_float(tx, ty)
|
709
|
+
tx, ty = Magick::RVG.convert_to_float(tx, ty)
|
710
710
|
@gc.translate(tx, ty)
|
711
711
|
@tx, @ty = tx, ty
|
712
712
|
concat_matrix()
|
@@ -714,7 +714,7 @@ module Magick::RVG::Utility
|
|
714
714
|
end
|
715
715
|
|
716
716
|
def word_spacing(value)
|
717
|
-
@text_attrs.word_spacing = RVG.convert_one_to_float(value)
|
717
|
+
@text_attrs.word_spacing = Magick::RVG.convert_one_to_float(value)
|
718
718
|
nil
|
719
719
|
end
|
720
720
|
|
data/lib/rvg/paint.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# $Id: paint.rb,v 1.
|
2
|
+
# $Id: paint.rb,v 1.2 2005/07/15 20:48:50 rmagick Exp $
|
3
3
|
# Copyright (C) 2005 Timothy P. Hunter
|
4
4
|
#++
|
5
5
|
# Defines paint server classes.
|
@@ -28,7 +28,7 @@ class Magick::RVG
|
|
28
28
|
# referring to them with #use.
|
29
29
|
def initialize(width=0, height=0, x=0, y=0)
|
30
30
|
super()
|
31
|
-
@width, @height, @x, @y = RVG.convert_to_float(width, height, x, y)
|
31
|
+
@width, @height, @x, @y = Magick::RVG.convert_to_float(width, height, x, y)
|
32
32
|
@content = Content.new
|
33
33
|
yield(self) if block_given?
|
34
34
|
end
|
data/lib/rvg/rvg.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--############################################################################
|
2
|
-
# $Id: rvg.rb,v 1.
|
2
|
+
# $Id: rvg.rb,v 1.5 2005/07/15 21:11:38 rmagick Exp $
|
3
3
|
#
|
4
4
|
# Copyright (C) 2005 by Timothy P. Hunter
|
5
5
|
#
|
@@ -61,32 +61,32 @@ class Magick::RVG
|
|
61
61
|
# else, combine it with the background_fill_opacity.
|
62
62
|
def bgfill()
|
63
63
|
if @background_fill.nil?
|
64
|
-
color = Pixel.new(0,0,0,TransparentOpacity)
|
64
|
+
color = Magick::Pixel.new(0,0,0,Magick::TransparentOpacity)
|
65
65
|
else
|
66
66
|
color = @background_fill
|
67
|
-
color.opacity = (1.0 - @background_fill_opacity) *
|
67
|
+
color.opacity = (1.0 - @background_fill_opacity) * Magick::TransparentOpacity
|
68
68
|
end
|
69
69
|
return color
|
70
70
|
end
|
71
71
|
|
72
72
|
def new_canvas
|
73
73
|
if @background_pattern
|
74
|
-
canvas =
|
74
|
+
canvas = Magick::Image.new(@width, @height, @background_pattern)
|
75
75
|
elsif @background_image
|
76
76
|
if @width != @background_image.columns || @height != @background_image.rows
|
77
77
|
canvas = case @background_position
|
78
78
|
when :scaled
|
79
79
|
@background_image.resize(@width, @height)
|
80
80
|
when :tiled
|
81
|
-
|
81
|
+
Magick::Image.new(@width, @height, Magick::TextureFill.new(@background_image))
|
82
82
|
when :fit
|
83
83
|
width, height = @width, @height
|
84
84
|
bgcolor = bgfill()
|
85
|
-
@background_image.change_geometry(Geometry.new(width, height)) do |new_cols, new_rows|
|
85
|
+
@background_image.change_geometry(Magick::Geometry.new(width, height)) do |new_cols, new_rows|
|
86
86
|
bg_image = @background_image.resize(new_cols, new_rows)
|
87
87
|
if bg_image.columns != width || bg_image.rows != height
|
88
|
-
bg =
|
89
|
-
bg_image = bg.composite!(bg_image, CenterGravity, OverCompositeOp)
|
88
|
+
bg = Magick::Image.new(width, height) { self.background_color = bgcolor }
|
89
|
+
bg_image = bg.composite!(bg_image, Magick::CenterGravity, Magick::OverCompositeOp)
|
90
90
|
end
|
91
91
|
bg_image
|
92
92
|
end
|
@@ -96,7 +96,7 @@ class Magick::RVG
|
|
96
96
|
end
|
97
97
|
else
|
98
98
|
bgcolor = bgfill()
|
99
|
-
canvas =
|
99
|
+
canvas = Magick::Image.new(Integer(@width), Integer(@height)) { self.background_color = bgcolor }
|
100
100
|
end
|
101
101
|
canvas[:desc] = @desc if @desc
|
102
102
|
canvas[:title] = @title if @title
|
@@ -139,7 +139,7 @@ class Magick::RVG
|
|
139
139
|
# Sets an image to use as the canvas background. See background_position= for layout options.
|
140
140
|
def background_image=(bg_image)
|
141
141
|
warn "background_image= has no effect in nested RVG objects" if @nested
|
142
|
-
if bg_image && ! bg_image.kind_of?(
|
142
|
+
if bg_image && ! bg_image.kind_of?(Magick::Image)
|
143
143
|
raise ArgumentError, "background image must be an Image (got #{bg_image.class})"
|
144
144
|
end
|
145
145
|
@background_image = bg_image
|
@@ -172,9 +172,9 @@ class Magick::RVG
|
|
172
172
|
# The default fill is "none", that is, transparent black.
|
173
173
|
def background_fill=(color)
|
174
174
|
warn "background_fill= has no effect in nested RVG objects" if @nested
|
175
|
-
if ! color.kind_of?(Pixel)
|
175
|
+
if ! color.kind_of?(Magick::Pixel)
|
176
176
|
begin
|
177
|
-
@background_fill = Pixel.from_color(color)
|
177
|
+
@background_fill = Magick::Pixel.from_color(color)
|
178
178
|
rescue Magick::ImageMagickError
|
179
179
|
raise ArgumentError, "unknown color `#{color}'"
|
180
180
|
rescue TypeError
|
@@ -247,7 +247,7 @@ class Magick::RVG
|
|
247
247
|
@height = rh if rh
|
248
248
|
end
|
249
249
|
|
250
|
-
# Used by
|
250
|
+
# Used by Magick::Embellishable.rvg to set non-0 x- and y-coordinates
|
251
251
|
def corner(x, y) #:nodoc:
|
252
252
|
@nested = true
|
253
253
|
@x, @y = Float(x), Float(y)
|
data/lib/rvg/text.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#--
|
2
|
-
# $Id: text.rb,v 1.
|
2
|
+
# $Id: text.rb,v 1.3 2005/07/15 20:48:50 rmagick Exp $
|
3
3
|
# Copyright (C) 2005 Timothy P. Hunter
|
4
4
|
#++
|
5
5
|
# Text-related classes
|
@@ -36,14 +36,14 @@ class Magick::RVG
|
|
36
36
|
|
37
37
|
# Add <tt>x</tt> and <tt>y</tt> to the current text position.
|
38
38
|
def d(x, y=0)
|
39
|
-
@dx, @dy = RVG.convert_to_float(x, y)
|
39
|
+
@dx, @dy = Magick::RVG.convert_to_float(x, y)
|
40
40
|
yield(self) if block_given?
|
41
41
|
self
|
42
42
|
end
|
43
43
|
|
44
44
|
# Rotate the text about the current text position.
|
45
45
|
def rotate(degrees)
|
46
|
-
@rotation = RVG.convert_to_float(degrees)[0]
|
46
|
+
@rotation = Magick::RVG.convert_to_float(degrees)[0]
|
47
47
|
yield(self) if block_given?
|
48
48
|
self
|
49
49
|
end
|
@@ -106,7 +106,7 @@ class Magick::RVG
|
|
106
106
|
include TextLink
|
107
107
|
|
108
108
|
def initialize(obj, x, y, parent)
|
109
|
-
@x, @y = RVG.convert_to_float(x, y, :allow_nil)
|
109
|
+
@x, @y = Magick::RVG.convert_to_float(x, y, :allow_nil)
|
110
110
|
super(nil)
|
111
111
|
@tspans << obj
|
112
112
|
@parent = parent
|
@@ -125,7 +125,7 @@ class Magick::RVG
|
|
125
125
|
#
|
126
126
|
# Tspan objects can contain Tspan objects.
|
127
127
|
def initialize(text=nil, x=nil, y=nil, &block)
|
128
|
-
@x, @y = RVG.convert_to_float(x, y, :allow_nil)
|
128
|
+
@x, @y = Magick::RVG.convert_to_float(x, y, :allow_nil)
|
129
129
|
super(text, &block)
|
130
130
|
end
|
131
131
|
|
@@ -147,7 +147,7 @@ class Magick::RVG
|
|
147
147
|
# t.tspan("Blue text").styles(:fill=>'blue')
|
148
148
|
# end
|
149
149
|
def initialize(x=0, y=0, text=nil, &block)
|
150
|
-
@cx, @cy = RVG.convert_to_float(x, y)
|
150
|
+
@cx, @cy = Magick::RVG.convert_to_float(x, y)
|
151
151
|
super(text, &block)
|
152
152
|
end
|
153
153
|
|