Jonathan. Frech’s WebBlog

TImg (#181)

Jonathan Frech,

Texas Instrument’s TI-84 Plus is a graphing calculator with a variety of features. It has built-in support for both fractions and complex numbers, can differentiate and integrate given functions and supports programming capabilities. The latter allows to di­rect­ly manipulate the calculator’s monochrome dis­play’s 5985 pixels (the screen has dimensions 95 ⨉ 63). TImg is a Python pro­gram (source code is listed below and can also be downloaded) which takes in an image and outputs TI-BASIC source code which, when run on the graphing calculator, will produce the given image — in potentially lower quality.

TI-84 Plus’ screen dimensions (bitmap).

PIL — the Python Imaging Li­brary — is used to read in the image and further for processing. The supplied image may be rotated and resized to better fit the TI-84’s screen and any color or even grayscale in­for­ma­tion is reduced to an actual bitmap — every pixel on­ly has two distinct values.
Direct pixel manipulation on the TI-84 is done via the Graph screen. To get remove any pixels the system draws on its own, the first three commands are ClrDraw, GridOff and AxesOff which should re­sult in a completely blank screen — assuming that no functions are cur­rent­ly being drawn. All subsequent commands are in charge of drawing the previously computed bitmap. To turn certain pixels on, Pxl-On(Y,X is used where 𝑌 and 𝑋 are the pixel’s coordinates.

A fractal (bitmap).

Since the TI-84 Plus on­ly has 24 kilobytes of avail­able RAM, the source code for a pro­gram which would turn on every single pixel individually does not fit. Luckily, though, a pro­gram which on­ly individually turns on half of the screen’s pixels fits. To ensure that TImg’s output fits on the hard­ware it is designed to be used with, an image’s bitmap is inverted when the required code would otherwise exceed 3500 lines — a value slightly above the required code to draw half of the pixels.

A J-Blog screenshot (input image).

Source code: timg.py