Class: Vedeu::Canvas

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/vedeu/geometry/canvas.rb

Overview

The size of the terminal is a limitation. Defining a canvas means we have more space to ‘do stuff’.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#xnFixnum (readonly) Also known as: right, width

Returns:

  • (Fixnum)


17
18
19
# File 'lib/vedeu/geometry/canvas.rb', line 17

def xn
  @xn
end

#ynFixnum (readonly) Also known as: bottom, height

Returns:

  • (Fixnum)


11
12
13
# File 'lib/vedeu/geometry/canvas.rb', line 11

def yn
  @yn
end

Class Method Details

.canvasVedeu::Canvas

Returns:



22
23
24
# File 'lib/vedeu/geometry/canvas.rb', line 22

def self.canvas
  instance
end

Instance Method Details

#cArray Also known as: centre

Returns:

  • (Array)


37
38
39
# File 'lib/vedeu/geometry/canvas.rb', line 37

def c
  [cy, cx]
end

#configure(yn, xn) ⇒ Vedeu::Canvas

Parameters:

  • yn (Fixnum)
  • xn (Fixnum)

Returns:



29
30
31
32
33
34
# File 'lib/vedeu/geometry/canvas.rb', line 29

def configure(yn, xn)
  @yn = yn
  @xn = xn

  self
end

#cxFixnum Also known as: centre_x

Returns:

  • (Fixnum)


49
50
51
# File 'lib/vedeu/geometry/canvas.rb', line 49

def cx
  (width / 2) + x
end

#cyFixnum Also known as: centre_y

Returns:

  • (Fixnum)


43
44
45
# File 'lib/vedeu/geometry/canvas.rb', line 43

def cy
  (height / 2) + y
end

#oFixnum Also known as: origin

Returns:

  • (Fixnum)


55
56
57
# File 'lib/vedeu/geometry/canvas.rb', line 55

def o
  1
end

#xFixnum Also known as: left

Returns:

  • (Fixnum)


77
78
79
# File 'lib/vedeu/geometry/canvas.rb', line 77

def x
  1
end

#yFixnum Also known as: top

Returns:

  • (Fixnum)


71
72
73
# File 'lib/vedeu/geometry/canvas.rb', line 71

def y
  1
end