Method: Magick::Geometry#initialize

Defined in:
lib/RMagick.rb

#initialize(width = nil, height = nil, x = nil, y = nil, flag = nil) ⇒ Geometry

Returns a new instance of Geometry.



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/RMagick.rb', line 48

def initialize(width=nil, height=nil, x=nil, y=nil, flag=nil)

    # Support floating-point width and height arguments so Geometry
    # objects can be used to specify Image#density= arguments.
    if width == nil
        @width = 0
    elsif width.to_f >= 0.0
        @width = width.to_f
    else
        raise ArgumentError, "width must be >= 0: #{width}"
    end
    if height == nil
        @height = 0
    elsif height.to_f >= 0.0
        @height = height.to_f
    else
        raise ArgumentError, "height must be >= 0: #{height}"
    end

    @x    = x.to_i
    @y    = y.to_i
    @flag = flag
end