Sha256: 37bc97eab0d6f914b1e3b8c31b6b343e36f48c3deda80c5c8683e2149641fcc2

Contents?: true

Size: 759 Bytes

Versions: 4

Compression:

Stored size: 759 Bytes

Contents

module GuiGeometry
class Point < Struct.new(:x, :y)
  include Tools

  def initialize(*args)
    self.x = self.y = 0
    super if args.length!=0
  end

  def min(b); point(super(x, b.x), super(y, b.y)); end
  def max(b); point(super(x, b.x), super(y, b.y)); end

  def inspect; "point(#{x},#{y})" end
  def to_s; "(#{x},#{y})" end

  def >=(b) x>=b.x && y>=b.y end
  def <=(b) x<=b.x && y<=b.y end
  def >(b) x>b.x && y>b.y end
  def <(b) x<b.x && y<b.y end

  def +(b) b.kind_of?(Point) ? point(x+b.x, y+b.y) : point(x+b, y+b) end
  def -(b) b.kind_of?(Point) ? point(x-b.x, y-b.y) : point(x-b, y-b) end
  def *(b) b.kind_of?(Point) ? point(x*b.x, y*b.y) : point(x*b, y*b) end
  def /(b) b.kind_of?(Point) ? point(x/b.x, y/b.y) : point(x/b, y/b) end
end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
gui_geometry-0.0.6 lib/gui_geometry/point.rb
gui_geometry-0.0.5 lib/gui_geometry/point.rb
gui_geometry-0.0.4 lib/gui_geometry/point.rb
gui_geometry-0.0.1 lib/gui_geometry/point.rb