class Mahoujin::Graphics::Utilities::Rectangle
Attributes
bottom[RW]
centerline[RW]
left[RW]
right[RW]
top[RW]
Public Class Methods
new(left = 0, top = 0, right = 0, bottom = 0)
click to toggle source
# File lib/mahoujin/graphics/utilities/rectangle.rb, line 7 def initialize(left = 0, top = 0, right = 0, bottom = 0) @left, @top, @right, @bottom = left, top, right, bottom @centerline = @top + (@bottom - @top).fdiv(2) end
Public Instance Methods
height()
click to toggle source
# File lib/mahoujin/graphics/utilities/rectangle.rb, line 25 def height @bottom - @top end
height=(height)
click to toggle source
# File lib/mahoujin/graphics/utilities/rectangle.rb, line 29 def height=(height) @centerline = @top + height * (@centerline - @top).fdiv(@bottom - @top) @bottom = @top + height end
move_bottom(bottom)
click to toggle source
# File lib/mahoujin/graphics/utilities/rectangle.rb, line 50 def move_bottom(bottom) @centerline = bottom + (@centerline - @bottom) @top = bottom + (@top - @bottom) @bottom = bottom end
move_left(left)
click to toggle source
# File lib/mahoujin/graphics/utilities/rectangle.rb, line 34 def move_left(left) @right = left + (@right - @left) @left = left end
move_right(right)
click to toggle source
# File lib/mahoujin/graphics/utilities/rectangle.rb, line 39 def move_right(right) @left = right + (@left - @right) @right = right end
move_top(top)
click to toggle source
# File lib/mahoujin/graphics/utilities/rectangle.rb, line 44 def move_top(top) @centerline = top + (@centerline - @top) @bottom = top + (@bottom - @top) @top = top end
sync_with(rectangle)
click to toggle source
# File lib/mahoujin/graphics/utilities/rectangle.rb, line 12 def sync_with(rectangle) @left, @top, @right, @bottom = rectangle.left, rectangle.top, rectangle.right, rectangle.bottom @centerline = rectangle.centerline end
width()
click to toggle source
# File lib/mahoujin/graphics/utilities/rectangle.rb, line 17 def width @right - @left end
width=(width)
click to toggle source
# File lib/mahoujin/graphics/utilities/rectangle.rb, line 21 def width=(width) @right = @left + width end