class Vamp::Graphic::Dotter

basis class for graphic implementations you have to implement :dot, :undot, :clear and :screen

Attributes

height[R]
width[R]

Public Class Methods

new(width, height) click to toggle source
# File lib/vamp/graphic/dotter.rb, line 9
def initialize(width, height)
  @width = width
  @height = height
  clear
end

Public Instance Methods

check(x, y) click to toggle source

check if (x, y) is on the screen, fails if not

# File lib/vamp/graphic/dotter.rb, line 47
def check(x, y)
  fail "for (#{x}, #{y}}: x not in [0, #{width}["  unless (0...width)  === x
  fail "for (#{x}, #{y}}: y not in [0, #{height}[" unless (0...height) === y
end
clear() click to toggle source

clear screen of all dots

# File lib/vamp/graphic/dotter.rb, line 33
def clear
  self
end
dot(x, y) click to toggle source

put dot at x, ys

# File lib/vamp/graphic/dotter.rb, line 16
def dot(x, y)
  check(x, y)
  self
end
dot?(x, y) click to toggle source

is there a dot at x, y

# File lib/vamp/graphic/dotter.rb, line 22
def dot?(x, y)
  check(x, y)
end
in?(x, y) click to toggle source

check if (x, y) is on the screen

# File lib/vamp/graphic/dotter.rb, line 42
def in?(x, y)
  (0...width)  === x && (0...height) === y
end
screen() click to toggle source

return complete screen as string representation

# File lib/vamp/graphic/dotter.rb, line 38
def screen
end
undot(x, y) click to toggle source

remove dot at x, y

# File lib/vamp/graphic/dotter.rb, line 27
def undot(x, y)
  check(x, y)
  self
end