Nathan Korth's writing

TI Basic Drawing Tutorial

November 2013

To write TI Basic programs that draw things, you can use commands from the DRAW menu under 2nd, PRGM. The first step, though, is setting up something you can draw on. The drawing functions draw right onto the graph screen, so to completely clear the screen we need to turn off graphs, plots, and axes.

:AxesOff
:FnOff
:PlotsOff
:ClrDraw

The DRAW menu contains many useful functions like Line, Circle, and Text. Personally, what I mostly use is the set of pixel functions in the next screen (POINTS). Like the line, circle, and text functions, the Pt-On and Pt-Off functions work with graph coordinates. This is useful if you plan to use all these functions. The issue with using graph coordinates is that they don't necessarily line up with pixels on the screen - instead, they're sensitive to the WINDOW settings. To make these functions line up with pixels, put ZDecimal at the start of your program. (it's in the ZOOM menu.) If you look at the window settings after running ZDecimal, you'll see that they range from (-4.7, -3.1) to (4.7, 3.1). This is because the calculator's screen is 94 pixels wide and 62 pixels tall. ZDecimal makes each pixel increment equal to 0.1 in graph coordinates.

The other way to draw things is with Pxl-On and Pxl-Off. These functions ignore the window settings, always drawing directly to the pixels. They take (row, column) positions instead of (x, y) positions, which can take some getting used to. The row will be between 0 and 62, and the column between 0 and 94. The Pxl functions will complain if you give them values outside of this range, which can be helpful sometimes. I like to use these functions when writing programs that draw things manually, pixel by pixel.

Without further ado, here are two fairly simple example programs. This first one uses graph coordinates and the Circle function:

PROGRAM:SPIRO
:AxesOff
:FnOff
:PlotsOff
:ClrDraw
:ZDecimal
:
:For(T,0,2π,π/8)
:1.5cos(T)→X
:1.5sin(T)→Y
:Circle(X,Y,1.5)
:End

The second one uses only the Pxl-On function. It uses nested For loops to iterate through every single pixel and decide whether to fill it in.

PROGRAM:GRADIENT
:AxesOff
:FnOff
:PlotsOff
:ClrDraw
:
:For(C,0,94)
:For(R,0,62)
:(R/62)→P
:If rand<P:Then
:Pxl-On(R,C)
:End
:End
:End