Sha256: e46a62c98aa9e26b373fba7e219b66484d54a62d01126d3b32c161c6d1021af6
Contents?: true
Size: 771 Bytes
Versions: 1
Compression:
Stored size: 771 Bytes
Contents
module OrangeZest # A box, with an origin in the top-left corner. class Box def initialize(origin, width, height) @origin = origin @width = width @height = height end attr_accessor :origin, :width, :height # Returns true if this box overlaps another box. def overlaps?(other) self.origin.x < other.origin.x + other.width \ && other.origin.x < self.origin.x + self.width \ && self.origin.y < other.origin.y + other.height \ && other.origin.y < self.origin.y + self.height end # Returns true if a point is inside this box. def point_inside?(point) point.x >= origin.x && point.x <= origin.x + width \ && point.y >= origin.y && point.y <= origin.y + height end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
orange_zest-0.1.0 | lib/orange_zest/box.rb |