Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/paulschweizer/ascii-canvas
Treat strings like Items on a 2D Canvas
https://github.com/paulschweizer/ascii-canvas
2d-canvas ascii-art asciiart canvas drawing python
Last synced: 9 days ago
JSON representation
Treat strings like Items on a 2D Canvas
- Host: GitHub
- URL: https://github.com/paulschweizer/ascii-canvas
- Owner: PaulSchweizer
- License: mit
- Created: 2017-10-01T11:23:53.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-20T17:35:55.000Z (8 months ago)
- Last Synced: 2024-03-21T08:17:25.676Z (8 months ago)
- Topics: 2d-canvas, ascii-art, asciiart, canvas, drawing, python
- Language: Python
- Size: 94.7 KB
- Stars: 7
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Version](https://img.shields.io/pypi/v/ascii_canvas.svg)](https://pypi.org/project/ascii_canvas/)
# Treat Strings like Items on a 2D Canvas
With this primitive library you can do things like this:
```python
from ascii_canvas import canvas
from ascii_canvas import itemcanvas_ = canvas.Canvas()
rect_a = item.Item('+-----+\n|Hello|\n+-----+', position=[0, 0])
rect_b = item.Item('+-----+\n|World|\n+-----+', position=[16, 5])
rect_c = item.Item('+-+\n|!|\n+-+', position=[32, 0])
line_a = item.Line(start=[7, 1], end=[15, 6])
line_b = item.Line(start=[23, 6], end=[31, 1])canvas_.add_item(rect_a)
canvas_.add_item(rect_b)
canvas_.add_item(rect_c)
canvas_.add_item(line_a)
canvas_.add_item(line_b)
print(canvas_.render())
```Which results in this output:
```
+-----+ +-+
|Hello|----+ +----|!|
+-----+ | | +-+
| |
| |
| +-----+ |
+----|World|----+
+-----+
```