Module: Magick::RVG::PreserveAspectRatio

Included in:
Image, Stretchable
Defined in:
lib/rvg/stretchable.rb

Instance Method Summary collapse

Instance Method Details

#preserve_aspect_ratio(align, meet_or_slice = 'meet') {|_self| ... } ⇒ Object

Included in Stretchable module and Image class

++ Specifies how the image within a viewport should be scaled.

align

a combination of ‘xMin’, ‘xMid’, or ‘xMax’, followed by ‘YMin’, ‘YMid’, or ‘YMax’

meet_or_slice

one of ‘meet’ or ‘slice’

Yields:

  • (_self)

Yield Parameters:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rvg/stretchable.rb', line 15

def preserve_aspect_ratio(align, meet_or_slice = 'meet')
  @align = align.to_s
  if @align != 'none'
    m = /\A(xMin|xMid|xMax)(YMin|YMid|YMax)\z/.match(@align)
    raise(ArgumentError, "unknown alignment specifier: #{@align}") unless m
  end

  if meet_or_slice
    meet_or_slice = meet_or_slice.to_s.downcase
    raise(ArgumentError, "specifier must be `meet' or `slice' (got #{meet_or_slice})") unless %w[meet slice].include?(meet_or_slice)

    @meet_or_slice = meet_or_slice
  end
  yield(self) if block_given?
  self
end