rmagick 1.14.1 → 1.15.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.

Files changed (66) hide show
  1. data/ChangeLog +22 -0
  2. data/README.html +11 -63
  3. data/README.txt +8 -56
  4. data/configure +214 -787
  5. data/configure.ac +22 -24
  6. data/doc/comtasks.html +2 -2
  7. data/doc/constants.html +5 -6
  8. data/doc/draw.html +33 -14
  9. data/doc/ex/clip_path.rb +3 -0
  10. data/doc/ex/path.rb +1 -1
  11. data/doc/ex/polaroid.rb +23 -0
  12. data/doc/ex/tspan01.rb +2 -2
  13. data/doc/ex/tspan02.rb +2 -2
  14. data/doc/ex/tspan03.rb +3 -3
  15. data/doc/ex/wet_floor.rb +54 -0
  16. data/doc/ilist.html +83 -4
  17. data/doc/image1.html +4 -5
  18. data/doc/image2.html +395 -266
  19. data/doc/image3.html +104 -8
  20. data/doc/imageattrs.html +2 -2
  21. data/doc/imusage.html +2 -2
  22. data/doc/index.html +22 -18
  23. data/doc/info.html +28 -6
  24. data/doc/magick.html +125 -4
  25. data/doc/optequiv.html +196 -21
  26. data/doc/rvg.html +2 -2
  27. data/doc/rvgclip.html +2 -2
  28. data/doc/rvggroup.html +2 -2
  29. data/doc/rvgimage.html +2 -2
  30. data/doc/rvgpattern.html +2 -2
  31. data/doc/rvgshape.html +2 -2
  32. data/doc/rvgstyle.html +2 -2
  33. data/doc/rvgtext.html +2 -2
  34. data/doc/rvgtspan.html +2 -2
  35. data/doc/rvgtut.html +3 -3
  36. data/doc/rvguse.html +2 -2
  37. data/doc/rvgxform.html +2 -2
  38. data/doc/struct.html +2 -2
  39. data/doc/usage.html +26 -5
  40. data/ext/RMagick/MANIFEST +3 -1
  41. data/ext/RMagick/rmagick.h +46 -12
  42. data/ext/RMagick/rmagick_config.h.in +12 -2
  43. data/ext/RMagick/rmdraw.c +202 -62
  44. data/ext/RMagick/rmfill.c +36 -36
  45. data/ext/RMagick/rmilist.c +75 -31
  46. data/ext/RMagick/rmimage.c +640 -323
  47. data/ext/RMagick/rminfo.c +76 -15
  48. data/ext/RMagick/rmmain.c +107 -30
  49. data/ext/RMagick/rmutil.c +97 -68
  50. data/lib/RMagick.rb +11 -11
  51. data/lib/rvg/clippath.rb +38 -36
  52. data/lib/rvg/container.rb +120 -118
  53. data/lib/rvg/deep_equal.rb +44 -42
  54. data/lib/rvg/describable.rb +49 -47
  55. data/lib/rvg/embellishable.rb +399 -397
  56. data/lib/rvg/misc.rb +613 -603
  57. data/lib/rvg/paint.rb +38 -36
  58. data/lib/rvg/pathdata.rb +124 -122
  59. data/lib/rvg/rvg.rb +202 -198
  60. data/lib/rvg/stretchable.rb +132 -130
  61. data/lib/rvg/stylable.rb +101 -99
  62. data/lib/rvg/text.rb +173 -171
  63. data/lib/rvg/transformable.rb +120 -118
  64. data/lib/rvg/units.rb +60 -58
  65. data/rmagick.gemspec +1 -1
  66. metadata +5 -3
@@ -1,154 +1,156 @@
1
1
  #--
2
- # $Id: stretchable.rb,v 1.3 2006/07/18 22:24:59 rmagick Exp $
3
- # Copyright (C) 2006 Timothy P. Hunter
2
+ # $Id: stretchable.rb,v 1.4 2007/01/20 17:39:50 rmagick Exp $
3
+ # Copyright (C) 2007 Timothy P. Hunter
4
4
  #++
5
5
 
6
- class Magick::RVG
7
-
8
- module PreserveAspectRatio
9
- #--
10
- # Included in Stretchable module and Image class
11
- #++
12
- # Specifies how the image within a viewport should be scaled.
13
- # [+align+] a combination of 'xMin', 'xMid', or 'xMax', followed by
14
- # 'YMin', 'YMid', or 'YMax'
15
- # [+meet_or_slice+] one of 'meet' or 'slice'
16
- def preserve_aspect_ratio(align, meet_or_slice='meet')
17
- @align = align.to_s
18
- if @align != 'none'
19
- m = /\A(xMin|xMid|xMax)(YMin|YMid|YMax)\z/.match(@align)
20
- raise(ArgumentError, "unknown alignment specifier: #{@align}") unless m
21
- end
6
+ module Magick
7
+ class RVG
8
+
9
+ module PreserveAspectRatio
10
+ #--
11
+ # Included in Stretchable module and Image class
12
+ #++
13
+ # Specifies how the image within a viewport should be scaled.
14
+ # [+align+] a combination of 'xMin', 'xMid', or 'xMax', followed by
15
+ # 'YMin', 'YMid', or 'YMax'
16
+ # [+meet_or_slice+] one of 'meet' or 'slice'
17
+ def preserve_aspect_ratio(align, meet_or_slice='meet')
18
+ @align = align.to_s
19
+ if @align != 'none'
20
+ m = /\A(xMin|xMid|xMax)(YMin|YMid|YMax)\z/.match(@align)
21
+ raise(ArgumentError, "unknown alignment specifier: #{@align}") unless m
22
+ end
22
23
 
23
- if meet_or_slice
24
- meet_or_slice = meet_or_slice.to_s.downcase
25
- if meet_or_slice == 'meet' || meet_or_slice == 'slice'
26
- @meet_or_slice = meet_or_slice
27
- else
28
- raise(ArgumentError, "specifier must be `meet' or `slice' (got #{meet_or_slice})")
24
+ if meet_or_slice
25
+ meet_or_slice = meet_or_slice.to_s.downcase
26
+ if meet_or_slice == 'meet' || meet_or_slice == 'slice'
27
+ @meet_or_slice = meet_or_slice
28
+ else
29
+ raise(ArgumentError, "specifier must be `meet' or `slice' (got #{meet_or_slice})")
30
+ end
29
31
  end
32
+ yield(self) if block_given?
33
+ self
30
34
  end
31
- yield(self) if block_given?
32
- self
33
- end
34
- end # module PreserveAspectRatio
35
+ end # module PreserveAspectRatio
35
36
 
36
37
 
37
- # The methods in this module describe the user-coordinate space.
38
- # Only RVG objects are stretchable.
39
- module Stretchable
38
+ # The methods in this module describe the user-coordinate space.
39
+ # Only RVG objects are stretchable.
40
+ module Stretchable
40
41
 
41
- private
42
- # Scale to fit
43
- def set_viewbox_none(width, height)
44
- sx, sy = 1.0, 1.0
42
+ private
43
+ # Scale to fit
44
+ def set_viewbox_none(width, height)
45
+ sx, sy = 1.0, 1.0
45
46
 
46
- if @vbx_width
47
- sx = width / @vbx_width
47
+ if @vbx_width
48
+ sx = width / @vbx_width
49
+ end
50
+ if @vbx_height
51
+ sy = height / @vbx_height
52
+ end
53
+
54
+ return [sx, sy]
48
55
  end
49
- if @vbx_height
50
- sy = height / @vbx_height
56
+
57
+ # Use align attribute to compute x- and y-offset from viewport's upper-left corner.
58
+ def align_to_viewport(width, height, sx, sy)
59
+ tx = case @align
60
+ when /\AxMin/
61
+ 0
62
+ when NilClass, /\AxMid/
63
+ (width - @vbx_width*sx) / 2.0
64
+ when /\AxMax/
65
+ width - @vbx_width*sx
66
+ end
67
+
68
+ ty = case @align
69
+ when /YMin\z/
70
+ 0
71
+ when NilClass, /YMid\z/
72
+ (height - @vbx_height*sy) / 2.0
73
+ when /YMax\z/
74
+ height - @vbx_height*sy
75
+ end
76
+ return [tx, ty]
51
77
  end
52
78
 
53
- return [sx, sy]
54
- end
55
-
56
- # Use align attribute to compute x- and y-offset from viewport's upper-left corner.
57
- def align_to_viewport(width, height, sx, sy)
58
- tx = case @align
59
- when /\AxMin/
60
- 0
61
- when NilClass, /\AxMid/
62
- (width - @vbx_width*sx) / 2.0
63
- when /\AxMax/
64
- width - @vbx_width*sx
79
+ # Scale to smaller viewbox dimension
80
+ def set_viewbox_meet(width, height)
81
+ sx = sy = [width / @vbx_width, height / @vbx_height].min
82
+ return [sx, sy]
65
83
  end
66
84
 
67
- ty = case @align
68
- when /YMin\z/
69
- 0
70
- when NilClass, /YMid\z/
71
- (height - @vbx_height*sy) / 2.0
72
- when /YMax\z/
73
- height - @vbx_height*sy
85
+ # Scale to larger viewbox dimension
86
+ def set_viewbox_slice(width, height)
87
+ sx = sy = [width / @vbx_width, height / @vbx_height].max
88
+ return [sx, sy]
74
89
  end
75
- return [tx, ty]
76
- end
77
-
78
- # Scale to smaller viewbox dimension
79
- def set_viewbox_meet(width, height)
80
- sx = sy = [width / @vbx_width, height / @vbx_height].min
81
- return [sx, sy]
82
- end
83
-
84
- # Scale to larger viewbox dimension
85
- def set_viewbox_slice(width, height)
86
- sx = sy = [width / @vbx_width, height / @vbx_height].max
87
- return [sx, sy]
88
- end
89
-
90
- # Establish the viewbox as necessary
91
- def add_viewbox_primitives(width, height, gc)
92
- @vbx_width ||= width
93
- @vbx_height ||= height
94
- @vbx_x ||= 0.0
95
- @vbx_y ||= 0.0
96
-
97
- if @align == 'none'
98
- sx, sy = set_viewbox_none(width, height)
99
- tx, ty = 0, 0
100
- elsif @meet_or_slice == 'meet'
101
- sx, sy = set_viewbox_meet(width, height)
102
- tx, ty = align_to_viewport(width, height, sx, sy)
103
- else
104
- sx, sy = set_viewbox_slice(width, height)
105
- tx, ty = align_to_viewport(width, height, sx, sy)
90
+
91
+ # Establish the viewbox as necessary
92
+ def add_viewbox_primitives(width, height, gc)
93
+ @vbx_width ||= width
94
+ @vbx_height ||= height
95
+ @vbx_x ||= 0.0
96
+ @vbx_y ||= 0.0
97
+
98
+ if @align == 'none'
99
+ sx, sy = set_viewbox_none(width, height)
100
+ tx, ty = 0, 0
101
+ elsif @meet_or_slice == 'meet'
102
+ sx, sy = set_viewbox_meet(width, height)
103
+ tx, ty = align_to_viewport(width, height, sx, sy)
104
+ else
105
+ sx, sy = set_viewbox_slice(width, height)
106
+ tx, ty = align_to_viewport(width, height, sx, sy)
107
+ end
108
+
109
+ # Establish clipping path around the current viewport
110
+ name = __id__.to_s
111
+ gc.define_clip_path(name) do
112
+ gc.path("M0,0 l#{width},0 l0,#{height} l-#{width},0 l0,-#{height}z")
113
+ end
114
+
115
+ gc.clip_path(name)
116
+ # Add a non-scaled translation if meet or slice
117
+ gc.translate(tx, ty) if (tx.abs > 1.0e-10 || ty.abs > 1.0e-10)
118
+ # Scale viewbox as necessary
119
+ gc.scale(sx, sy) if (sx != 1.0 || sy != 1.0)
120
+ # Add a scaled translation if non-0 origin
121
+ gc.translate(-@vbx_x, -@vbx_y) if (@vbx_x.abs != 0.0 || @vbx_y.abs != 0)
106
122
  end
107
123
 
108
- # Establish clipping path around the current viewport
109
- name = __id__.to_s
110
- gc.define_clip_path(name) do
111
- gc.path("M0,0 l#{width},0 l0,#{height} l-#{width},0 l0,-#{height}z")
124
+ def initialize(*args, &block)
125
+ super()
126
+ @vbx_x, @vbx_y, @vbx_width, @vbx_height = nil
127
+ @meet_or_slice = 'meet'
128
+ @align = nil
112
129
  end
113
130
 
114
- gc.clip_path(name)
115
- # Add a non-scaled translation if meet or slice
116
- gc.translate(tx, ty) if (tx.abs > 1.0e-10 || ty.abs > 1.0e-10)
117
- # Scale viewbox as necessary
118
- gc.scale(sx, sy) if (sx != 1.0 || sy != 1.0)
119
- # Add a scaled translation if non-0 origin
120
- gc.translate(-@vbx_x, -@vbx_y) if (@vbx_x.abs != 0.0 || @vbx_y.abs != 0)
121
- end
122
-
123
- def initialize(*args, &block)
124
- super()
125
- @vbx_x, @vbx_y, @vbx_width, @vbx_height = nil
126
- @meet_or_slice = 'meet'
127
- @align = nil
128
- end
129
-
130
- public
131
- include PreserveAspectRatio
132
-
133
- # Describe a user coordinate system to be imposed on the viewbox.
134
- # The arguments must be numbers and the +width+ and +height+
135
- # arguments must be positive.
136
- def viewbox(x, y, width, height)
137
- begin
138
- @vbx_x = Float(x)
139
- @vbx_y = Float(y)
140
- @vbx_width = Float(width)
141
- @vbx_height = Float(height)
142
- rescue ArgumentError
143
- raise ArgumentError, "arguments must be convertable to float (got #{x.class}, #{y.class}, #{width.class}, #{height.class})"
131
+ public
132
+ include PreserveAspectRatio
133
+
134
+ # Describe a user coordinate system to be imposed on the viewbox.
135
+ # The arguments must be numbers and the +width+ and +height+
136
+ # arguments must be positive.
137
+ def viewbox(x, y, width, height)
138
+ begin
139
+ @vbx_x = Float(x)
140
+ @vbx_y = Float(y)
141
+ @vbx_width = Float(width)
142
+ @vbx_height = Float(height)
143
+ rescue ArgumentError
144
+ raise ArgumentError, "arguments must be convertable to float (got #{x.class}, #{y.class}, #{width.class}, #{height.class})"
145
+ end
146
+ raise(ArgumentError, "viewbox width must be > 0 (#{width} given)") unless width >= 0
147
+ raise(ArgumentError, "viewbox height must be > 0 (#{height} given)") unless height >= 0
148
+ yield(self) if block_given?
149
+ self
144
150
  end
145
- raise(ArgumentError, "viewbox width must be > 0 (#{width} given)") unless width >= 0
146
- raise(ArgumentError, "viewbox height must be > 0 (#{height} given)") unless height >= 0
147
- yield(self) if block_given?
148
- self
149
- end
150
151
 
151
- end # module Stretchable
152
+ end # module Stretchable
152
153
 
153
- end # class Magick::RVG
154
+ end # class RVG
155
+ end # module Magick
154
156
 
@@ -1,116 +1,118 @@
1
1
  #--
2
- # $Id: stylable.rb,v 1.2 2005/12/31 14:41:04 rmagick Exp $
3
- # Copyright (C) 2006 Timothy P. Hunter
2
+ # $Id: stylable.rb,v 1.4 2007/01/20 17:49:57 rmagick Exp $
3
+ # Copyright (C) 2007 Timothy P. Hunter
4
4
  #++
5
5
 
6
- class Magick::RVG
7
-
8
- #:stopdoc:
9
- STYLES = [:clip_path, :clip_rule, :fill, :fill_opacity, :fill_rule, :font,
10
- :font_family, :font_size, :font_stretch, :font_style, :font_weight,
11
- :opacity, :stroke, :stroke_dasharray, :stroke_dashoffset, :stroke_linecap,
12
- :stroke_linejoin, :stroke_miterlimit, :stroke_opacity, :stroke_width,
13
- :text_anchor, :text_decoration,
14
- :glyph_orientation_vertical, :glyph_orientation_horizontal,
15
- :letter_spacing, :word_spacing, :baseline_shift, :writing_mode]
16
-
17
- Styles = Struct.new(*STYLES)
18
-
19
- # Styles is a Struct class with a couple of extra methods
20
- class Styles
21
-
22
- def set(styles)
23
- begin
24
- styles.each_pair do |style, value|
25
- begin
26
- self[style] = value
27
- rescue NoMethodError
28
- raise ArgumentError, "unknown style `#{style}'"
6
+ module Magick
7
+ class RVG
8
+
9
+ #:stopdoc:
10
+ STYLES = [:clip_path, :clip_rule, :fill, :fill_opacity, :fill_rule, :font,
11
+ :font_family, :font_size, :font_stretch, :font_style, :font_weight,
12
+ :opacity, :stroke, :stroke_dasharray, :stroke_dashoffset, :stroke_linecap,
13
+ :stroke_linejoin, :stroke_miterlimit, :stroke_opacity, :stroke_width,
14
+ :text_anchor, :text_decoration,
15
+ :glyph_orientation_vertical, :glyph_orientation_horizontal,
16
+ :letter_spacing, :word_spacing, :baseline_shift, :writing_mode]
17
+
18
+ Styles = Struct.new(*STYLES)
19
+
20
+ # Styles is a Struct class with a couple of extra methods
21
+ class Styles
22
+
23
+ def set(styles)
24
+ begin
25
+ styles.each_pair do |style, value|
26
+ begin
27
+ self[style] = value
28
+ rescue NoMethodError
29
+ raise ArgumentError, "unknown style `#{style}'"
30
+ end
29
31
  end
32
+ rescue NoMethodError
33
+ raise ArgumentError, "style arguments must be in the form `style => value'"
30
34
  end
31
- rescue NoMethodError
32
- raise ArgumentError, "style arguments must be in the form `style => value'"
35
+ self
33
36
  end
34
- self
35
- end
36
37
 
37
- # Iterate over the style names. Yield for each style that has a value.
38
- def each_value
39
- each_pair do |style, value|
40
- yield(style, value) if value
38
+ # Iterate over the style names. Yield for each style that has a value.
39
+ def each_value
40
+ each_pair do |style, value|
41
+ yield(style, value) if value
42
+ end
41
43
  end
42
- end
43
44
 
44
- # The "usual" deep_copy method doesn't copy a Struct correctly.
45
- def deep_copy(h=nil)
46
- copy = Styles.new
47
- each_pair { |style, value| copy[style] = value }
48
- return copy
49
- end
45
+ # The "usual" deep_copy method doesn't copy a Struct correctly.
46
+ def deep_copy(h=nil)
47
+ copy = Styles.new
48
+ each_pair { |style, value| copy[style] = value }
49
+ return copy
50
+ end
50
51
 
51
- end # class Styles
52
+ end # class Styles
52
53
 
53
- #:startdoc:
54
+ #:startdoc:
54
55
 
55
- # This module is mixed into classes that can have styles.
56
- module Stylable
56
+ # This module is mixed into classes that can have styles.
57
+ module Stylable
57
58
 
58
- private
59
+ private
59
60
 
60
- # For each style that has a value, add a style primitive to the gc.
61
- # Use splat to splat out Array arguments such as stroke_dasharray.
62
- def add_style_primitives(gc)
63
- @styles.each_value do |style, value|
64
- if value.respond_to? :add_primitives
65
- value.add_primitives(gc, style)
66
- else
67
- gc.__send__(style, *value)
61
+ # For each style that has a value, add a style primitive to the gc.
62
+ # Use splat to splat out Array arguments such as stroke_dasharray.
63
+ def add_style_primitives(gc)
64
+ @styles.each_value do |style, value|
65
+ if value.respond_to? :add_primitives
66
+ value.add_primitives(gc, style)
67
+ else
68
+ gc.__send__(style, *value)
69
+ end
68
70
  end
69
71
  end
70
- end
71
-
72
- def initialize
73
- super
74
- @styles = Styles.new
75
- end
76
-
77
- public
78
-
79
- # This method can be used with any RVG, Group, Use, Text, or
80
- # shape object. The argument is a hash. The style names are
81
- # the hash keys. The style names and values are:
82
- # [:clip_path] clipping path defined by clip_path
83
- # [:clip_rule] 'evenodd' or 'nozero'
84
- # [:fill] color name
85
- # [:fill_opacity] the fill opacity, 0.0<=N<=1.0
86
- # [:fill_rule] 'evenodd' or 'nozero'
87
- # [:font] font name or font file name
88
- # [:font_family] font family name, ex. 'serif'
89
- # [:font_size] font size in points
90
- # [:font_stretch] 'normal','ultra_condensed','extra_condensed',
91
- # 'condensed','semi_condensed','semi_expanded',
92
- # 'expanded','extra_expanded','ultra_expanded'
93
- # [:font_style] 'normal','italic','oblique'
94
- # [:font_weight] 'normal','bold','bolder','lighter', or
95
- # a multiple of 100 between 100 and 900.
96
- # [:opacity] both fill and stroke opacity, 0.0<=N<=1.0
97
- # [:stroke] color name
98
- # [:stroke_dasharray] dash pattern (Array)
99
- # [:stroke_dashoffset] initial distance into dash pattern
100
- # [:stroke_linecap] 'butt', 'round', 'square'
101
- # [:stroke_linejoin] 'miter', 'round', 'bevel'
102
- # [:stroke_miterlimit] miter length constraint
103
- # [:stroke_opacity] the stroke opacity, 0.0<=N<=1.0
104
- # [:stroke_width] stroke width
105
- # [:text_anchor] 'start','middle','end'
106
- # [:text_decoration] 'none','underline','overline','line_through'
107
- def styles(styles)
108
- @styles.set(styles)
109
- yield(self) if block_given?
110
- self
111
- end
112
-
113
- end # module Stylable
114
-
115
- end # class Magick::RVG
72
+
73
+ def initialize
74
+ super
75
+ @styles = Styles.new
76
+ end
77
+
78
+ public
79
+
80
+ # This method can be used with any RVG, Group, Use, Text, or
81
+ # shape object. The argument is a hash. The style names are
82
+ # the hash keys. The style names and values are:
83
+ # [:clip_path] clipping path defined by clip_path
84
+ # [:clip_rule] 'evenodd' or 'nozero'
85
+ # [:fill] color name
86
+ # [:fill_opacity] the fill opacity, 0.0<=N<=1.0
87
+ # [:fill_rule] 'evenodd' or 'nozero'
88
+ # [:font] font name or font file name
89
+ # [:font_family] font family name, ex. 'serif'
90
+ # [:font_size] font size in points
91
+ # [:font_stretch] 'normal','ultra_condensed','extra_condensed',
92
+ # 'condensed','semi_condensed','semi_expanded',
93
+ # 'expanded','extra_expanded','ultra_expanded'
94
+ # [:font_style] 'normal','italic','oblique'
95
+ # [:font_weight] 'normal','bold','bolder','lighter', or
96
+ # a multiple of 100 between 100 and 900.
97
+ # [:opacity] both fill and stroke opacity, 0.0<=N<=1.0
98
+ # [:stroke] color name
99
+ # [:stroke_dasharray] dash pattern (Array)
100
+ # [:stroke_dashoffset] initial distance into dash pattern
101
+ # [:stroke_linecap] 'butt', 'round', 'square'
102
+ # [:stroke_linejoin] 'miter', 'round', 'bevel'
103
+ # [:stroke_miterlimit] miter length constraint
104
+ # [:stroke_opacity] the stroke opacity, 0.0<=N<=1.0
105
+ # [:stroke_width] stroke width
106
+ # [:text_anchor] 'start','middle','end'
107
+ # [:text_decoration] 'none','underline','overline','line_through'
108
+ def styles(styles)
109
+ @styles.set(styles)
110
+ yield(self) if block_given?
111
+ self
112
+ end
113
+
114
+ end # module Stylable
115
+
116
+ end # class RVG
117
+ end # module Magick
116
118