Method: SugarCube::CoreGraphics.Size

Defined in:
lib/sugarcube-coregraphics/core_graphics.rb

.Size(w_or_size, h = nil) ⇒ Object

Accepts 1 or 2 arguments 1 argument should be a CGPoint, CGSize, Array[Numeric, Numeric] or UIOffset 2 arguments should be Numeric, Numeric



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/sugarcube-coregraphics/core_graphics.rb', line 35

def Size(w_or_size, h=nil)
  unless h
    case w_or_size
    when CGSize
      w = w_or_size.width
      h = w_or_size.height
    when CGPoint
      w = w_or_size.x
      h = w_or_size.y
    when UIOffset
      w = w_or_size.horizontal
      h = w_or_size.vertical
    when Array
      w = w_or_size[0]
      h = w_or_size[1]
    else
      raise RuntimeError.new("Invalid argument sent to Size(#{w_or_size.inspect})")
    end
  else
    w = w_or_size
  end
  return CGSize.new(w, h)
end