Sha256: bdd549a49e95d820f034372edeca4b13f4a547c727a60a9d1b3a47fac0e7653b
Contents?: true
Size: 902 Bytes
Versions: 1
Compression:
Stored size: 902 Bytes
Contents
require 'bitmapped/commands/base_command' require 'bitmapped/commands/commands_helper' require 'bitmapped/exceptions' module Bitmapped module Commands class VerticalLineCommand < BaseCommand include CommandsHelper def command_id "V" end 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 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 end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
bitmapped-0.2.0 | lib/bitmapped/commands/vertical_line_command.rb |