瞽字象形 PyDrawille
Using Unicode braille characters to draw pixel graphics in a console.
此自述文件亦可见于诸下文字
The README is also in
🇨🇳 Chinese 汉语
The aim of the library's development is to avoid the drawille library's AGPLv3 license trapping. We use a totally different logic to achieve the same functionality, in the hope of creating a fully independent and free software. To preserve the original source's independence, we did not use the API of drawille library, and did not use the same code logic, allowing a completely entirely new way to present the braille characters' graphics.
Function description
Class definition
This library defines a CanvasSurface as the base class for drawing pixel canvas. It provides various methods to operate on the canvas and finally convert it to braille strings or images.
Basic attributes
_width: Canvas width, used internally, should not be directly modified._height: Canvas height, used internally, should not be directly modified.data: Canvas data, stored in a NumPy array, Boolean type,Truerepresents the point's existence andFalserepresents the oppsite.
Constructors
-
__init__: Initialize canvas, which can specify width, height, initial data and fill value. By default, the width is twice that of the terminal width, and the height is four times that of the terminal height. -
from_image: Create a canvas from an image, with all its pixels will be converted to bw colors.
Attributes
surface_width: Get canvas width.surface_height: Get canvas height.surface_size: Get canvas size and return a tuple (width, height).
Instance function
reshape_canvas: Resizes canvas without scaling content.resize_image: Scales entire canvas, supports multiple interpolation methods.stack: Stacks another canvas object on top of current canvas, supports horizontal and vertical stacking. (Stitching canvas)rorate: Rotates canvas and its image, supports rotation by 90 degrees, 180 degrees, or 270 degrees.reset: Resets canvas. get_pixel: Gets pixel at specified coordinates.set_pixel: Sets pixel at specified coordinates.set_pixels: Uses X and Y sequences to set multiple pixels faster than set_points.set_points: Uses sets of coordinates to set multiple pixels.set_line: Sets a row of pixels. set_column: Sets a column of pixels.set_block: Sets pixels in an area. set_canvas: Sets all pixels on canvas.reverse_pixel: Flips pixel at specified coordinates. (Invert color of one point)reverse_line: Flips line of pixels. (Invert color of one row)reverse_column: Flips column of pixels. (Invert color of one column)reverse_block: Flips pixels in an area. (Invert color of one region)reverse_canvas: Flips all pixels on canvas.dump_lines: Braille character string iterator divided by lines.dump: Generates braille character string from all pixels on canvas.dump_singleline: Generates braille character string for specified line, iterating each character.to_image: Generates image from canvas.dump_image: Generates braille character string image from canvas, supporting specifying font, background color, and foreground color.
Static functions
walk_line: A linear iterator that returns all coordinates on a line.
Example usage
# Create a canvas
canvas = CanvasSurface(width=100, height=50)
# Set some pixels
canvas.set_pixel(10, 10, True)
canvas.set_pixel(15, 15, True)
# Make a braille character drawing string
braille_art = canvas.dump()
print(braille_art)
# Dumps to a image
image = canvas.to_image()
image.show()
# Make a braille character drawing image
font = ImageFont.truetype("FontSupportsBraille.ttf", 24)
braille_image = canvas.dump_image(font, backgrand_color=0, foreground_color=255)
braille_image.show()
Acknowledgements
- Thanks for the outstanding contribution of the FSF (Free Software Foundation) in promoting software non-freedom. The so-called free software is meaningless if it merely relies on developers' non-freedom. In the self-introduction “The Free Software Foundation (FSF) is a nonprofit with a worldwide mission to promote computer user freedom. We defend the rights of all software users.” by the Free Software Foundation, I believe they indeed try to protect computer users' freedom and also attempt to deprive developers of their right to freely develop software. I believe that true freedom can only be called real freedom when it is established on the breadth of humanity. Partial freedom cannot be called freedom; it's just a form of slavery over others. We need to defend developers' freedom and their right to rationally manage their intellectual property.
Metadata
Release files for PyDrawille 0.0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pydrawille-0.0.1.2.tar.gz | 14.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pydrawille-0.0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 29.1 kB
Release files / pydrawille-0.0.1.2.tar.gz
| Download URL | pydrawille-0.0.1.2.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e065f0992b0fe4866b2b46a4075adaaa8a7c44f6b7ea333c4c885b719c7abb2d
|
|
BLAKE2b-256 checksum How to use checksums |
83ffb11087d1d08f62bb90a75c08e9ed6dd8c17fa9b8d1a96c20ab1df860f0ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.14
|
Release files / pydrawille-0.0.1.2-py3-none-any.whl
| Download URL | pydrawille-0.0.1.2-py3-none-any.whl |
|---|---|
| Size | 14.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
47c9cc201bec1471a0f58e251058f31e6f6c564b0a3e882bb1602816094ea391
|
|
BLAKE2b-256 checksum How to use checksums |
40ad9ced154ec7866232927b998ce0688229f725227a17cda61b27a3bec37e54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.14
|