rmagick 5.4.4 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.devcontainer/ImageMagick6/devcontainer.json +1 -1
  3. data/.devcontainer/devcontainer.json +1 -1
  4. data/.github/workflows/ci.yml +41 -31
  5. data/.gitignore +1 -0
  6. data/.rubocop.yml +36 -9
  7. data/.rubocop_todo.yml +369 -187
  8. data/CHANGELOG.md +77 -0
  9. data/Gemfile +14 -0
  10. data/README.md +3 -3
  11. data/Rakefile +12 -1
  12. data/before_install_linux.sh +1 -11
  13. data/before_install_osx.sh +5 -7
  14. data/ext/RMagick/extconf.rb +58 -68
  15. data/ext/RMagick/rmagick.h +7 -12
  16. data/ext/RMagick/rmdraw.cpp +10 -20
  17. data/ext/RMagick/rmfill.cpp +4 -4
  18. data/ext/RMagick/rmilist.cpp +10 -2
  19. data/ext/RMagick/rmimage.cpp +342 -344
  20. data/ext/RMagick/rminfo.cpp +22 -21
  21. data/ext/RMagick/rmkinfo.cpp +5 -18
  22. data/ext/RMagick/rmmain.cpp +42 -91
  23. data/ext/RMagick/rmmontage.cpp +5 -5
  24. data/ext/RMagick/rmpixel.cpp +3 -3
  25. data/ext/RMagick/rmutil.cpp +58 -89
  26. data/lib/rmagick/version.rb +3 -3
  27. data/lib/rmagick.rb +1 -1
  28. data/lib/rmagick_internal.rb +111 -103
  29. data/lib/rvg/container.rb +3 -3
  30. data/lib/rvg/embellishable.rb +7 -3
  31. data/lib/rvg/misc.rb +15 -15
  32. data/lib/rvg/rvg.rb +6 -6
  33. data/lib/rvg/stretchable.rb +2 -2
  34. data/lib/rvg/stylable.rb +2 -2
  35. data/lib/rvg/transformable.rb +1 -1
  36. data/lib/rvg/units.rb +1 -0
  37. data/rmagick.gemspec +2 -15
  38. data/sig/rmagick/_draw_common_methods.rbs +64 -0
  39. data/sig/rmagick/_image_common_methods.rbs +387 -0
  40. data/sig/rmagick/draw.rbs +38 -0
  41. data/sig/rmagick/draw_attribute.rbs +28 -0
  42. data/sig/rmagick/enum.rbs +820 -0
  43. data/sig/rmagick/error.rbs +11 -0
  44. data/sig/rmagick/fill.rbs +21 -0
  45. data/sig/rmagick/geometry.rbs +14 -0
  46. data/sig/rmagick/image.rbs +196 -0
  47. data/sig/rmagick/image_list.rbs +183 -0
  48. data/sig/rmagick/iptc.rbs +101 -0
  49. data/sig/rmagick/kernel_info.rbs +12 -0
  50. data/sig/rmagick/optional_method_arguments.rbs +10 -0
  51. data/sig/rmagick/pixel.rbs +46 -0
  52. data/sig/rmagick/struct.rbs +90 -0
  53. data/sig/rmagick.rbs +43 -0
  54. data/sig/rvg/clippath.rbs +34 -0
  55. data/sig/rvg/container.rbs +78 -0
  56. data/sig/rvg/deep_equal.rbs +48 -0
  57. data/sig/rvg/describable.rbs +30 -0
  58. data/sig/rvg/embellishable.rbs +226 -0
  59. data/sig/rvg/misc.rbs +145 -0
  60. data/sig/rvg/paint.rbs +55 -0
  61. data/sig/rvg/pathdata.rbs +77 -0
  62. data/sig/rvg/rvg.rbs +125 -0
  63. data/sig/rvg/stretchable.rbs +56 -0
  64. data/sig/rvg/stylable.rbs +66 -0
  65. data/sig/rvg/text.rbs +118 -0
  66. data/sig/rvg/transformable.rbs +59 -0
  67. data/sig/rvg/units.rbs +33 -0
  68. metadata +38 -134
data/lib/rvg/misc.rb CHANGED
@@ -72,7 +72,7 @@ module Magick
72
72
  end
73
73
 
74
74
  def enquote(text)
75
- return text if text.length > 2 && /\A(?:\"[^\"]+\"|\'[^\']+\'|\{[^\}]+\})\z/.match(text)
75
+ return text if text.length > 2 && /\A(?:"[^\"]+"|'[^\']+'|\{[^\}]+\})\z/.match(text)
76
76
 
77
77
  if !text['\'']
78
78
  text = '\'' + text + '\''
@@ -87,7 +87,7 @@ module Magick
87
87
 
88
88
  # escape existing braces, surround with braces
89
89
  text.gsub!(/[}]/) { |b| '\\' + b }
90
- '{' + text + '}'
90
+ '{' + text + '}'
91
91
  end
92
92
 
93
93
  def glyph_metrics(glyph_orientation, glyph)
@@ -114,7 +114,7 @@ module Magick
114
114
  y_rel_coords << wy
115
115
  end
116
116
  first_word = false
117
- word.split('').each do |glyph|
117
+ word.chars.each do |glyph|
118
118
  wx, wy = get_letter_spacing(glyph)
119
119
  x_rel_coords << wx
120
120
  y_rel_coords << wy
@@ -173,7 +173,7 @@ module Magick
173
173
 
174
174
  def render(x, y, text)
175
175
  x_rel_coords, y_rel_coords = text_rel_coords(text)
176
- dx = x_rel_coords.reduce(0) { |sum, a| sum + a }
176
+ dx = x_rel_coords.sum
177
177
  dy = y_rel_coords.max
178
178
 
179
179
  # We're handling the anchoring.
@@ -203,7 +203,7 @@ module Magick
203
203
  text.split(::Magick::RVG::WORD_SEP).each do |word|
204
204
  x += x_rel_coords.shift unless first_word
205
205
  first_word = false
206
- word.split('').each do |glyph|
206
+ word.chars.each do |glyph|
207
207
  render_glyph(@ctx.text_attrs.glyph_orientation_horizontal, x, y, glyph)
208
208
  x += x_rel_coords.shift
209
209
  end
@@ -234,7 +234,7 @@ module Magick
234
234
  def render(x, y, text)
235
235
  x_rel_coords, y_rel_coords = text_rel_coords(text)
236
236
  dx = x_rel_coords.max
237
- dy = y_rel_coords.reduce(0) { |sum, a| sum + a }
237
+ dy = y_rel_coords.sum
238
238
 
239
239
  # We're handling the anchoring.
240
240
  @ctx.gc.push
@@ -271,7 +271,7 @@ module Magick
271
271
  x_rel_coords.shift
272
272
  end
273
273
  first_word = false
274
- word.split('').each do |glyph|
274
+ word.chars.each do |glyph|
275
275
  case @ctx.text_attrs.glyph_orientation_vertical.to_i
276
276
  when 0, 90, 270
277
277
  x_shift = (dx - x_rel_coords.shift) / 2
@@ -452,10 +452,10 @@ module Magick
452
452
  }
453
453
 
454
454
  FONT_WEIGHT = {
455
- 'normal' => Magick::NormalWeight,
456
- 'bold' => Magick::BoldWeight,
457
- 'bolder' => Magick::BolderWeight,
458
- 'lighter' => Magick::LighterWeight
455
+ normal: Magick::NormalWeight,
456
+ bold: Magick::BoldWeight,
457
+ bolder: Magick::BolderWeight,
458
+ lighter: Magick::LighterWeight
459
459
  }
460
460
 
461
461
  TEXT_ANCHOR = {
@@ -579,7 +579,7 @@ module Magick
579
579
 
580
580
  def font_weight(weight)
581
581
  # If the arg is not in the hash use it directly. Handles numeric values.
582
- weight = FONT_WEIGHT.fetch(weight) { |key| key }
582
+ weight = FONT_WEIGHT.fetch(weight.to_sym, Magick::NormalWeight) unless weight.is_a?(Numeric)
583
583
  @gc.font_weight(weight)
584
584
  @shadow[-1].font_weight = weight
585
585
  nil
@@ -646,7 +646,7 @@ module Magick
646
646
 
647
647
  def skewX(degrees)
648
648
  degrees = Magick::RVG.convert_one_to_float(degrees)
649
- @gc.skewX(degrees)
649
+ @gc.skewx(degrees)
650
650
  @ry = Math.tan(GraphicContext.degrees_to_radians(degrees))
651
651
  concat_matrix
652
652
  nil
@@ -654,7 +654,7 @@ module Magick
654
654
 
655
655
  def skewY(degrees)
656
656
  degrees = Magick::RVG.convert_one_to_float(degrees)
657
- @gc.skewY(degrees)
657
+ @gc.skewy(degrees)
658
658
  @rx = Math.tan(GraphicContext.degrees_to_radians(degrees))
659
659
  concat_matrix
660
660
  nil
@@ -668,7 +668,7 @@ module Magick
668
668
  end
669
669
 
670
670
  def text(x, y, text)
671
- return if text.length.zero?
671
+ return if text.empty?
672
672
 
673
673
  text_renderer = if @text_attrs.non_default?
674
674
  TEXT_STRATEGIES[@text_attrs.writing_mode].new(self)
data/lib/rvg/rvg.rb CHANGED
@@ -41,8 +41,6 @@ require 'rvg/clippath'
41
41
  require 'rvg/paint'
42
42
  require 'rvg/units'
43
43
 
44
- require 'pp' if ENV['debug_rvg']
45
-
46
44
  # RVG is the main class in this library. All graphic elements
47
45
  # must be contained within an RVG object.
48
46
  module Magick
@@ -90,6 +88,8 @@ module Magick
90
88
  end
91
89
  bg_image
92
90
  end
91
+ else
92
+ @background_image.copy
93
93
  end
94
94
  else
95
95
  @background_image.copy
@@ -106,7 +106,7 @@ module Magick
106
106
 
107
107
  if ENV['debug_prim']
108
108
  def print_gc(gc)
109
- primitives = gc.inspect.split(/\n/)
109
+ primitives = gc.inspect.split("\n")
110
110
  indent = 0
111
111
  primitives.each do |cmd|
112
112
  indent -= 1 if cmd['pop ']
@@ -170,7 +170,9 @@ module Magick
170
170
  # The default fill is "none", that is, transparent black.
171
171
  def background_fill=(color)
172
172
  warn 'background_fill= has no effect in nested RVG objects' if @nested
173
- if !color.is_a?(Magick::Pixel)
173
+ if color.is_a?(Magick::Pixel)
174
+ @background_fill = color
175
+ else
174
176
  begin
175
177
  @background_fill = Magick::Pixel.from_color(color)
176
178
  rescue Magick::ImageMagickError
@@ -180,8 +182,6 @@ module Magick
180
182
  rescue StandardError
181
183
  raise ArgumentError, "argument must be a color name or a Pixel (got #{color.class})"
182
184
  end
183
- else
184
- @background_fill = color
185
185
  end
186
186
  end
187
187
 
@@ -137,8 +137,8 @@ module Magick
137
137
  rescue ArgumentError
138
138
  raise ArgumentError, "arguments must be convertable to float (got #{x.class}, #{y.class}, #{width.class}, #{height.class})"
139
139
  end
140
- raise(ArgumentError, "viewbox width must be > 0 (#{width} given)") unless width >= 0
141
- raise(ArgumentError, "viewbox height must be > 0 (#{height} given)") unless height >= 0
140
+ raise(ArgumentError, "viewbox width must be > 0 (#{@vbx_width} given)") unless @vbx_width >= 0
141
+ raise(ArgumentError, "viewbox height must be > 0 (#{@vbx_height} given)") unless @vbx_height >= 0
142
142
 
143
143
  # return the user-coordinate space attributes if defined
144
144
  class << self
data/lib/rvg/stylable.rb CHANGED
@@ -4,7 +4,7 @@
4
4
  #++
5
5
  module Magick
6
6
  class RVG
7
- #:stopdoc:
7
+ # :stopdoc:
8
8
  STYLES = %i[
9
9
  clip_path clip_rule fill fill_opacity fill_rule font
10
10
  font_family font_size font_stretch font_style font_weight
@@ -49,7 +49,7 @@ module Magick
49
49
  end
50
50
  end # class Styles
51
51
 
52
- #:startdoc:
52
+ # :startdoc:
53
53
 
54
54
  # This module is mixed into classes that can have styles.
55
55
  module Stylable
@@ -89,7 +89,7 @@ module Magick
89
89
  cx = Float(args[0])
90
90
  cy = Float(args[1])
91
91
  @transforms << [:translate, [cx, cy]]
92
- @transforms << [:rotate, [angle]]
92
+ @transforms << [:rotate, [Float(angle)]]
93
93
  @transforms << [:translate, [-cx, -cy]]
94
94
  else
95
95
  raise ArgumentError, "wrong number of arguments (#{args.length} for 1 or 3)"
data/lib/rvg/units.rb CHANGED
@@ -5,6 +5,7 @@ module Magick
5
5
  # Define RVG.dpi and RVG.dpi=. Add conversions to Integer and Float classes
6
6
  class << self
7
7
  attr_reader :dpi
8
+
8
9
  def dpi=(n)
9
10
  unless defined?(@dpi)
10
11
  [Float, Integer].each do |c|
data/rmagick.gemspec CHANGED
@@ -5,7 +5,6 @@ require './lib/rmagick/version'
5
5
  Gem::Specification.new do |s|
6
6
  s.name = 'rmagick'
7
7
  s.version = Magick::VERSION
8
- s.date = Date.today.to_s
9
8
  s.summary = 'Ruby binding to ImageMagick'
10
9
  s.description = 'RMagick is an interface between Ruby and ImageMagick.'
11
10
  s.authors = ['Tim Hunter', 'Omer Bar-or', 'Benjamin Thomas', 'Moncef Maiza']
@@ -14,7 +13,7 @@ Gem::Specification.new do |s|
14
13
  s.license = 'MIT'
15
14
 
16
15
  tracked_files = `git ls-files`.split($OUTPUT_RECORD_SEPARATOR)
17
- file_exclusion_regex = %r{\A(doc|benchmarks|examples|spec|lib/rvg/to_c.rb)}
16
+ file_exclusion_regex = /\A(doc|benchmarks|examples|spec|Steepfile)/
18
17
  files = tracked_files.reject { |file| file[file_exclusion_regex] }
19
18
 
20
19
  s.files = files
@@ -24,18 +23,6 @@ Gem::Specification.new do |s|
24
23
  s.required_ruby_version = ">= #{Magick::MIN_RUBY_VERSION}"
25
24
  s.requirements << "ImageMagick #{Magick::MIN_IM_VERSION} or later"
26
25
 
27
- s.add_runtime_dependency 'pkg-config', '~> 1.4'
28
26
  s.add_runtime_dependency 'observer', '~> 0.1'
29
-
30
- s.add_development_dependency 'pry', '~> 0.14'
31
- s.add_development_dependency 'rake-compiler', '~> 1.0'
32
- s.add_development_dependency 'rspec', '~> 3.8'
33
- s.add_development_dependency 'rspec_junit_formatter', '~> 0.6.0'
34
- if RUBY_PLATFORM !~ /mswin|mingw/
35
- s.add_development_dependency 'rubocop', '~> 0.81.0'
36
- s.add_development_dependency 'rubocop-rspec', '~> 1.38.1'
37
- s.add_development_dependency 'rubocop-performance', '~> 1.5.2'
38
- end
39
- s.add_development_dependency 'simplecov', '~> 0.16.1'
40
- s.add_development_dependency 'yard', '~> 0.9.24'
27
+ s.add_runtime_dependency 'pkg-config', '~> 1.4'
41
28
  end
@@ -0,0 +1,64 @@
1
+ module Magick
2
+ interface _DrawCommonMethods
3
+ def affine: (magick_real sx, magick_real rx, magick_real ry, magick_real sy, magick_real tx, magick_real ty) -> self
4
+ def alpha: (magick_real x, magick_real y, PaintMethod method) -> self
5
+ def arc: (magick_real start_x, magick_real start_y, magick_real end_x, magick_real end_y, magick_real start_degrees, magick_real end_degrees) -> self
6
+ def bezier: (*magick_real points) -> self
7
+ def circle: (magick_real origin_x, magick_real origin_y, magick_real perim_x, magick_real perim_y) -> self
8
+ def clip_path: (interned name) -> self
9
+ def clip_rule: (interned rule) -> self
10
+ def clip_units: (interned unit) -> self
11
+ def color: (magick_real x, magick_real y, PaintMethod method) -> self
12
+ def decorate: (DecorationType decoration) -> self
13
+ def define_clip_path: (interned name) { () -> void } -> void
14
+ def ellipse: (magick_real origin_x, magick_real origin_y, magick_real width, magick_real height, magick_real arc_start, magick_real arc_end) -> self
15
+ def encoding: (interned encoding) -> self
16
+ def fill: (interned colorspec) -> self
17
+ alias fill_color fill
18
+ alias fill_pattern fill
19
+ def fill_opacity: (magick_percentage opacity) -> self
20
+ def fill_rule: (interned rule) -> self
21
+ def gravity: (GravityType grav) -> self
22
+ def image: (CompositeOperator composite, magick_real x, magick_real y, magick_real width, magick_real height, String image_file_path) -> self
23
+ def interline_spacing: (magick_real space) -> self
24
+ def interword_spacing: (magick_real space) -> self
25
+ def kerning: (magick_real space) -> self
26
+ def line: (magick_real start_x, magick_real start_y, magick_real end_x, magick_real end_y) -> self
27
+ def opacity: (magick_percentage opacity) -> self
28
+ def path: (interned cmds) -> self
29
+ def pattern: (interned name, magick_real x, magick_real y, magick_real width, magick_real height) { () -> void } -> void
30
+ def point: (magick_real x, magick_real y) -> self
31
+ def pointsize: (magick_real points) -> self
32
+ def polygon: (*magick_real points) -> self
33
+ def polyline: (*magick_real points) -> self
34
+ def rectangle: (magick_real upper_left_x, magick_real upper_left_y, magick_real lower_right_x, magick_real lower_right_y) -> self
35
+ def roundrectangle: (magick_real center_x, magick_real center_y, magick_real width, magick_real height, magick_real corner_width, magick_real corner_height) -> self
36
+ def skewx: (magick_real angle) -> self
37
+ def skewy: (magick_real angle) -> self
38
+ def stroke: (interned colorspec) -> self
39
+ alias stroke_color stroke
40
+ alias stroke_pattern stroke
41
+ def stroke_antialias: (bool `bool`) -> self
42
+ def stroke_dasharray: (*magick_real list) -> self
43
+ def stroke_dashoffset: (?magick_real value) -> self
44
+ def stroke_linecap: (interned value) -> self
45
+ def stroke_linejoin: (interned value) -> self
46
+ def stroke_miterlimit: (magick_real value) -> self
47
+ def stroke_opacity: (magick_percentage opacity) -> self
48
+ def text_align: (AlignType alignment) -> self
49
+ def text_antialias: (bool boolean) -> self
50
+ def text_undercolor: (String color) -> self
51
+
52
+ def annotate: (magick_image image_arg, int width_arg, int height_arg, int x_arg, int y_arg, string text) -> self
53
+ | (magick_image image_arg, int width_arg, int height_arg, int x_arg, int y_arg, string text) { (self) -> void } -> self
54
+ def composite: (magick_real x, magick_real y, magick_real width, magick_real height, magick_image image, ?CompositeOperator composite_op) -> self
55
+ def draw: (magick_image image_arg) -> self
56
+ def get_type_metrics: (magick_image image, string text) -> TypeMetric
57
+ | (string text) -> TypeMetric
58
+ def get_multiline_type_metrics: (magick_image image, string text) -> TypeMetric
59
+ | (string text) -> TypeMetric
60
+ def marshal_dump: () -> Hash[Symbol, untyped]
61
+ def marshal_load: (Hash[Symbol, untyped] ddraw) -> self
62
+ def primitive: (string primitive) -> self
63
+ end
64
+ end