lib/geomotion/cg_point.rb in geomotion-0.1 vs lib/geomotion/cg_point.rb in geomotion-0.5
- old
+ new
@@ -4,11 +4,11 @@
CGPoint.new(options[:x] || 0, options[:y] || 0)
end
# size = CGSize.make width: 100, height: 100
# point = CPPoint.make x:0, y:10
- # point.rect_of_size(point) # => CGRect([0, 10], [100, 100])
+ # point.rect_of_size(size) # => CGRect([0, 10], [100, 100])
# point.rect_of_size([10, 20]) # => CGRect([10, 20], [100, 100])
def rect_of_size(size)
CGRect.new([self.x, self.y], size)
end
@@ -29,8 +29,20 @@
CGRectContainsPoint(rect, self)
end
def ==(point)
point.is_a?(CGPoint) && CGPointEqualToPoint(self, point)
+ end
+
+ def -@
+ CGPoint.new(-self.x, -self.y)
+ end
+
+ def -(other)
+ self.+(-other)
+ end
+
+ def inspect
+ "#{self.class.name}(#{self.x}, #{self.y})"
end
end