Class: SugarCube::CoreGraphics::Rect

Inherits:
Array
  • Object
show all
Includes:
SugarCube::CGRectExtensions
Defined in:
lib/sugarcube/core_graphics.rb

Instance Method Summary collapse

Methods included from SugarCube::CGRectExtensions

#+, #==, #bottom, #center, #contains?, #empty?, #height, included, #infinite?, #inspect, #intersection, #intersects?, #left, #null?, #right, #to_hash, #to_s, #top, #width

Methods inherited from Array

#to_pointer

Constructor Details

#initialize(args) ⇒ Rect

Returns a new instance of Rect.



239
240
241
242
243
244
245
246
247
248
249
250
251
# File 'lib/sugarcube/core_graphics.rb', line 239

def initialize args
  if args.length == 4
    super [Point.new([args[0], args[1]]), Size.new([args[2], args[3]])]
  else
    unless args[0].is_a? Point
      args[0] = Point(args[0])
    end
    unless args[1].is_a? Size
      args[1] = Size(args[1])
    end
    super [args[0], args[1]]
  end
end

Instance Method Details

#originObject



253
254
255
# File 'lib/sugarcube/core_graphics.rb', line 253

def origin
  return self[0]
end

#origin=(val) ⇒ Object



257
258
259
# File 'lib/sugarcube/core_graphics.rb', line 257

def origin= val
  self[0] = Point(val)
end

#sizeObject



261
262
263
# File 'lib/sugarcube/core_graphics.rb', line 261

def size
  return self[1]
end

#size=(val) ⇒ Object



265
266
267
# File 'lib/sugarcube/core_graphics.rb', line 265

def size= val
  self[1] = Size(val)
end