Module: Dieses::Geometry::Rect::Predicate

Included in:
Dieses::Geometry::Rect
Defined in:
lib/dieses/geometry/rect.rb

Instance Method Summary collapse

Instance Method Details

#cover?(element) ⇒ Boolean

Returns:

  • (Boolean)


106
107
108
109
# File 'lib/dieses/geometry/rect.rb', line 106

def cover?(element)
  bbox = element.bbox
  inside?(bbox.minimum) && inside?(bbox.maximum)
end

#inside?(point) ⇒ Boolean

Returns:

  • (Boolean)


92
93
94
95
96
# File 'lib/dieses/geometry/rect.rb', line 92

def inside?(point)
  onto?(point) || (
    left.right?(point) && right.left?(point) && top.left?(point) && bottom.right?(point)
  )
end

#onto?(point) ⇒ Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/dieses/geometry/rect.rb', line 102

def onto?(point)
  left.onto?(point) || right.onto?(point) || top.onto?(point) || bottom.onto?(point)
end

#outside?(point) ⇒ Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/dieses/geometry/rect.rb', line 98

def outside?(point)
  !inside?(point)
end