beautypg.com

Drawing – HP Prime Graphing Calculator User Manual

Page 538

background image

534

Programming

Drawing

There are 10 built-in graphics variables in the HP Prime,
called G0G9. G0 is always the current screen graphic.
G1 to G9 can be used to store temporary graphic objects
(called GROBs for short) when programming applications
that use graphics. They are temporary and thus cleared
when the calculator turns off.
Twenty-six functions can be used to modify graphics
variables. Thirteen of them work with Cartesian
coordinates using the Cartesian plane defined in the
current app by the variables Xmin, Xmax, Ymin, and
Ymax.
The remaining thirteen work with pixel coordinates where
the pixel 0,0 is the top left pixel of the GROB, and 320,
240 is the bottom right. Functions in this second set have

a _P suffix to the function name.

C→PX

Converts from Cartesian coordinates to screen coordinates.

DRAWMENU

Syntax: DRAWMENU({text

1

, text

2

, …})

Draws a menu showing the text items listed.

FREEZE

Syntax: FREEZE
Pauses program execution until a key is pressed. This
prevents the screen from being redrawn after the end of
the program execution, leaving the modified display on
the screen for the user to see.

PX→C

Converts from screen coordinates to Cartesian

coordinates.

RGB

Syntax: RGB(R, G, B, [A])
Returns an integer number that can be used as the color

parameter for a drawing function. Based on Red, Green

and Blue components values (0 to 255).
If Alpha is greater than 128, returns the color flagged as

transparent. There is no alpha channel blending on Prime.
So RGB(255,0,128) returns #FF000F.
RECT(RGB(0,0,255)) makes a blue screen, as would

RGB(255) (any valid number gets interpreted the same way).
LINE(...,RGB(0,255,0)) makes a green line.