CanvasCLI¶
Description¶
The simple console version of a drawing program!
- Free software: MIT license
- Documentation: https://canvascli.readthedocs.io.
Features¶
At this time, the functionality of the program is quite limited but this might change in the future. In a nutshell, the program should work as follows:
- Create a new canvas
- Start drawing on the canvas by issuing various commands
- Quit
At the moment, the program supports the following commands:
- Create the Canvas
- Draw a Line (Only horizontal and vertical lines are supported!)
- Draw a Rectangle
- Fill a Region with a given Color
- Erase the Canvas
- Quit
If you want to resize the Canvas after it has been created you can run the create command again, but you will be asked for confirmation as the previous canvas will be replaced by the new one!
Example¶
$ canvascli
Enter command: C 20 4
----------------------
| |
| |
| |
| |
----------------------
Enter command: L 1 2 6 2
----------------------
| |
|xxxxxx |
| |
| |
----------------------
Enter command: L 6 3 6 4
----------------------
| |
|xxxxxx |
| x |
| x |
----------------------
Enter command: R 16 1 20 3
----------------------
| xxxxx|
|xxxxxx x x|
| x xxxxx|
| x |
----------------------
Enter command: B 10 3 o
----------------------
|...............xxxxx|
|xxxxxx.........x x|
| x.........xxxxx|
| x..............|
----------------------
Enter command: E
----------------------
| |
| |
| |
| |
----------------------
Enter command: Q
Lowercase commands are also valid!
Help¶
When running canvascli at any moment the help can be viewed typing H
$ canvascli
Enter command: H
CanvasCLI: the simple console version of a drawing program!
===========================================================
Program commands:
-----------------
H Display help
C width height Create a new canvas of given size
width: Canvas width
height: Canvas height
L x1 y1 x2 y2 Draw a Line from (x1,y1) to (x2,y2)
x1: Point 1 x coordinate
y1: Point 1 y coordinate
x2: Point 2 x coordinate
y2: Point 2 y coordinate
R x1 y1 x2 y2 Draw a Rectangle given by (x1,y1) and (x2,y2)
x1: Upper left corner x coordinate
y1: Upper left corner y coordinate
x2: Lower right corner x coordinate
y2: Lower right corner y coordinate
B x y color Fill the area connected to (x,y) with color
x: Point x coordinate
y: Point y coordinate
color: Expressed as an ASCII single character
E Erase the contents of the canvas.
Q Quit program
Notes:
- Currently only horizontal or vertical lines are supported.
- Horizontal and vertical lines will be drawn using the 'x' character.
Testing¶
To run the test suite you need to install pytest and pytest-cov and run:
$ pip install pytest pytest-cov
$ pytest tests/ --cov=canvascli
Currently the canvas and utils modules have 100% code coverage. The parser and the cli modules have only partial coverage but we are working hard on improving this!
Code style¶
We try to follow PEP8 and use Flake8 to check code style.
To run the code style check you need to install flake8 and run:
$ pip install flake8
$ flake8 canvascli/
Credits¶
- This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
- This package was inspired by a Huge Coding challenge!