class EightCorner::Bounds

Attributes

x[RW]

width

y[RW]

height

Public Class Methods

new(x=nil, y=nil) click to toggle source
# File lib/eight_corner/bounds.rb, line 11
def initialize(x=nil, y=nil)
  @x = x
  @y = y
end

Public Instance Methods

quadrant(point) click to toggle source
# File lib/eight_corner/bounds.rb, line 23
def quadrant(point)
  current = [
    point.x < x/2 ? 0 : 1,
    point.y < y/2 ? 0 : 1
  ]

  {
    [0,0] => Quadrant::UPPER_LEFT,
    [1,0] => Quadrant::UPPER_RIGHT,
    [0,1] => Quadrant::LOWER_LEFT,
    [1,1] => Quadrant::LOWER_RIGHT
  }[current]
end
x_from_pct(percent) click to toggle source
# File lib/eight_corner/bounds.rb, line 16
def x_from_pct(percent)
  @x * percent
end
y_from_pct(percent) click to toggle source
# File lib/eight_corner/bounds.rb, line 19
def y_from_pct(percent)
  @y * percent
end