Here is my attempt for Creditspring technical test.
In order to run the program:
-
clone the repo
-
run
./bitmap-editor.rb
in the root of the repo
Here are the commands:
I M N - Create a new M x N canvas with all pixels coloured white
C - Clears canvas
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)
F X Y C - Fill the region (X,Y) with the colour C
W F - Scales the canvas with the given factor F
S - Show the contents of the current canvas
X - Terminate the session
? - Shows in program help