Sha256: 5b1d957b9220b79b5d609e6dcf50082dcf99ee19f39d5919165c9583ae5313c5

Contents?: true

Size: 723 Bytes

Versions: 1

Compression:

Stored size: 723 Bytes

Contents

require 'bitmapped/commands/base_command'
require 'bitmapped/commands/commands_helper'
require 'bitmapped/exceptions'

module Bitmapped
  module Commands
    class PixelFillCommand < BaseCommand
      include CommandsHelper

      def command_id
        "L"
      end

      def process_command(bitmap, input)
          Validators::ValidateBitmapInitialised.parse_and_validate(bitmap)
          column, row, color = Validators::ValidateFillInput.parse_and_validate(input)
          color_command(bitmap, column, row, color)
      end

      private
        def color_command(bitmap, x, y, color)
          x, y = coordinates_to_array_indexes(bitmap, x, y)
          bitmap.pixels[y][x] = color
        end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bitmapped-0.2.0 lib/bitmapped/commands/pixel_fill_command.rb