Skip to main content

A simple python drawing package

Project description

lpdraw

This is a simple drawing package that contains Line and Circle Drawing Algorithms. This package can display the output on terminal as well as visually appealing grayscale image.

Usage

Example:

from lpdraw import Line, Circle, Clear, DisplayTerminal
from lpython import i32, Const

from numpy import empty, int32

def main():
    Width: Const[i32] = 100 # x-axis limits [0, 99]
    Height: Const[i32] = 40 # y-axis limits [0, 39]
    Screen: i32[Height, Width] = empty((Height, Width), dtype=int32)

    Clear(Height, Width, Screen)
    Line(Height, Width, Screen, 2, 4, 99, 11)
    Line(Height, Width, Screen, 0, 39, 49, 0)
    Circle(Height, Width, Screen, 52, 20, 6.0)
    DisplayTerminal(Height, Width, Screen)

main()

Output:

$ python main.py
+----------------------------------------------------------------------------------------------------+
|.                                                                                                   |
| .                                                                                                  |
|  ..                                                                                                |
|    .                                                                                               |
|     .                                                                                              |
|      .                                                                                             |
|       ..                                                                                           |
|         .                                                                                          |
|          .                                                                                         |
|           .                                                                                        |
|            ..                                                                                      |
|              .                                                                                     |
|               .                                                                                    |
|                .                                   .                                               |
|                 ..                               .. ..                                             |
|                   .                             .     .                                            |
|                    .                           .       .                                           |
|                     .                         .         .                                          |
|                      ..                       .         .                                          |
|                        .                     .           .                                         |
|                         .                     .         .                                          |
|                          ..                   .         .                                          |
|                            .                   .       .                                           |
|                             .                   .     .                                            |
|                              .                   .. ..                                             |
|                               ..                   .                                               |
|                                 .                                                                  |
|                                  .                                                                 |
|                                   .                                                         .......|
|                                    ..                                         ..............       |
|                                      .                          ..............                     |
|                                       .           ..............                                   |
|                                     ..............                                                 |
|                       ..............    ..                                                         |
|         ..............                    .                                                        |
|  .......                                   .                                                       |
|                                             .                                                      |
|                                              ..                                                    |
|                                                .                                                   |
|                                                 .                                                  |
+----------------------------------------------------------------------------------------------------+

You can also use the Display() provided in this package to generate a grascale .pgm image. You need to save the output produced on execution to a .pgm file. For example,

python main.py > img.pgm

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

lpdraw-0.0.1.1.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

lpdraw-0.0.1.1-py3-none-any.whl (3.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