Friday, July 19, 2019

TI Nspire CX II and TI Nspire CX II CAS: Drawing Demo

TI Nspire CX II  and TI Nspire CX II CAS:  Drawing Demo


The new TI Nspire CX II  and TI Nspire CX II CAS has an expanded library of programming commands.  We are now able to draw and place text anywhere on the screen. 

When a drawing command is used, the Nspire shifts into graphics mode.  The graphics screen is treated as a final output screen.  Graphics mode only executes in one of two places:

*  Running the program in a Calculator page in a document
*  Running the program in the Calculator part of the Sketchpad

When a graphics screen has an initial (and maximum) height of 212 pixels and an initial (and maximum) width of 318 pixels.  The default background is white. 

Shifting a Program to Graphics Mode

The Nspire shifts into graphics mode automatically any time a drawing command is executed.  Followed by their basic syntax, the commands are:

Clear (blank to clear the entire screen),  (x, y, width, height)

DrawArc  x, y, width, height, startAngle, sweepAngle

DrawCircle x, y, radius

DrawLine x1, y1, x2, y2

DrawPoly (see plotdemo2 for further details)

DrawRect upper_x_pixel, upper_y_pixel, width, height

DrawText x, y, string/text/expression

FillArc x, y, width, height, startAngle, sweepAngle

FillCircle x, y, radius

FillPoly (see plotdemo2 for further details)

FillRect upper_x_pixel, upper_y_pixel, width, height

getPlatform() (returns dt for desktop, hh for handheld, ios for the iOS App)

PaintBuffer  (buffers the paint screen)

PlotXY x, y, shape  (13 shapes available: 1 for dot, 5 for cross, 6 for plus, 8, for medium dot)

SetColor  red, green, blue    (sets the Nspire's color pen)

SetPen thickness, style  (1 thin, 2 medium, 3 thick; 1 smooth, 2, dotted, 3 dashed)

SetWidnow xMin, xMax, yMin, yMax  (establishes drawing area - use this command to switch coordinates to Cartesian)

UseBuffer  (tells the Nspire to use an off screen to draw objects, then use
PaintBuffer to call them back up)

Once graphics mode is entered, the following commands cannot be used:


This means if you want the user to able to input during graphics mode, you will need to use Getkey.

When the Graphics Is Displayed

The graphics will be displayed until the user presses [ enter ]. 

Caution:   The drawing commands are only available for the CX II.  The original CX, nor any previous incarnations of the TI Nspire will not have these commands. 

TI NSpire CX II Program plotdemo1

This demo shows all the possible shapes that PlotXY has.  Colors are set randomly. 

Define plotdemo1()=
:© graphics uses pixels: 318 * 212
:© Plotxy demo
:Local r,g,b,n,x,y
:For n,1,13
:© set colors
:SetColor r,g,b
:© draw text and points
:DrawText 1+22*n,40,n
:PlotXY 5+22*n,50,n

TI NSpire CX II Program plotdemo2

This demo draws filled polygons.  There are two syntax sets for DrawPoly and FillPoly:

Draw/FillPoly  x1, y1, x2, y2, ... ,xn, yn

With this format the polygon stops at the coordinate (xn, yn).  The polygon is not automatically completed under this format.  To complete the polygon, make sure that the coordinate (x1, y1) is the last two coordinates listed.

Draw/FillPoly x_coordinate_list, y_coordinate_list

With this format, the polygon is automatically completed.

Define plotdemo2()=
:© draw four triangles, filled
:© draw background box - gray
:© use fill, no draw
:SetColor 128,128,128
:FillRect 0,0,212,212
:© remember: x,y,width,height
:© now the triangles
:SetColor 128,0,0
:FillPoly 56,0,106,106,156,0
:FillPoly 56,212,106,106,156,212
:SetColor 127,255,255
:FillPoly 0,56,106,106,0,156
:FillPoly 212,56,106,106,212,156

TI Nspire CX II Program plotdemo3

This demo draws the function y = 1.5 cos (x^2).  The angle is set to radians mode.  The coordinates are converted to pixels prior to plotting them.

Define plotdemo3()=
:© draw y=1.5cos(x^((2)))
:© radians
:© denim color
:SetColor 16,36,192
:© main
:Local x,xs,xp,y,ys,yp
:For x,−2*π,2*π,xs
:  y:=1.5*cos(x^(2))
:  xp:=((x+2*π)/(xs))
:  yp:=((−(y-2))/(ys))
:  DrawText 10,10,xp
:  PlotXY xp,yp,1

TI Nspire CX II Program plotdemo5

Like in plotdemo3, this program draws y = 1.5 cos (x^2).  Instead of converting coordinates to pixels, SetWindow is used and adjust the coordinates so that Cartesian coordinates can be used. 

Define plotdemo5()=
:© draw y=1.5cos(x^((2)))
:© radians
:© denim color
:SetColor 16,36,192
:© main
:Local x,xs,y,ys
:© only x scaling is necesary
:SetWindow −2*π,2*π,−2,2
:© changes pixels to Cartesian
:For x,−2*π,2*π,xs
:  y:=1.5*cos(x^(2))
:  PlotXY x,y,1

This is a basic demonstration of drawing with the TI Nspire CX II.  On the next post, I show how to use getKey in graphics mode.

Happy drawing,


All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.

Texas Instruments: TI-36X Pro and TI-30X Pro Mathprint

 Essentially, the Texas Instruments TI-36X Pro and the TI-30X MathPrint are functionally equivalent.  What makes the two calculators differe...