Class: GuiGeo::Point

Inherits:
Struct
  • Object
show all
Includes:
Tools
Defined in:
lib/gui_geometry/point.rb

Constant Summary

Constants included from GuiGeo

VERSION

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Tools

#clone_value, #minmax

Methods included from GuiGeo

#point, #rect

Constructor Details

#initialize(*args) ⇒ Point

Returns a new instance of Point.



5
6
7
8
# File 'lib/gui_geometry/point.rb', line 5

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

Instance Attribute Details

#xObject Also known as: w, width, col, column

Returns the value of attribute x

Returns:

  • (Object)

    the current value of x



2
3
4
# File 'lib/gui_geometry/point.rb', line 2

def x
  @x
end

#yObject Also known as: h, height, line

Returns the value of attribute y

Returns:

  • (Object)

    the current value of y



2
3
4
# File 'lib/gui_geometry/point.rb', line 2

def y
  @y
end

Instance Method Details

#*(b) ⇒ Object



35
# File 'lib/gui_geometry/point.rb', line 35

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

#+(b) ⇒ Object



33
# File 'lib/gui_geometry/point.rb', line 33

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

#-(b) ⇒ Object



34
# File 'lib/gui_geometry/point.rb', line 34

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

#/(b) ⇒ Object



36
# File 'lib/gui_geometry/point.rb', line 36

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

#<(b) ⇒ Object



31
# File 'lib/gui_geometry/point.rb', line 31

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

#<=(b) ⇒ Object



29
# File 'lib/gui_geometry/point.rb', line 29

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

#>(b) ⇒ Object



30
# File 'lib/gui_geometry/point.rb', line 30

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

#>=(b) ⇒ Object



28
# File 'lib/gui_geometry/point.rb', line 28

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

#areaObject



38
# File 'lib/gui_geometry/point.rb', line 38

def area; x*y; end

#bound(a, b) ⇒ Object



21
# File 'lib/gui_geometry/point.rb', line 21

def bound(a, b); point(Tools::bound(a.x, x, b.x), Tools::bound(a.y, y, b.y)); end

#cloneObject



23
# File 'lib/gui_geometry/point.rb', line 23

def clone; point(clone_value(x), clone_value(y)); end

#inspectObject



25
# File 'lib/gui_geometry/point.rb', line 25

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

#max(b) ⇒ Object



20
# File 'lib/gui_geometry/point.rb', line 20

def max(b); point(Tools::max(x, b.x), Tools::max(y, b.y)); end

#min(b) ⇒ Object



19
# File 'lib/gui_geometry/point.rb', line 19

def min(b); point(Tools::min(x, b.x), Tools::min(y, b.y)); end

#to_sObject



26
# File 'lib/gui_geometry/point.rb', line 26

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