asciimoo / drawille Goto Github PK
View Code? Open in Web Editor NEWPixel graphics in terminal with unicode braille characters
License: GNU Affero General Public License v3.0
Pixel graphics in terminal with unicode braille characters
License: GNU Affero General Public License v3.0
Another implementation being actively maintained in Perl is Term-Graille (to differentiate from hoelzro/Term-Drawille which is 8 years old. Like Drawille, offers turtlescript, fonts/image importing, various graphics primitives etc
I would like to call .forward()
or .fd()
without enabling the brush.
I'm using .up()
and .down()
to control the brush but forward
implicitly enables the brush and I would like to know why this is intended behaviour.
The fix for me would be removing these lines from drawille.py
.
prev_brush_state = self.brush_on
self.brush_on = True
self.brush_on = prev_brush_state
I'm currently having a blast using drawille!
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⢇⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠤⠒⠉⠀⠀⠈⠑⠢⢄
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠊⢹⠉⠒⠤⣀⢀⡠⠔⠊⢹⠉⠢⢄⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⢸⠀⠀⠀⠀⡇⠀⠀⠀⢸⠀⠀⠀⢸
⠀⠀⠀⣀⠤⠢⢄⡀⠀⢸⠀⠀⡠⠜⠀⠀⠀⠀⡇⠀⠀⠀⠘⠤⡀⠀⢸⠀⠀⣀⠤⠢⢄⡀
⠠⣒⠉⠀⠀⠀⠀⠈⢑⣺⣒⠉⠀⠀⠀⠀⠀⠀⡇⠀⠀⠀⠀⠀⠈⢑⣺⣒⠉⠀⠀⠀⠀⠈⢑⡢
⠀⠀⠉⠒⠤⡠⠔⠊⠁⢸⠀⠉⠢⢄⠀⠀⠀⠀⡇⠀⠀⠀⢀⠤⠊⠁⢸⠀⠉⠒⠤⡠⠔⠊⠁
⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⢸⠀⠀⠀⠀⡇⠀⠀⠀⢸⠀⠀⠀⢸
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠒⠤⡀⢸⠀⣀⠤⠒⠑⠢⢄⡀⢸⠀⡠⠔⠊
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠭⣀⠀⠀⠀⠀⢀⡨⠝⠉
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠒⡔⠊⠁
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡇
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁
I'd like to use drawille
on a Windows operating system (Windows 7 or 10). After successfully installing the drawille
package into my virtual environment, using pip
, using it by typing
>>> from drawille import Canvas
leads to this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\nnako\ENV__Python27\lib\site-packages\drawille.py", line 23, in <module>
import curses
File "C:\PROGS\Python__v2_7_9\Lib\curses\__init__.py", line 15, in <module>
from _curses import *
ImportError: No module named _curses
So, it seems, there is a dependency on the curses
package and Windows doesn't provide the package, natively. So I installed curses
using the instructions from this StackOverflow post. But when I now enter my python installation and enter the following lines:
>>> from drawille import Canvas
>>> c=Canvas()
>>> c.set(10,10)
>>> print(c.frame())
the result on screen is:
Ôáä
and not a dot as expected (and as I see when using my Linux computer and the same lines of code).
Any hints?
I'm running OS X, El Capitan, Terminal.app.
Traceback (most recent call last):
File "term_display.py", line 108, in <module>
curses.wrapper(__main__, projection)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/curses/wrapper.py", line 43, in wrapper
return func(stdscr, *args, **kwds)
File "rotating_cube.py", line 94, in __main__
stdscr.addstr(0, 0, '{0}\n'.format(f))
_curses.error: addstr() returned ERR
I changed line 93 to:
f = c.frame(-40, -40, 40, 40)
And it worked.
I was wondering whether or not the choice of AGPL was intentional, given it restricts the use in many projects that can't change their license to use it. Will it be possible to consider switching to a more permissive license?
I also see that node-drawille, which is a pretty direct translation is licensed under MIT...
Hi!
I made an Elisp implementation. It is based on matrix: It convert a 2d vector to a drawille "image".
Here it is:
https://github.com/sshbio/elisp-drawille
It is very basic, but can also convert a string.
I enjoyed using drawille, and enjoyed writing this as well, so thank you!
Github user 'sshbio' apparently changed their username to 'josuah'. Please fix links in README.md
I found this through the vim-minimap plugin and I figured I'd write an implementation in my language of choice, would be nice if it could be added to the list: https://github.com/PMunch/drawille-nim
How can I add colors to the objects? I am trying to make a Rubix cube game in the terminal. I am successful in making the cube, but struck at implementing the colors. Can anyone look at my code and help me to make the colors for the individual face?
This is my code: https://github.com/devallabharath/Terminal-Rubix-Cube/blob/main/ex.py
I have Python 2.7.5 on Mac OSX Mavericks with PIL 1.1.7 and I get the following when running the xkcd.py example:
Traceback (most recent call last):
File "xkcd.py", line 66, in <module>
for pix in i.tobytes():
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 512, in __getattr__
raise AttributeError(name)
AttributeError: tobytes
I was able to fix it by changing line 66 from:
for pix in i.tobytes():
to
for pix in i.tostring():
I found it with some help from this stackoverflow question. It seems like the official PIL 1.1.7 still uses the tostring method while Pillow is deprecating it in favor of tobytes (although it still supports the old one).
A simple approach to deal with this could be to just test the attribute first:
try:
i_converted = i.tobytes()
except AttributeError:
i_converted = i.tostring()
for pix in i_converted:
(...)
I see that this issue has been raised 7 years ago but I thought I'd see whether anything has changed since then. In particular, python now has the two libraries Rich and Textual that have improved (or soon will improve) python CLI and TUI applications. Being able to have some graphics drawing functionality would be a great addition but both libraries are licenced under the MIT licence, so using drawille would require all applications using it to be released under the AGPL.
Is there any appetite for changing the licence to something more permissive (not necessarily MIT but maybe LGPL?)
Just as a point of interest, it seems like it's a 50/50 split between MIT or AGPL for the other implementations/similar projects mentioned in the README.
Is there a way to add color support? Alternatively, is there another similar terminal canvas drawing library that you know of that has color support?
Thanks
I have Python 2.7.6 on Ubuntu 14.04 64b. I typed sudo pip install drawille
to get drawille.
When I tried to run the example put in the README on GitHub, I got the following message:
Traceback (most recent call last):
File "drawille.py", line 2, in <module>
from drawille import Canvas
File "/home/guillaume/Documents/drawille.py", line 2, in <module>
from drawille import Canvas
ImportError: cannot import name Canvas
The script is only 17 lines of working code, and it use external tool. I use it with imagemagick to convert images to pbm format, and then change the output with sed.
It is not a request or anything, just letting you know that it exists.
Here it is in my ~/bin/
: https://github.com/sshbio/dot/blob/master/bin/drawk
And here is the gist for it: https://gist.github.com/sshbio/cb0073a0e8c50a681288c8bff74d9c4b
Hi,
Started porting drawille to Go, but I ran into some issues. It may be related to the rounding of numbers, not entirely sure yet.
https://github.com/xyproto/drawillego
The rotating cube example works, but it looks slightly wonky.
I write this in case you wanted to list the port together with the other ports and also for help if you should happen to spot the bug in the Go port.
Best regards,
Alexander Rødseth
After successfully installing using the pip command using python3.7, I try running any of the examples.
However, I get a Canvas not found error immediately.
$python drawille.py
Traceback (most recent call last):
File "drawille.py", line 5, in <module>
from drawille import Canvas
File "/Users/*********/repos/drawille/drawille.py", line 5, in <module>
from drawille import Canvas
ImportError: cannot import name Canvas
$python3 drawille.py
Traceback (most recent call last):
File "drawille.py", line 5, in <module>
from drawille import Canvas
File "/Users/*********/repos/thermal_testing/drawille.py", line 5, in <module>
from drawille import Canvas
ImportError: cannot import name 'Canvas' from partially initialized module 'drawille' (most likely due to a circular import) (/Users/*********/repos/thermal_testing/drawille.py)
I got this when running image2term.py
from examples.
Traceback (most recent call last):
File "image2term.py", line 107, in <module>
__main__()
File "image2term.py", line 102, in __main__
args['output'].write(image2term(args['image'], args['threshold'], args['ratio']))
File "image2term.py", line 66, in image2term
return can.frame()
File "/tmp/drawille/examples/drawille.py", line 403, in frame
return self.line_ending.join(self.rows())
File "/tmp/drawille/examples/drawille.py", line 354, in rows
minrow = min(self.pixels.keys())
ValueError: min() arg is an empty sequence
I tried to inspect and conclude that it was because the (default) threshold causes the image become blank. I also tried to do a simple run by creating a Canvas()
and call frame()
. The result was the same, so that I conclude that a blank canvas leads to an error.
Unicode has quadrant characters (in http://www.fileformat.info/info/unicode/block/block_elements/utf8test.htm) that can also be used for drawing (with the benefit of being actually designed for that, at the expense of making this library slightly imprecisely named).
Would a patch for adding them as an optional parameter for Canvas.__init__ be considered?
I am using npyscreen to draw GUI like this :
https://raw.githubusercontent.com/MrRio/vtop/master/docs/example.gif
I need to set the size of the canvas and then blit pixels on it accordingly.
But, when I do this :
>>> c = Canvas()
# how to set canvas size ?
>>> c.set(100,20)
>>> print(c.frame())
⠁
It prints a dot at start, I want it to print at the desired location i.e x=100 and y=20.
How can I achieve the behavior I am looking for.
Thanks.
Hey,
So, I tried installing a bunch of fonts (including the ones you listed, such as Terminus), but I still have problems rendering the braille characters.
Can you link a font that will work for sure?
Or provide a way to patch in braille support in an existing font. There is https://aur.archlinux.org/packages/ttf-ubraille/ and I wonder if it can patched in with NerdFonts or something like this. I tried doing it myself, but without success.
A more concise explanation on how the fonts on the system must be configured to use this would be appreciated!
Would it be possible to set colors (e.g. RGB tuple) to the outputs?
After scouring the net, I wasn't able to find a .psf font for the Linux console that had support for Unicode, so I made one myself. It's derived from GNU Unifont and hand edited to resemble IBM Plex Mono, including lovingly crafted Braille characters.
It's only available in a 16x8 size, and only covers CP437, so may not be suitable for non English speakers, and the style may not be to everyone's liking, but it's the only way I found to get Braille characters on a vtty.
https://drive.google.com/file/d/1yoyhUHm2wCZfJSgAaW862asiMQfm3ckt/
but declaring it as one on setup.py can confuse people
i just wanted to say thanks, this is awesome !
maybe you enjoy some fractals:
⣄
⡿⠷⢄
⣿⣦⣸⣷⣄
⣷⣄⢸⣦⡀⣷⣄
⣯⡉⢹⣍⠉⣯⡉⢱⣄
⣟⠛⢺⡛⠓⣟⠛⢺⡛⠓⣄
⠿⠷⠼⠿⠦⠿⠷⠼⠿⠦⠿⠷⠄
⣖⣶⣲⣖⣶⣲⣖⣶⣲⣖⣶⣲⣖⡆
⣯⣇⣀⣯⣿⣽⣀⣸⣽⣯⣇⣀⣯⡇
⡷⣿⢾⡷⡟⠚⠓⠛⠚⡷⣿⢾⡷⡇
⣟⡏⠉⣟⡇⠀⠀⠀⠀⣟⡏⠉⣟⡇
⣯⣿⣽⣯⣇⣀⣀⣀⣀⣯⣿⣽⣯⡇
⡷⡟⠚⡷⣿⢾⠓⢻⢾⡷⡟⠚⡷⡇
⣟⣷⣲⣟⣿⣻⣖⣾⣻⣟⣷⣲⣟⡇
⠀⠀⠀⠀⠀⠀⣠⡀
⠀⠀⠀⠀⠠⠦⠴⠤⠦
⠀⠀⡀⠀⠀⠀⢀⠀⠀⠀⠀⡀
⣠⣈⣍⣠⣀⣄⣩⣁⣄⣠⣈⣍⣠⡀
⡢⡂⠀⡢⡂⠀⠀⠀⠀⡢⡂⠀⡢⡂
⡀⡨⠪⡀⡀⠀⠀⠀⠀⡀⡨⠪⡀⡀
⠊⠂⠀⠊⠢⡠⠀⠠⡠⠊⠂⠀⠊⠂
⠀⠀⠀⠀⠈⠈⡢⡊⠈
⡀⡀⠀⡀⡨⠪⠀⠨⠪⡀⡀⠀⡀⡀
⠊⠢⡠⠊⠂⠀⠀⠀⠀⠊⠢⡠⠊⠂
⡢⡊⠈⡢⡂⠀⠀⠀⠀⡢⡊⠈⡢⡂
⡢⡢⠀⠀⡢⡢⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡢⡢⠀⠀⡢⡢
⠈⠈⡢⡢⠈⠈⡢⡢⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢
⡢⡢⠈⠈⡢⡢⠈⠈⠀⠀⠀⠀⠀⠀⠀⠀⡢⡢⠈⠈⡢⡢⠈⠈
⠈⠈⡢⡢⠈⠈⡢⡢⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢
⠀⠀⠈⠈⠀⠀⠈⠈⡢⡢⠀⠀⡢⡢⠀⠀⠀⠀⠈⠈⠀⠀⠈⠈⡢⡢⠀⠀⡢⡢
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢
⠀⠀⠀⠀⠀⠀⠀⠀⡢⡢⠈⠈⡢⡢⠈⠈⠀⠀⠀⠀⠀⠀⠀⠀⡢⡢⠈⠈⡢⡢⠈⠈
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢
⡢⡢⠀⠀⡢⡢⠀⠀⠀⠀⠈⠈⠀⠀⠈⠈⡢⡢⠀⠀⡢⡢⠀⠀⠀⠀⠈⠈⠀⠀⠈⠈
⠈⠈⡢⡢⠈⠈⡢⡢⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢
⡢⡢⠈⠈⡢⡢⠈⠈⠀⠀⠀⠀⠀⠀⠀⠀⡢⡢⠈⠈⡢⡢⠈⠈
⠈⠈⡢⡢⠈⠈⡢⡢⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢
⠀⠀⠈⠈⠀⠀⠈⠈⡢⡢⠀⠀⡢⡢⠀⠀⠀⠀⠈⠈⠀⠀⠈⠈⡢⡢⠀⠀⡢⡢
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢
⠀⠀⠀⠀⠀⠀⠀⠀⡢⡢⠈⠈⡢⡢⠈⠈⠀⠀⠀⠀⠀⠀⠀⠀⡢⡢⠈⠈⡢⡢⠈⠈
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⡢⡢⠈⠈⡢⡢
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⠀⠀⠈⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠈⠀⠀⠈⠈
⢦⠆⠀⢦⠆⠀⠀⠀⠀⢦⠆⠀⢦⠆
⠳⢛⢞⠳⠃⠀⠀⠀⠀⠳⢛⢞⠳⠃
⣄⡌⠋⣄⣤⣠⠀⢠⣠⣄⡌⠋⣄⡄
⢮⠶⡴⢮⠶⡵⢦⠶⡵⢮⠶⡴⢮⠆
⠀⠘⠞⠀⢀⢀⠳⢃⢀⠀⠘⠞
⠀⠀⠀⠀⢨⣫⣄⣬⣫
⠀⠀⠀⠀⠀⠁⢮⠆⠁
Sorry if I missed anything but Im just wondering how I could integrate PIL images with this?
this lib seems pretty cool so
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.