Using Unicode braille characters to draw pixels in console.
Project description
瞽字象形 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,True
represents the point's existence andFalse
represents 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pydrawille-0.0.1.1.tar.gz
.
File metadata
- Download URL: pydrawille-0.0.1.1.tar.gz
- Upload date:
- Size: 19.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d10885f7b99fc014f677abc9db448fbd5dcabc6ba3fed133cd373ad9166d0290 |
|
MD5 | 091c51aae1571c838f4b4b5902a76b19 |
|
BLAKE2b-256 | 1fa979a886eb052e561627578e09897afd3419707f34e0f0d434581eebe5e08f |
File details
Details for the file PyDrawille-0.0.1.1-py3-none-any.whl
.
File metadata
- Download URL: PyDrawille-0.0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d59ae2b005ab278fe50838a4d927f9fb54a1932670ac0affd000e53b8aebe0a |
|
MD5 | 402f7a3eeada6a77f4932d7d58c0b8ac |
|
BLAKE2b-256 | d7a2ef7da914aac26a6561df905140b7076052362f8b34077ed8aa632299d144 |