class Bitmapped::Commands::VerticalLineCommand

Public Instance Methods

command_id() click to toggle source
# File lib/bitmapped/commands/vertical_line_command.rb, line 10
def command_id
  "V"
end
process_command(bitmap, input) click to toggle source
# File lib/bitmapped/commands/vertical_line_command.rb, line 14
def process_command(bitmap, input)
  Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
  column, start, finish, color = Validators::ValidateSegmentInput.parse_and_validate(input)
  vertical_command(bitmap, column, start, finish, color)
end

Private Instance Methods

vertical_command(bitmap, column, x, y, color) click to toggle source
# File lib/bitmapped/commands/vertical_line_command.rb, line 21
def vertical_command(bitmap, column, x, y, color)
  raise InvalidCoordinatesError unless (0 < column && column <= bitmap.columns)
  x, y = coordinates_to_array_indexes(bitmap, x, y)
  column = column - 1
  bitmap.pixels[x..y].each { |row| row[column] = color }
end