绘图程序的简单控制台版本!
canvascli的Python项目详细描述
canvascli
功能
此时,程序的功能非常有限,但这可能 未来的变化。简而言之,程序的工作原理如下:
- 创建新画布
- 通过发出各种命令在画布上开始绘图
- 退出
目前,程序支持以下命令:
- 创建画布
- 画一条线(只支持水平线和垂直线!)
- 绘制矩形
- 用给定的颜色填充区域
- 擦除画布
- 退出
如果要在画布创建后调整其大小,可以运行 再次创建命令,但将要求您像前面一样进行确认 画布将被新的取代!
安装
您可以使用pip安装:
$ pip install canvascli
使用量
安装后,您可以通过执行以下命令从终端/cli运行
$ canvascli
示例
$ 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
小写命令也有效!
帮助
在任何时候运行canvascli时,都可以通过键入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.
测试
要运行测试套件,您需要安装pytest和pytest-cov并运行:
$ pip install pytest pytest-cov
$ pytest tests/ --cov=canvascli
目前canvas和utils模块有100%的代码覆盖率。分析器和 cli模块只有部分覆盖,但我们正在努力改进 这个!
学分
- 这个包是用Cookiecutter和audreyr/cookiecutter-pypackage项目模板创建的。
- 这个包的灵感来自于一个Huge编码挑战!
历史记录
0.1.0(2018-03-18)
- pypi上的第一个版本。