rmagick 2.15.3 → 2.15.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.editorconfig +14 -0
  3. data/.rubocop.yml +27 -3
  4. data/.travis.yml +9 -6
  5. data/CHANGELOG.md +4 -0
  6. data/CONTRIBUTING.md +10 -0
  7. data/README.textile +4 -0
  8. data/before_install_linux.sh +4 -4
  9. data/doc/ex/gravity.rb +2 -1
  10. data/ext/RMagick/extconf.rb +60 -17
  11. data/lib/rmagick/version.rb +1 -1
  12. data/lib/rvg/clippath.rb +37 -36
  13. data/lib/rvg/container.rb +106 -107
  14. data/lib/rvg/deep_equal.rb +46 -48
  15. data/lib/rvg/describable.rb +35 -36
  16. data/lib/rvg/embellishable.rb +384 -380
  17. data/lib/rvg/misc.rb +705 -690
  18. data/lib/rvg/paint.rb +39 -40
  19. data/lib/rvg/pathdata.rb +120 -121
  20. data/lib/rvg/rvg.rb +212 -209
  21. data/lib/rvg/stretchable.rb +159 -158
  22. data/lib/rvg/stylable.rb +99 -100
  23. data/lib/rvg/text.rb +0 -1
  24. data/lib/rvg/transformable.rb +110 -110
  25. data/lib/rvg/units.rb +58 -58
  26. data/rmagick.gemspec +1 -1
  27. data/spec/rmagick/image/blue_shift_spec.rb +16 -0
  28. data/spec/rmagick/image/composite_spec.rb +140 -0
  29. data/spec/rmagick/image/constitute_spec.rb +15 -0
  30. data/spec/rmagick/image/dispatch_spec.rb +18 -0
  31. data/spec/rmagick/image/from_blob_spec.rb +14 -0
  32. data/spec/rmagick/image/ping_spec.rb +14 -0
  33. data/spec/rmagick/image/properties_spec.rb +29 -0
  34. data/spec/spec_helper.rb +3 -0
  35. data/test/Image1.rb +524 -718
  36. data/test/Image2.rb +1262 -1262
  37. data/test/Image3.rb +973 -973
  38. data/test/ImageList2.rb +341 -341
  39. data/test/Image_attributes.rb +678 -678
  40. data/test/Info.rb +336 -336
  41. data/test/Magick.rb +245 -242
  42. data/test/Pixel.rb +105 -105
  43. data/test/Preview.rb +42 -42
  44. metadata +21 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcaee92d74cc985e1296e1a1e31577597da850af
4
- data.tar.gz: 7a2b76f61cfd85f4699e6a91ee61672c5488f1e9
3
+ metadata.gz: 79bd6595ef81cd3743a21521e9a4bed46dbcf52b
4
+ data.tar.gz: 659d7eff32093a2a9d1738509a0c4c3376466d29
5
5
  SHA512:
6
- metadata.gz: 588236f986f01875b947efb01049991768e3f38f9dc9b1a1387e02ebc4dc636ac8b27925ac8048fa2d0dd726555ab8a4826ed9d15113683276225c0b82cb187e
7
- data.tar.gz: 308b4616c264fd8bf908b817b46e35624ba99987d12268775be459cd477454c0931be08756f9d5ec4b69fbf1baf3b43e6cc721531ba0b591e046b27e5a11cc59
6
+ metadata.gz: 72eb476772660c07483bf8748716d1a95412c3d64988c65385dee9b48b4177a9e42beb583a031233689446fb3aa2987d1da672ed18fe88bf96618ea28da5fb6e
7
+ data.tar.gz: b67cb2bcccb97b2e4ef53b65fdfabde8cacf18dfcba388d49a476d6f96d27d2685aeef6e15e1268aa68465277e3752a45fe4f7c1bbc26bb8ebad091056953ca4
@@ -0,0 +1,14 @@
1
+ # EditorConfig helps developers define and maintain consistent coding styles between different editors and IDEs
2
+ # @see http://editorconfig.org
3
+ root = true
4
+
5
+ [*]
6
+ end_of_line = lf
7
+ charset = utf-8
8
+ trim_trailing_whitespace = true
9
+ insert_final_newline = true
10
+ indent_style = spaces
11
+ tab_width = 2
12
+
13
+ [{*.{rb,yml,sh,md}]
14
+ indent_size = 2
@@ -14,9 +14,6 @@ Style/Lambda:
14
14
  Style/StringLiterals:
15
15
  EnforcedStyle: single_quotes
16
16
 
17
- Style/MultilineOperationIndentation:
18
- EnforcedStyle: indented
19
-
20
17
  Style/DotPosition:
21
18
  EnforcedStyle: leading
22
19
 
@@ -27,6 +24,9 @@ Style/DotPosition:
27
24
  Lint/BlockAlignment:
28
25
  Enabled: false
29
26
 
27
+ Lint/FormatParameterMismatch:
28
+ Enabled: false
29
+
30
30
  # Offense count: 1
31
31
  Lint/HandleExceptions:
32
32
  Enabled: false
@@ -93,10 +93,16 @@ Metrics/ParameterLists:
93
93
  Metrics/PerceivedComplexity:
94
94
  Max: 41
95
95
 
96
+ Performance/StringReplacement:
97
+ Enabled: false
98
+
96
99
  # Offense count: 4
97
100
  Style/AccessorMethodName:
98
101
  Enabled: false
99
102
 
103
+ Style/AlignArray:
104
+ Enabled: false
105
+
100
106
  # Offense count: 3
101
107
  # Cop supports --auto-correct.
102
108
  # Configuration parameters: EnforcedStyle, SupportedStyles.
@@ -126,6 +132,9 @@ Style/ClassAndModuleChildren:
126
132
  Style/ClosingParenthesisIndentation:
127
133
  Enabled: false
128
134
 
135
+ Style/CollectionMethods:
136
+ Enabled: false
137
+
129
138
  # Offense count: 5
130
139
  # Cop supports --auto-correct.
131
140
  Style/CommentIndentation:
@@ -139,6 +148,12 @@ Style/ConstantName:
139
148
  Style/Documentation:
140
149
  Enabled: false
141
150
 
151
+ Style/EmptyLinesAroundBlockBody:
152
+ Enabled: false
153
+
154
+ Style/ExtraSpacing:
155
+ Enabled: false
156
+
142
157
  # Offense count: 23
143
158
  # Configuration parameters: Exclude.
144
159
  Style/FileName:
@@ -165,6 +180,12 @@ Style/GuardClause:
165
180
  Style/IfUnlessModifier:
166
181
  Enabled: false
167
182
 
183
+ Style/IndentArray:
184
+ Enabled: false
185
+
186
+ Style/IndentationConsistency:
187
+ Enabled: false
188
+
168
189
  # Offense count: 1049
169
190
  # Cop supports --auto-correct.
170
191
  # Configuration parameters: Width.
@@ -227,6 +248,9 @@ Style/PredicateName:
227
248
  Style/RegexpLiteral:
228
249
  Enabled: false
229
250
 
251
+ Style/RescueEnsureAlignment:
252
+ Enabled: false
253
+
230
254
  # Offense count: 2
231
255
  Style/RescueModifier:
232
256
  Enabled: false
@@ -3,10 +3,11 @@ language: ruby
3
3
  os:
4
4
  - linux
5
5
 
6
+ sudo: required
7
+
6
8
  env:
7
9
  # Currently successful release
8
10
  - IMAGEMAGICK_VERSION=6.6.9-10
9
- - IMAGEMAGICK_VERSION=6.6.9-10 STYLE_CHECKS=true
10
11
  # Ubuntu's current stable release
11
12
  - IMAGEMAGICK_VERSION=6.7.7-10
12
13
  # Latest 6.7 release
@@ -30,8 +31,6 @@ rvm:
30
31
 
31
32
  matrix:
32
33
  exclude:
33
- - rvm: 1.8
34
- env: IMAGEMAGICK_VERSION=6.6.9-10 STYLE_CHECKS=true
35
34
  - rvm: 1.8
36
35
  env: IMAGEMAGICK_VERSION=6.7.9-10
37
36
  - rvm: 1.8
@@ -53,12 +52,16 @@ matrix:
53
52
  - rvm: 2.0
54
53
  env: IMAGEMAGICK_VERSION=6.8.9-10 CONFIGURE_OPTIONS=--enable-hdri
55
54
  allow_failures:
56
- - rvm: 1.8
57
- - rvm: 2.2
58
- - env: IMAGEMAGICK_VERSION=6.6.9-10 STYLE_CHECKS=true
59
55
  - env: IMAGEMAGICK_VERSION=6.7.7-10
60
56
  - env: IMAGEMAGICK_VERSION=6.7.9-10
57
+ rvm: 2.1
58
+ - env: IMAGEMAGICK_VERSION=6.7.9-10
59
+ rvm: 2.2
60
+ - env: IMAGEMAGICK_VERSION=6.8.9-10
61
+ rvm: 2.1
61
62
  - env: IMAGEMAGICK_VERSION=6.8.9-10 CONFIGURE_OPTIONS=--enable-hdri
63
+ rvm: 2.1
64
+ - env: IMAGEMAGICK_VERSION=latest
62
65
 
63
66
  notifications:
64
67
  webhooks:
@@ -3,6 +3,10 @@
3
3
  All notable changes to this project are documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## RMagick 2.15.4
7
+
8
+ - Improved C extension building process - @u338steven
9
+
6
10
  ## RMagick 2.15.3
7
11
 
8
12
  - Fixed ImageMagick version detection on Windows - @maisumakun
@@ -37,4 +37,14 @@ You are also welcome to convert existing Test/Unit tests to RSpec.
37
37
  Committing
38
38
  ----------
39
39
 
40
+ All work for a next release is done in the `develop` branch. Please create your branch off of it.
41
+
40
42
  It is better if you follow [Git Style Guide](https://github.com/agis-/git-style-guide).
43
+
44
+
45
+ Pull Requests
46
+ -------------
47
+
48
+ Please choose the `rmagick/rmagick` repo and the `develop` branch as the destination for your pull request.
49
+
50
+ NOTE: GitHub suggests `rmagick-temp/rmagick` repo by default. **This is incorrect.** Please switch to `rmagick/rmagick`. It should be the next repo in the drop-down list.
@@ -32,6 +32,10 @@ Ruby must be able to build C-Extensions (e.g. MRI, Rubinius, not JRuby)
32
32
 
33
33
  *ImageMagick* Version 6.4.9 or later. You can get ImageMagick from "www.imagemagick.org":http://www.imagemagick.org.
34
34
 
35
+ On Ubuntu, you can run:
36
+
37
+ bc. sudo apt-get install libmagickwand-dev
38
+
35
39
  h2(#install). Installing RMagick
36
40
 
37
41
  h4. Installing via Bundler
@@ -5,13 +5,13 @@ sudo apt-get install -y build-essential libx11-dev libxext-dev zlib1g-dev libpng
5
5
  sudo apt-get build-dep -y imagemagick
6
6
  case $IMAGEMAGICK_VERSION in
7
7
  latest)
8
- wget http://www.imagemagick.org/download/ImageMagick.tar.gz
9
- tar -xzvf ImageMagick.tar.gz
8
+ wget http://www.imagemagick.org/download/ImageMagick.tar.xz
9
+ tar -xf ImageMagick.tar.xz
10
10
  cd ImageMagick-*
11
11
  ;;
12
12
  *)
13
- wget http://www.imagemagick.org/download/releases/ImageMagick-${IMAGEMAGICK_VERSION}.tar.gz
14
- tar -xzvf ImageMagick-${IMAGEMAGICK_VERSION}.tar.gz
13
+ wget http://www.imagemagick.org/download/releases/ImageMagick-${IMAGEMAGICK_VERSION}.tar.xz
14
+ tar -xf ImageMagick-${IMAGEMAGICK_VERSION}.tar.xz
15
15
  cd ImageMagick-${IMAGEMAGICK_VERSION}
16
16
  ;;
17
17
  esac
@@ -5,7 +5,8 @@
5
5
 
6
6
  require 'rmagick'
7
7
 
8
- x, y = 100, 100
8
+ x = 100
9
+ y = 100
9
10
 
10
11
  begin
11
12
 
@@ -1,5 +1,6 @@
1
1
  lib_dir = File.expand_path('../../lib', File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir)
3
+ require 'rubygems'
3
4
  require 'mkmf'
4
5
  require 'date'
5
6
 
@@ -60,10 +61,12 @@ module RMagick
60
61
  $pkg_config = false
61
62
 
62
63
  # Check for Magick-config
63
- if find_executable('Magick-config')
64
+ if find_executable('Magick-config') && !has_graphicsmagick_libmagick_dev_compat?
64
65
  $magick_config = true
66
+ $magick_version = `Magick-config --version`[/^(\d+\.\d+\.\d+)/]
65
67
  elsif find_executable('pkg-config')
66
68
  $pkg_config = true
69
+ $magick_version = `pkg-config MagickCore --modversion`[/^(\d+\.\d+\.\d+)/]
67
70
  else
68
71
  exit_failure "Can't install RMagick #{RMAGICK_VERS}. Can't find Magick-config or pkg-config in #{ENV['PATH']}\n"
69
72
  end
@@ -74,15 +77,10 @@ module RMagick
74
77
  # Ensure minimum ImageMagick version
75
78
  # Check minimum ImageMagick version if possible
76
79
  checking_for("outdated ImageMagick version (<= #{Magick::MIN_IM_VERSION})") do
77
- # extract version info from convert binary (could use identify as well)
78
- # TODO: Extract the value of MagickLibVersionText constant in MagickCore/version.h somehow
79
- `convert -version`.match(/^Version: ImageMagick (\d+\.\d+\.\d+)/) do |matches|
80
- version = matches[1]
81
- Logging.message("Detected ImageMagick version: #{version}\n")
82
-
83
- if Gem::Version.new(version) < Gem::Version.new(Magick::MIN_IM_VERSION)
84
- exit_failure "Can't install RMagick #{RMAGICK_VERS}. You must have ImageMagick #{Magick::MIN_IM_VERSION} or later.\n"
85
- end
80
+ Logging.message("Detected ImageMagick version: #{$magick_version}\n")
81
+
82
+ if Gem::Version.new($magick_version) < Gem::Version.new(Magick::MIN_IM_VERSION)
83
+ exit_failure "Can't install RMagick #{RMAGICK_VERS}. You must have ImageMagick #{Magick::MIN_IM_VERSION} or later.\n"
86
84
  end
87
85
  end
88
86
 
@@ -109,25 +107,25 @@ module RMagick
109
107
 
110
108
  elsif RUBY_PLATFORM =~ /mingw/ # mingw
111
109
 
112
- `convert -version` =~ /Version: ImageMagick (\d+\.\d+\.\d+)-+\d+ /
110
+ `identify -version` =~ /Version: ImageMagick (\d+\.\d+\.\d+)-+\d+ /
113
111
  abort 'Unable to get ImageMagick version' unless $1
114
112
  $magick_version = $1
115
- if RUBY_PLATFORM =~ /x64/
116
- $LOCAL_LIBS = '-lCORE_RL_magick_'
117
- else
118
- $LOCAL_LIBS = '-lCORE_RL_magick_ -lX11'
113
+ unless have_library('CORE_RL_magick_')
114
+ search_paths_for_library_for_mingw
119
115
  end
116
+ have_library('X11')
120
117
 
121
118
  else # mswin
122
119
 
123
- `convert -version` =~ /Version: ImageMagick (\d+\.\d+\.\d+)-+\d+ /
120
+ `identify -version` =~ /Version: ImageMagick (\d+\.\d+\.\d+)-+\d+ /
124
121
  abort 'Unable to get ImageMagick version' unless $1
125
122
  $magick_version = $1
126
123
  $CFLAGS = '-W3'
127
124
  $CPPFLAGS = %Q{-I"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Include" -I"C:\\Program Files\\ImageMagick-#{$magick_version}-Q8\\include"}
128
125
  # The /link option is required by the Makefile but causes warnings in the mkmf.log file.
129
126
  $LDFLAGS = %Q{/link /LIBPATH:"C:\\Program Files\\Microsoft Platform SDK for Windows Server 2003 R2\\Lib" /LIBPATH:"C:\\Program Files\\ImageMagick-#{$magick_version}-Q8\\lib" /LIBPATH:"C:\\ruby\\lib"}
130
- $LOCAL_LIBS = 'CORE_RL_magick_.lib X11.lib'
127
+ $LOCAL_LIBS = 'CORE_RL_magick_.lib'
128
+ have_library('X11')
131
129
 
132
130
  end
133
131
  end
@@ -156,6 +154,20 @@ SRC
156
154
  end
157
155
  end
158
156
 
157
+ def has_graphicsmagick_libmagick_dev_compat?
158
+ config_path = `which Magick-config`.chomp
159
+ if File.exist?(config_path) &&
160
+ File.symlink?(config_path) &&
161
+ File.readlink(config_path) =~ /GraphicsMagick/
162
+ msg = 'Found a graphicsmagick-libmagick-dev-compat installation.'
163
+ Logging.message msg
164
+ message msg+"\n"
165
+ true
166
+ else
167
+ false
168
+ end
169
+ end
170
+
159
171
  def exit_failure(msg)
160
172
  Logging.message msg
161
173
  message msg+"\n"
@@ -228,6 +240,37 @@ SRC
228
240
  end
229
241
  end
230
242
 
243
+ def search_paths_for_library_for_mingw
244
+ msg = 'searching PATH for the ImageMagick library...'
245
+ Logging.message msg
246
+ message msg+"\n"
247
+
248
+ found_lib = false
249
+
250
+ paths = ENV['PATH'].split(File::PATH_SEPARATOR)
251
+ paths.each do |dir|
252
+ lib = File.join(dir, 'lib')
253
+ lib_file = File.join(lib, 'CORE_RL_magick_.lib')
254
+ if File.exist?(lib_file)
255
+ $CPPFLAGS = %Q{-I"#{File.join(dir, 'include')}"}
256
+ $LDFLAGS = %Q{-L"#{lib}"}
257
+ found_lib = have_library('CORE_RL_magick_')
258
+ break if found_lib
259
+ end
260
+ end
261
+
262
+ unless found_lib
263
+ exit_failure <<END_MINGW
264
+ Can't install RMagick #{RMAGICK_VERS}.
265
+ Can't find the ImageMagick library.
266
+ Retry with '--with-opt-dir' option.
267
+ Usage: gem install rmagick -- '--with-opt-dir=\"[path to ImageMagick]\"'
268
+ e.g.
269
+ gem install rmagick -- '--with-opt-dir=\"C:\Program Files\ImageMagick-6.9.1-Q16\"'
270
+ END_MINGW
271
+ end
272
+ end
273
+
231
274
  def assert_can_compile!
232
275
  assert_not_windows!
233
276
  assert_minimum_ruby_version!
@@ -1,5 +1,5 @@
1
1
  module Magick
2
- VERSION = '2.15.3'
2
+ VERSION = '2.15.4'
3
3
  MIN_RUBY_VERSION = '1.8.5'
4
4
  MIN_IM_VERSION = '6.4.9'
5
5
  end
@@ -3,42 +3,43 @@
3
3
  # Copyright (C) 2009 Timothy P. Hunter
4
4
  #++
5
5
  module Magick
6
- class RVG
7
- class ClipPath
8
- include ShapeConstructors
9
- include UseConstructors
10
- include TextConstructors
11
- include Describable
12
- include Stylable
13
- include Duplicatable
6
+ class RVG
7
+ class ClipPath
8
+ include ShapeConstructors
9
+ include UseConstructors
10
+ include TextConstructors
11
+ include Describable
12
+ include Stylable
13
+ include Duplicatable
14
14
 
15
- # Create a clipping path. Within the block create an outline
16
- # from one or more paths, basic shapes, text objects, or +use+.
17
- # Everything drawn within the outline will be displayed.
18
- # Anything drawn outside the outline will not.
19
- #
20
- # If the clipping path contains a +use+, it
21
- # must directly reference path, basic shape, or text objects.
22
- #
23
- # Attach the clipping path to an object with the :clip_path style.
24
- def initialize(clip_path_units='userSpaceOnUse')
25
- super()
26
- unless ['userSpaceOnUse', 'objectBoundingBox'].include?(clip_path_units)
27
- fail ArgumentError, "undefined value for clip path units: #{clip_path_units}"
28
- end
29
- @clip_path_units = clip_path_units
30
- @content = Content.new
31
- yield(self) if block_given?
32
- end
15
+ # Create a clipping path. Within the block create an outline
16
+ # from one or more paths, basic shapes, text objects, or +use+.
17
+ # Everything drawn within the outline will be displayed.
18
+ # Anything drawn outside the outline will not.
19
+ #
20
+ # If the clipping path contains a +use+, it
21
+ # must directly reference path, basic shape, or text objects.
22
+ #
23
+ # Attach the clipping path to an object with the :clip_path style.
24
+ def initialize(clip_path_units = 'userSpaceOnUse')
25
+ super()
26
+ unless ['userSpaceOnUse', 'objectBoundingBox'].include?(clip_path_units)
27
+ fail ArgumentError, "undefined value for clip path units: #{clip_path_units}"
28
+ end
33
29
 
34
- def add_primitives(gc, style) #:nodoc:
35
- name = __id__.to_s
36
- gc.define_clip_path(name) do
37
- gc.clip_units(@clip_path_units)
38
- @content.each { |element| element.add_primitives(gc) }
39
- end
40
- gc.clip_path(name)
41
- end
42
- end # class ClipPath
43
- end # class RVG
30
+ @clip_path_units = clip_path_units
31
+ @content = Content.new
32
+ yield(self) if block_given?
33
+ end
34
+
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)
42
+ end
43
+ end # class ClipPath
44
+ end # class RVG
44
45
  end # module Magick
@@ -2,122 +2,121 @@
2
2
  # $Id: container.rb,v 1.5 2009/02/28 23:52:13 rmagick Exp $
3
3
  # Copyright (C) 2009 Timothy P. Hunter
4
4
  #++
5
-
6
5
  module Magick
7
- class RVG
8
- # Content is simply an Array with a deep_copy method.
9
- # When unit-testing, it also has a deep_equal method.
10
- class Content < Array #:nodoc:
11
- def deep_copy(h = {})
12
- me = __id__
13
- copy = h[me]
14
- unless copy
15
- copy = self.class.new
16
- each do |c|
17
- copy << case
18
- when c.nil?
19
- nil
20
- when c.respond_to?(:deep_copy)
21
- c.deep_copy(h)
22
- when c.respond_to?(:dup)
23
- c.dup rescue c
24
- else
25
- c
26
- end
27
- end
28
- copy.freeze if frozen?
29
- h[me] = copy
30
- end
31
- copy
6
+ class RVG
7
+ # Content is simply an Array with a deep_copy method.
8
+ # When unit-testing, it also has a deep_equal method.
9
+ class Content < Array #:nodoc:
10
+ def deep_copy(h = {})
11
+ me = __id__
12
+ copy = h[me]
13
+ unless copy
14
+ copy = self.class.new
15
+ each do |c|
16
+ copy << case
17
+ when c.nil?
18
+ nil
19
+ when c.respond_to?(:deep_copy)
20
+ c.deep_copy(h)
21
+ when c.respond_to?(:dup)
22
+ c.dup rescue c
23
+ else
24
+ c
32
25
  end
33
- end # class Content
26
+ end
27
+ copy.freeze if frozen?
28
+ h[me] = copy
29
+ end
30
+ copy
31
+ end
32
+ end # class Content
34
33
 
35
- # Define a collection of shapes, text, etc. that can be reused.
36
- # Group objects are _containers_. That is, styles and transforms defined
37
- # on the group are used by contained objects such as shapes, text, and
38
- # nested groups unless overridden by a nested container or the object itself.
39
- # Groups can be reused with the RVG::UseConstructors#use method.
40
- # Create groups within
41
- # containers with the RVG::StructureConstructors#g method.
42
- #
43
- # Example:
44
- # # All elements in the group will be translated by 50 in the
45
- # # x-direction and 10 in the y-direction.
46
- # rvg.g.translate(50, 10).styles(:stroke=>'red',:fill=>'none') do |grp|
47
- # # The line will be red.
48
- # grp.line(10,10, 20,20)
49
- # # The circle will be blue.
50
- # grp.circle(10, 20, 20).styles(:stroke=>'blue')
51
- # end
52
- class Group
53
- include Stylable
54
- include Transformable
55
- include Embellishable
56
- include Describable
57
- include Duplicatable
34
+ # Define a collection of shapes, text, etc. that can be reused.
35
+ # Group objects are _containers_. That is, styles and transforms defined
36
+ # on the group are used by contained objects such as shapes, text, and
37
+ # nested groups unless overridden by a nested container or the object itself.
38
+ # Groups can be reused with the RVG::UseConstructors#use method.
39
+ # Create groups within
40
+ # containers with the RVG::StructureConstructors#g method.
41
+ #
42
+ # Example:
43
+ # # All elements in the group will be translated by 50 in the
44
+ # # x-direction and 10 in the y-direction.
45
+ # rvg.g.translate(50, 10).styles(:stroke=>'red',:fill=>'none') do |grp|
46
+ # # The line will be red.
47
+ # grp.line(10,10, 20,20)
48
+ # # The circle will be blue.
49
+ # grp.circle(10, 20, 20).styles(:stroke=>'blue')
50
+ # end
51
+ class Group
52
+ include Stylable
53
+ include Transformable
54
+ include Embellishable
55
+ include Describable
56
+ include Duplicatable
58
57
 
59
- def initialize
60
- super
61
- @content = Content.new
62
- yield(self) if block_given?
63
- end
58
+ def initialize
59
+ super
60
+ @content = Content.new
61
+ yield(self) if block_given?
62
+ end
64
63
 
65
- def add_primitives(gc) #:nodoc:
66
- gc.push
67
- add_transform_primitives(gc)
68
- add_style_primitives(gc)
69
- @content.each { |element| element.add_primitives(gc) }
70
- gc.pop
71
- end
64
+ def add_primitives(gc) #:nodoc:
65
+ gc.push
66
+ add_transform_primitives(gc)
67
+ add_style_primitives(gc)
68
+ @content.each { |element| element.add_primitives(gc) }
69
+ gc.pop
70
+ end
72
71
 
73
- # Translate container according to #use arguments
74
- def ref(x, y, width, height) #:nodoc:
75
- translate(x, y) if x != 0 || y != 0
76
- end
72
+ # Translate container according to #use arguments
73
+ def ref(x, y, width, height) #:nodoc:
74
+ translate(x, y) if x != 0 || y != 0
75
+ end
77
76
 
78
- # Append an arbitrary object to the group's content. Called
79
- # by #use to insert a non-container object into a group.
80
- def <<(obj) #:nodoc:
81
- @content << obj
82
- end
83
- end # class Group
77
+ # Append an arbitrary object to the group's content. Called
78
+ # by #use to insert a non-container object into a group.
79
+ def <<(obj) #:nodoc:
80
+ @content << obj
81
+ end
82
+ end # class Group
84
83
 
85
- # A Use object allows the re-use of RVG and RVG::Group
86
- # objects within a container. Create a Use object with the
87
- # RVG::UseConstructors#use method.
88
- class Use
89
- include Stylable
90
- include Transformable
91
- include Duplicatable
84
+ # A Use object allows the re-use of RVG and RVG::Group
85
+ # objects within a container. Create a Use object with the
86
+ # RVG::UseConstructors#use method.
87
+ class Use
88
+ include Stylable
89
+ include Transformable
90
+ include Duplicatable
92
91
 
93
- # In a container, Use objects are created indirectly via the
94
- # RVG::UseConstructors#use method.
95
- # The +x+ and +y+ arguments
96
- # can be used to specify an additional translation for
97
- # the group. The +width+ and +height+ arguments specify
98
- # a width and height for referenced RVG objects.
99
- def initialize(element, x=0, y=0, width=nil, height=nil)
100
- super()
92
+ # In a container, Use objects are created indirectly via the
93
+ # RVG::UseConstructors#use method.
94
+ # The +x+ and +y+ arguments
95
+ # can be used to specify an additional translation for
96
+ # the group. The +width+ and +height+ arguments specify
97
+ # a width and height for referenced RVG objects.
98
+ def initialize(element, x = 0, y = 0, width = nil, height = nil)
99
+ super()
101
100
 
102
- # If the element is not a group, defs, symbol, or rvg,
103
- # wrap a group around it so it can get a transform and
104
- # possibly a new viewport.
105
- if !element.respond_to?(:ref)
106
- @element = Group.new
107
- @element << element.deep_copy
108
- else
109
- @element = element.deep_copy
110
- end
111
- @element.ref(x, y, width, height)
112
- end
101
+ # If the element is not a group, defs, symbol, or rvg,
102
+ # wrap a group around it so it can get a transform and
103
+ # possibly a new viewport.
104
+ if !element.respond_to?(:ref)
105
+ @element = Group.new
106
+ @element << element.deep_copy
107
+ else
108
+ @element = element.deep_copy
109
+ end
110
+ @element.ref(x, y, width, height)
111
+ end
113
112
 
114
- def add_primitives(gc) #:nodoc:
115
- gc.push
116
- add_transform_primitives(gc)
117
- add_style_primitives(gc)
118
- @element.add_primitives(gc)
119
- gc.pop
120
- end
121
- end # class Use
122
- end # class RVG
113
+ def add_primitives(gc) #:nodoc:
114
+ gc.push
115
+ add_transform_primitives(gc)
116
+ add_style_primitives(gc)
117
+ @element.add_primitives(gc)
118
+ gc.pop
119
+ end
120
+ end # class Use
121
+ end # class RVG
123
122
  end # module Magick