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:


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

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)
        fail(ArgumentError, "unknown alignment specifier: #{@align}") unless m
    end

    if meet_or_slice
        meet_or_slice = meet_or_slice.to_s.downcase
        if meet_or_slice == 'meet' || meet_or_slice == 'slice'
            @meet_or_slice = meet_or_slice
        else
            fail(ArgumentError, "specifier must be `meet' or `slice' (got #{meet_or_slice})")
        end
    end
    yield(self) if block_given?
    self
end