Build Status Maintainability Test Coverage

BitmapCompiler

This is the Bitmap compiler gem! It aims to build a Bitmap given an input file.

You can check on spec/support folder to see examples. The supported commands are:

I M N       - Create a new M x N image with all pixels coloured white (O).
C           - Clears the table, setting all pixels to white (O).
L X Y C     - Colours the pixel (X,Y) with colour C.
V X Y1 Y2 C - Draw a vertical segment of colour C in column X between rows Y1 and Y2 (inclusive).
H X1 X2 Y C - Draw a horizontal segment of colour C in row Y between columns X1 and X2 (inclusive).
S           - Show the contents of the current image
  • The maximum size allowed when creating an Image is 250x250
  • Colors must be a single capital character A-Z

Example of file

Input: show.txt

I 5 6 
L 1 3 A 
V 2 3 6 W 
H 3 5 2 Z 
S

Output

OOOOO
OOZZZ
AWOOO
OWOOO
OWOOO
OWOOO

Installation

Add this line to your application's Gemfile:

gem 'bitmap_compiler'

And then execute:

$ bundle

Or install it yourself as:

$ gem install bitmap_compiler

Usage

You can use the application programmatically by installing the gem and using on the Ruby environment (You can run bin/console for this). Check the examples folder for more examples.

BitmapCompiler::Core::Editor.new.run('spec/support/show.txt')

There is also a CLI provided that can be used.

CLI

The application also has a CLI built-in that can be used directly on any *nix terminal.

$ bitmap_compiler process_file --file=spec/support/show.txt

Use the help command for more information.

$ bitmap_compiler help process_file

Development

After checking out the repo, run bin/setup to install dependencies. Then, run bundle exec rspec spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

Contributing

See CONTRIBUTING.md.

License

The gem is available as open source under the terms of the MIT License.