Showing posts with label library. Show all posts
Showing posts with label library. Show all posts

Friday, May 4, 2018

python lib showcase: pyg-to-term

pygtotermlib.py is a python library of mine that converts pygame surfaces to block-graphics (think ansi-art), ready to be printed to a *nix-style terminal.

So what can you do with it?

The chart on the right shows the 5 main conversion modes. (interpolation options for the first and third modes not shown)

The second and fourth options use 256-color escape sequences, while the last one uses 24bit-color escape sequences.

While these modes allow nicer output, there is a catch: not all terminals will actually show these modes properly.

pyg-to-term on Github

Thursday, June 1, 2017

Balanced ternary: Overhauling libbaltcalc's aging, clunky API

new libbaltcalc 3.x series.
 while the old balance ternary integer string API is still present, its been cleaned up a bit. also a new class-based API now exists.

the btint class provides a more seamless API in python.

as an example lets add 2 and 4
old API:
>>>import libbaltcalc
>>>int1=libbaltcalc.DECTOBT(2)
>>>int2=libbaltcalc.DECTOBT(4)
>>>print libbaltcalc.btadd(int1, int2)
+-0

the new btint class can accept integers, balanced ternary integer strings, and other btint instances as an argument. not only that, but all supported mathematics operations return btint instances. and btint instances can be printed and used quite simply.

new API:
>>>import libbaltcalc
>>>from libbaltcalc import btint
>>>int1=btint(2)
>>>int2=btint(4)
>>>print int1 + int2
+-0

Now wasn't that easier?

new libbaltcalc documentation