Skip to main content

Tremshape is a minimalistic Python packgage, that only prints basic shapes on terminal.

Project description

PyPI version fury.io codecov Tests Language grade: Python

termshape

Termshape is a minimalistic Python package, that only prints basic shapes on terminal. It does not have any dependencies.

You're welcome to add any shapes!

Installation

pip install termshape

Explanation:

The idea is to draw all the shapes as vectors, so you can set the size of any shape as you wish. Each shape has equations that print it. The get_* functions has (x,y) range and some equations, and from them it prints the shape.

Example:

from termshape import get_square
print(get_square(5))

so: x-range is between 0 and 4 y-range is between 0 and 4 and the equations are: x=0, y=0, x=5 and y=5.

See below the output.

Usage

  • Print a square:
from termshape import get_square
print(get_square(5))
* * * * *
*       *
*       *
*       *
* * * * *
  • Print a rectangle:
from termshape import get_rectangle 
print(get_rectangle(10, 5))
* * * * * * * * * *
*                 *
*                 *
*                 *
* * * * * * * * * *
  • Print a circle:
from termshape import get_circle
print(get_circle(10))
                  * * * * *                
              *               *            
          *                       *        
        *                           *      
      *                               *    
                                           
    *                                   *  
                                           
  *                                       *
  *                                       *
  *                                       *
  *                                       *
  *                                       *
                                           
    *                                   *  
                                           
      *                               *    
        *                           *      
          *                       *        
              *               *            
                  * * * * *                
  • Print a triangle:
from termshape import get_triangular
print(get_triangular(10))
*                  
* *                
*   *              
*     *            
*       *          
*         *        
*           *      
*             *    
*               *  
* * * * * * * * * *
  • Print a shape with custom character:
from termshape import get_rectangle
print(get_rectangle(10, 5, fg='$'))
$ $ $ $ $ $ $ $ $ $
$                 $
$                 $
$                 $
$ $ $ $ $ $ $ $ $ $
  • Print a shape with background:
from termshape import get_rectangle
print(get_square(10, bg='.'))
* * * * * * * * * *
* . . . . . . . . *
* . . . . . . . . *
* . . . . . . . . *
* . . . . . . . . *
* . . . . . . . . *
* . . . . . . . . *
* . . . . . . . . *
* . . . . . . . . *
* * * * * * * * * *
  • Print a shape with points:
from termshape import get_points
points_array = [(0, 0), (0, 9), (9, 0), (9, 9)]
print(get_points(10, 10, points_array, bg='.'))
* . . . . . . . . *
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
* . . . . . . . . *
  • Print numbers:
from termshape import get_number
print(get_number(31415926,3))
* * * *          *    *     *          *    * * * *    * * * *    * * * *    * * * *
      *          *    *     *          *    *          *     *          *    *      
      *          *    *     *          *    *          *     *          *    *      
* * * *          *    * * * *          *    * * * *    * * * *    * * * *    * * * *
      *          *          *          *          *          *    *          *     *
      *          *          *          *          *          *    *          *     *
* * * *          *          *          *    * * * *    * * * *    * * * *    * * * *
  • Print a custom shape using lines:
from termshape import get_lines
lines = [(0, 0), (9, 9), (0, 9), (9, 0), (0, 0)]
print(get_lines(10, 10, lines))
* * * * * * * * * *
  *             *  
    *         *    
      *     *      
        * *        
        * *        
      *     *      
    *         *    
  *             *  
* * * * * * * * * *

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

termshape-1.2.0.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

termshape-1.2.0-py3-none-any.whl (5.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page