绘图程序的简单控制台版本!

canvascli的Python项目详细描述


canvascli

构建状态

Travis Continuous IntegrationAppveyor Continuous IntegrationCode coverageScrutinizer Code Quality

包裹信息

https://img.shields.io/pypi/v/canvascli.svgDocumentation Status

说明

绘图程序的简单控制台版本!

功能

此时,程序的功能非常有限,但这可能 未来的变化。简而言之,程序的工作原理如下:

  1. 创建新画布
  2. 通过发出各种命令在画布上开始绘图
  3. 退出

目前,程序支持以下命令:

  • 创建画布
  • 画一条线(只支持水平线和垂直线!)
  • 绘制矩形
  • 用给定的颜色填充区域
  • 擦除画布
  • 退出

如果要在画布创建后调整其大小,可以运行 再次创建命令,但将要求您像前面一样进行确认 画布将被新的取代!

安装

您可以使用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.

测试

要运行测试套件,您需要安装pytestpytest-cov并运行:

$ pip install pytest pytest-cov
$ pytest tests/ --cov=canvascli

目前canvas和utils模块有100%的代码覆盖率。分析器和 cli模块只有部分覆盖,但我们正在努力改进 这个!

代码样式

我们尝试遵循PEP8并使用Flake8检查代码样式。

要运行代码样式检查,您需要安装flake8并运行:

$ pip install flake8
$ flake8 canvascli/

学分

历史记录

0.1.0(2018-03-18)

  • pypi上的第一个版本。

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java jgrapht SimpleDirectedWeightedGraph规范化权重   java安卓使用CFB   java如何从javaclass警告浏览器?可能吗?   javagson结构难点   java使用jbossclient的最佳方式是什么。Wildfly 10应用程序中的jar?   JAVA:socket重写以使用CipherInputStream和CipherOutputStream   java Android UI测试长时间点击并拖动   java如何在Android中重置AtomicInteger唯一Id?   多线程客户端/服务器应用程序上的java客户端断开连接   GAE Memcache中的java损坏值   java如何使用变量作为资源的路径?   爪哇?(三向)操作员