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.
- data/ChangeLog +22 -0
- data/README.html +11 -63
- data/README.txt +8 -56
- data/configure +214 -787
- data/configure.ac +22 -24
- data/doc/comtasks.html +2 -2
- data/doc/constants.html +5 -6
- data/doc/draw.html +33 -14
- data/doc/ex/clip_path.rb +3 -0
- data/doc/ex/path.rb +1 -1
- data/doc/ex/polaroid.rb +23 -0
- data/doc/ex/tspan01.rb +2 -2
- data/doc/ex/tspan02.rb +2 -2
- data/doc/ex/tspan03.rb +3 -3
- data/doc/ex/wet_floor.rb +54 -0
- data/doc/ilist.html +83 -4
- data/doc/image1.html +4 -5
- data/doc/image2.html +395 -266
- data/doc/image3.html +104 -8
- data/doc/imageattrs.html +2 -2
- data/doc/imusage.html +2 -2
- data/doc/index.html +22 -18
- data/doc/info.html +28 -6
- data/doc/magick.html +125 -4
- data/doc/optequiv.html +196 -21
- data/doc/rvg.html +2 -2
- data/doc/rvgclip.html +2 -2
- data/doc/rvggroup.html +2 -2
- data/doc/rvgimage.html +2 -2
- data/doc/rvgpattern.html +2 -2
- data/doc/rvgshape.html +2 -2
- data/doc/rvgstyle.html +2 -2
- data/doc/rvgtext.html +2 -2
- data/doc/rvgtspan.html +2 -2
- data/doc/rvgtut.html +3 -3
- data/doc/rvguse.html +2 -2
- data/doc/rvgxform.html +2 -2
- data/doc/struct.html +2 -2
- data/doc/usage.html +26 -5
- data/ext/RMagick/MANIFEST +3 -1
- data/ext/RMagick/rmagick.h +46 -12
- data/ext/RMagick/rmagick_config.h.in +12 -2
- data/ext/RMagick/rmdraw.c +202 -62
- data/ext/RMagick/rmfill.c +36 -36
- data/ext/RMagick/rmilist.c +75 -31
- data/ext/RMagick/rmimage.c +640 -323
- data/ext/RMagick/rminfo.c +76 -15
- data/ext/RMagick/rmmain.c +107 -30
- data/ext/RMagick/rmutil.c +97 -68
- data/lib/RMagick.rb +11 -11
- data/lib/rvg/clippath.rb +38 -36
- data/lib/rvg/container.rb +120 -118
- data/lib/rvg/deep_equal.rb +44 -42
- data/lib/rvg/describable.rb +49 -47
- data/lib/rvg/embellishable.rb +399 -397
- data/lib/rvg/misc.rb +613 -603
- data/lib/rvg/paint.rb +38 -36
- data/lib/rvg/pathdata.rb +124 -122
- data/lib/rvg/rvg.rb +202 -198
- data/lib/rvg/stretchable.rb +132 -130
- data/lib/rvg/stylable.rb +101 -99
- data/lib/rvg/text.rb +173 -171
- data/lib/rvg/transformable.rb +120 -118
- data/lib/rvg/units.rb +60 -58
- data/rmagick.gemspec +1 -1
- metadata +5 -3
data/lib/RMagick.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# $Id: RMagick.rb,v 1.
|
1
|
+
# $Id: RMagick.rb,v 1.51 2007/01/20 23:13:50 rmagick Exp $
|
2
2
|
#==============================================================================
|
3
|
-
# Copyright (C)
|
3
|
+
# Copyright (C) 2007 by Timothy P. Hunter
|
4
4
|
# Name: RMagick.rb
|
5
5
|
# Author: Tim Hunter
|
6
6
|
# Purpose: Extend Ruby to interface with ImageMagick.
|
@@ -108,25 +108,25 @@ class Draw
|
|
108
108
|
LeftAlign.to_i => 'left',
|
109
109
|
RightAlign.to_i => 'right',
|
110
110
|
CenterAlign.to_i => 'center'
|
111
|
-
}
|
111
|
+
}.freeze
|
112
112
|
ANCHOR_TYPE_NAMES = {
|
113
113
|
StartAnchor.to_i => 'start',
|
114
114
|
MiddleAnchor.to_i => 'middle',
|
115
115
|
EndAnchor.to_i => 'end'
|
116
|
-
}
|
116
|
+
}.freeze
|
117
117
|
DECORATION_TYPE_NAMES = {
|
118
118
|
NoDecoration.to_i => 'none',
|
119
119
|
UnderlineDecoration.to_i => 'underline',
|
120
120
|
OverlineDecoration.to_i => 'overline',
|
121
121
|
LineThroughDecoration.to_i => 'line-through'
|
122
|
-
}
|
122
|
+
}.freeze
|
123
123
|
FONT_WEIGHT_NAMES = {
|
124
124
|
AnyWeight.to_i => 'all',
|
125
125
|
NormalWeight.to_i => 'normal',
|
126
126
|
BoldWeight.to_i => 'bold',
|
127
127
|
BolderWeight.to_i => 'bolder',
|
128
128
|
LighterWeight.to_i => 'lighter',
|
129
|
-
}
|
129
|
+
}.freeze
|
130
130
|
GRAVITY_NAMES = {
|
131
131
|
NorthWestGravity.to_i => 'northwest',
|
132
132
|
NorthGravity.to_i => 'north',
|
@@ -137,14 +137,14 @@ class Draw
|
|
137
137
|
SouthWestGravity.to_i => 'southwest',
|
138
138
|
SouthGravity.to_i => 'south',
|
139
139
|
SouthEastGravity.to_i => 'southeast'
|
140
|
-
}
|
140
|
+
}.freeze
|
141
141
|
PAINT_METHOD_NAMES = {
|
142
142
|
PointMethod.to_i => 'point',
|
143
143
|
ReplaceMethod.to_i => 'replace',
|
144
144
|
FloodfillMethod.to_i => 'floodfill',
|
145
145
|
FillToBorderMethod.to_i => 'filltoborder',
|
146
146
|
ResetMethod.to_i => 'reset'
|
147
|
-
}
|
147
|
+
}.freeze
|
148
148
|
STRETCH_TYPE_NAMES = {
|
149
149
|
NormalStretch.to_i => 'normal',
|
150
150
|
UltraCondensedStretch.to_i => 'ultra-condensed',
|
@@ -156,13 +156,13 @@ class Draw
|
|
156
156
|
ExtraExpandedStretch.to_i => 'extra-expanded',
|
157
157
|
UltraExpandedStretch.to_i => 'ultra-expanded',
|
158
158
|
AnyStretch.to_i => 'all'
|
159
|
-
}
|
159
|
+
}.freeze
|
160
160
|
STYLE_TYPE_NAMES = {
|
161
161
|
NormalStyle.to_i => 'normal',
|
162
162
|
ItalicStyle.to_i => 'italic',
|
163
163
|
ObliqueStyle.to_i => 'oblique',
|
164
164
|
AnyStyle.to_i => 'all'
|
165
|
-
}
|
165
|
+
}.freeze
|
166
166
|
|
167
167
|
private
|
168
168
|
def enquote(str)
|
@@ -340,7 +340,7 @@ class Draw
|
|
340
340
|
|
341
341
|
# Set matte (make transparent) in image according to the specified
|
342
342
|
# colorization rule
|
343
|
-
def matte(x, y,
|
343
|
+
def matte(x, y, method)
|
344
344
|
if ( not PAINT_METHOD_NAMES.has_key?(method.to_i) )
|
345
345
|
Kernel.raise ArgumentError, "Unknown paint method"
|
346
346
|
end
|
data/lib/rvg/clippath.rb
CHANGED
@@ -1,46 +1,48 @@
|
|
1
1
|
#--
|
2
|
-
# $Id: clippath.rb,v 1.
|
3
|
-
# Copyright (C)
|
2
|
+
# $Id: clippath.rb,v 1.3 2007/01/20 17:39:48 rmagick Exp $
|
3
|
+
# Copyright (C) 2007 Timothy P. Hunter
|
4
4
|
#++
|
5
|
-
|
5
|
+
module Magick
|
6
|
+
class RVG
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
class ClipPath
|
9
|
+
include ShapeConstructors
|
10
|
+
include UseConstructors
|
11
|
+
include TextConstructors
|
12
|
+
include Describable
|
13
|
+
include Stylable
|
14
|
+
include Duplicatable
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
16
|
+
# Create a clipping path. Within the block create an outline
|
17
|
+
# from one or more paths, basic shapes, text objects, or +use+.
|
18
|
+
# Everything drawn within the outline will be displayed.
|
19
|
+
# Anything drawn outside the outline will not.
|
20
|
+
#
|
21
|
+
# If the clipping path contains a +use+, it
|
22
|
+
# must directly reference path, basic shape, or text objects.
|
23
|
+
#
|
24
|
+
# Attach the clipping path to an object with the :clip_path style.
|
25
|
+
def initialize(clip_path_units='userSpaceOnUse')
|
26
|
+
super()
|
27
|
+
if ! ['userSpaceOnUse', 'objectBoundingBox'].include?(clip_path_units)
|
28
|
+
raise ArgumentError, "undefined value for clip path units: #{clip_path_units}"
|
29
|
+
end
|
30
|
+
@clip_path_units = clip_path_units
|
31
|
+
@content = Content.new
|
32
|
+
yield(self) if block_given?
|
28
33
|
end
|
29
|
-
@clip_path_units = clip_path_units
|
30
|
-
@content = Content.new
|
31
|
-
yield(self) if block_given?
|
32
|
-
end
|
33
34
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
35
|
+
def add_primitives(gc, style) #:nodoc:
|
36
|
+
name = __id__.to_s
|
37
|
+
gc.define_clip_path(name) do
|
38
|
+
gc.clip_units(@clip_path_units)
|
39
|
+
@content.each { |element| element.add_primitives(gc) }
|
40
|
+
end
|
41
|
+
gc.clip_path(name)
|
39
42
|
end
|
40
|
-
gc.clip_path(name)
|
41
|
-
end
|
42
43
|
|
43
|
-
|
44
|
+
end # class ClipPath
|
44
45
|
|
45
|
-
end
|
46
|
+
end # class RVG
|
47
|
+
end # module Magick
|
46
48
|
|
data/lib/rvg/container.rb
CHANGED
@@ -1,129 +1,131 @@
|
|
1
1
|
#--
|
2
|
-
# $Id: container.rb,v 1.
|
3
|
-
# Copyright (C)
|
2
|
+
# $Id: container.rb,v 1.3 2007/01/20 17:39:49 rmagick Exp $
|
3
|
+
# Copyright (C) 2007 Timothy P. Hunter
|
4
4
|
#++
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
copy
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
nil
|
21
|
-
|
22
|
-
c.deep_copy
|
23
|
-
|
24
|
-
c.dup
|
25
|
-
|
26
|
-
|
27
|
-
|
6
|
+
module Magick
|
7
|
+
class RVG
|
8
|
+
|
9
|
+
# Content is simply an Array with a deep_copy method.
|
10
|
+
# When unit-testing, it also has a deep_equal method.
|
11
|
+
class Content < Array #:nodoc:
|
12
|
+
|
13
|
+
def deep_copy(h = {})
|
14
|
+
me = self.__id__
|
15
|
+
copy = h[me]
|
16
|
+
unless copy
|
17
|
+
copy = self.class.new
|
18
|
+
each do |c|
|
19
|
+
copy << case
|
20
|
+
when c.nil?
|
21
|
+
nil
|
22
|
+
when c.respond_to?(:deep_copy)
|
23
|
+
c.deep_copy(h)
|
24
|
+
when c.respond_to?(:dup)
|
25
|
+
c.dup rescue c
|
26
|
+
else
|
27
|
+
c
|
28
|
+
end
|
29
|
+
end
|
30
|
+
copy.freeze if frozen?
|
31
|
+
h[me] = copy
|
28
32
|
end
|
29
|
-
copy
|
30
|
-
h[me] = copy
|
33
|
+
return copy
|
31
34
|
end
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
end
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
# A Use object allows the re-use of RVG and RVG::Group
|
90
|
-
# objects within a container. Create a Use object with the
|
91
|
-
# RVG::UseConstructors#use method.
|
92
|
-
class Use
|
93
|
-
include Stylable
|
94
|
-
include Transformable
|
95
|
-
include Duplicatable
|
96
|
-
|
97
|
-
# In a container, Use objects are created indirectly via the
|
35
|
+
|
36
|
+
end # class Content
|
37
|
+
|
38
|
+
# Define a collection of shapes, text, etc. that can be reused.
|
39
|
+
# Group objects are _containers_. That is, styles and transforms defined
|
40
|
+
# on the group are used by contained objects such as shapes, text, and
|
41
|
+
# nested groups unless overridden by a nested container or the object itself.
|
42
|
+
# Groups can be reused with the RVG::UseConstructors#use method.
|
43
|
+
# Create groups within
|
44
|
+
# containers with the RVG::StructureConstructors#g method.
|
45
|
+
#
|
46
|
+
# Example:
|
47
|
+
# # All elements in the group will be translated by 50 in the
|
48
|
+
# # x-direction and 10 in the y-direction.
|
49
|
+
# rvg.g.translate(50, 10).styles(:stroke=>'red',:fill=>'none') do |grp|
|
50
|
+
# # The line will be red.
|
51
|
+
# grp.line(10,10, 20,20)
|
52
|
+
# # The circle will be blue.
|
53
|
+
# grp.circle(10, 20, 20).styles(:stroke=>'blue')
|
54
|
+
# end
|
55
|
+
class Group
|
56
|
+
include Stylable
|
57
|
+
include Transformable
|
58
|
+
include Embellishable
|
59
|
+
include Describable
|
60
|
+
include Duplicatable
|
61
|
+
|
62
|
+
def initialize
|
63
|
+
super
|
64
|
+
@content = Content.new
|
65
|
+
yield(self) if block_given?
|
66
|
+
end
|
67
|
+
|
68
|
+
def add_primitives(gc) #:nodoc:
|
69
|
+
gc.push
|
70
|
+
add_transform_primitives(gc)
|
71
|
+
add_style_primitives(gc)
|
72
|
+
@content.each { |element| element.add_primitives(gc) }
|
73
|
+
gc.pop
|
74
|
+
end
|
75
|
+
|
76
|
+
# Translate container according to #use arguments
|
77
|
+
def ref(x, y, width, height) #:nodoc:
|
78
|
+
translate(x, y) if (x != 0 || y != 0)
|
79
|
+
end
|
80
|
+
|
81
|
+
# Append an arbitrary object to the group's content. Called
|
82
|
+
# by #use to insert a non-container object into a group.
|
83
|
+
def <<(obj) #:nodoc:
|
84
|
+
@content << obj
|
85
|
+
end
|
86
|
+
|
87
|
+
end # class Group
|
88
|
+
|
89
|
+
|
90
|
+
# A Use object allows the re-use of RVG and RVG::Group
|
91
|
+
# objects within a container. Create a Use object with the
|
98
92
|
# RVG::UseConstructors#use method.
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
93
|
+
class Use
|
94
|
+
include Stylable
|
95
|
+
include Transformable
|
96
|
+
include Duplicatable
|
97
|
+
|
98
|
+
# In a container, Use objects are created indirectly via the
|
99
|
+
# RVG::UseConstructors#use method.
|
100
|
+
# The +x+ and +y+ arguments
|
101
|
+
# can be used to specify an additional translation for
|
102
|
+
# the group. The +width+ and +height+ arguments specify
|
103
|
+
# a width and height for referenced RVG objects.
|
104
|
+
def initialize(element, x=0, y=0, width=nil, height=nil)
|
105
|
+
super()
|
106
|
+
|
107
|
+
# If the element is not a group, defs, symbol, or rvg,
|
108
|
+
# wrap a group around it so it can get a transform and
|
109
|
+
# possibly a new viewport.
|
110
|
+
if ! element.respond_to?(:ref)
|
111
|
+
@element = Group.new
|
112
|
+
@element << element.deep_copy
|
113
|
+
else
|
114
|
+
@element = element.deep_copy
|
115
|
+
end
|
116
|
+
@element.ref(x, y, width, height)
|
114
117
|
end
|
115
|
-
@element.ref(x, y, width, height)
|
116
|
-
end
|
117
118
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
119
|
+
def add_primitives(gc) #:nodoc:
|
120
|
+
gc.push
|
121
|
+
add_transform_primitives(gc)
|
122
|
+
add_style_primitives(gc)
|
123
|
+
@element.add_primitives(gc)
|
124
|
+
gc.pop
|
125
|
+
end
|
125
126
|
|
126
|
-
|
127
|
+
end # class Use
|
127
128
|
|
128
|
-
end
|
129
|
+
end # class RVG
|
130
|
+
end # module Magick
|
129
131
|
|
data/lib/rvg/deep_equal.rb
CHANGED
@@ -1,54 +1,56 @@
|
|
1
|
-
|
1
|
+
module Magick
|
2
|
+
class RVG
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
[PathData, Styles, Transforms].each do |c|
|
5
|
+
c.class_eval do
|
6
|
+
def deep_equal(other)
|
7
|
+
if self != other
|
8
|
+
puts "#{c.inspect} not equal.\nself:#{self} != other:#{other}"
|
9
|
+
return false
|
10
|
+
end
|
11
|
+
return true
|
9
12
|
end
|
10
|
-
return true
|
11
13
|
end
|
12
14
|
end
|
13
|
-
end
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
[Shape, TextBase, Image, Group, Content, Use, ClipPath, Pattern, self].each do |c|
|
17
|
+
c.class_eval do
|
18
|
+
def deep_equal(other)
|
19
|
+
ivs = self.instance_variables
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
21
|
+
ivs.each do |iv|
|
22
|
+
itv = self.instance_variable_get(iv)
|
23
|
+
otv = other.instance_variable_get(iv)
|
24
|
+
if itv.respond_to?(:deep_equal)
|
25
|
+
if itv.equal?(otv)
|
26
|
+
puts "#{iv} has deep_equal but self.#{iv} and other.#{iv} are the same object."
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
if !itv.deep_equal(otv)
|
30
|
+
puts "Not equal.\nself.#{iv}=#{itv.inspect}\nother.#{iv}=#{otv.inspect}"
|
31
|
+
return false
|
32
|
+
end
|
33
|
+
else
|
34
|
+
case itv
|
35
|
+
when Float, Symbol, TrueClass, FalseClass, Fixnum, NilClass
|
36
|
+
return false if itv != otv
|
37
|
+
else
|
38
|
+
if itv.equal?(otv)
|
39
|
+
puts "#{iv} is dup-able but self.#{iv} and other.#{iv} are the same object."
|
40
|
+
return false
|
41
|
+
end
|
42
|
+
if itv != otv
|
43
|
+
puts "Not equal.\nself.#{iv}=#{itv.inspect}\nother.#{iv}=#{otv.inspect}"
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
end
|
45
47
|
end
|
46
48
|
end
|
47
|
-
end
|
48
49
|
|
49
|
-
|
50
|
+
return true
|
51
|
+
end
|
50
52
|
end
|
51
53
|
end
|
52
|
-
end
|
53
54
|
|
54
|
-
end
|
55
|
+
end # class RVG
|
56
|
+
end # module Magick
|