Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Display Abstraction #7

Merged
merged 16 commits into from Aug 22, 2021
Merged

Feature: Display Abstraction #7

merged 16 commits into from Aug 22, 2021

Conversation

timfi
Copy link
Owner

@timfi timfi commented Aug 22, 2021

Closes #2

What's the idea?

One "nice to have" feature could be the addition of matrices that use other character sets for rendering. One nice set could be ▖▗▘▝▀▄▌▐▚▞▙▛▜▟█, i.e. a 2x2 grid per character.

Code

from dotmatrix import BlockMatrix

m = BlockMatrix(16, 8)

m.rectangle((0, 0), (15, 7))

print(m.render())

Output

▛▀▀▀▀▀▀▜
▌      ▐
▌      ▐
▌      ▐
▌      ▐
▌      ▐
▌      ▐
▙▄▄▄▄▄▄▟

from issue


How did I accomplish this?

To implement this I added the Display protocol/abstraction which describes all methods required for setting/getting pixel values and rendering said values to some useful output. The Braille logic has been moved to such a display (at dotmatrix.displays.Braille and remains the default display type. In addition to this I've also implemented a unicode block character display at dotmatrix.displays.Block.

Code

from dotmatrix import Matrix
from dotmatrix.displays import Block

m = Matrix(16, 16, display=Block)

m.rectangle((0, 0), (15, 15))
m.circle((7, 7), 7)

print(m.render())

Output

█▀▀██▀▀▀▀▀██▀▀▀█
█▄▀         ▀▄ █
█▀           ▀▄█
█             ██
█             ██
██           █ █
█ ▀▄▄     ▄▄▀  █
█▄▄▄▄█████▄▄▄▄▄█

@timfi timfi merged commit 02ed4ff into root Aug 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Different "Character sets"
1 participant