# Programming HP Calculators/Commands/Drawing Commands
## Important note

The drawing commands are somewhat confusing in that they reference parts of the 'plot', not parts of the physical screen.
It is intuitive to assume that (knowing that the screen is 131x64 pixels wide, and that the calculator references points by a Cartesian-like system) a pixel at (1,1) will always be the most bottom-right pixel on the screen.
However, this is not the case. (1,1) is the pixel at (1,1) on the infinite 'plot'. This means that it will only be the bottom-right pixel, as expected, when the plot is set to the dimensions 1?X?131 and 1?Y?64. This can be done by setting the (X/Y)(MIN/MAX) commands to appropriate values:
Adding this code to the start of your program will set the calculator's plot size to these specifications automatically, ensuring smooth operation of your program. However, upon the program's completion, any graph the user might have set up will be displayed on a (presumably) incorrect plotsize, which may frustrate the user. You could work around this like follows:
Of course, this adds bloat to the program somewhat, but will resolve the problem as long as you don't use the variables you selected in the program for other purposes. An alternate method would be to store the values in a list.

## ARC

Syntax
Detail
* <cent-x> and <cent-y> are the x- and y-coordinates of the center of the arc.
* <radius> is simply the radius of the arc.
* <start> is the starting angle of the arc, and <end> the finishing angle.
** Angles are measured mathematically, that is, the same as the unit circle; with 0° being the equivalent of due east on the compass, not due north, and counter-clockwise being the positive direction.
Dangers
* The ARC command utilises the current angle mode for arguments <start> and <end>. Therefore, if you design your arcs using degrees, it may be wise to set the angle mode to degrees programmatically like so:
* Alternately, an HAngle value of 2 or 3 can be used to set the calculator in radians or grads, respectively.
* The ARC command is particularly slow, so if you need to draw extensively, it may be wise (although time-consuming) to use MAKEGROB.
Example
Draws a full circle of radius 15px, from the center of the screen.
Draws a full circle comprised of four arcs, but the circle is missing a arc of 20° at each cardinal point. Represented more concisely using a loop:

## BOX

Syntax
Detail
* (<x1>,<y1>) are the coordinates of the box's starting corner.
* (<x2>,<y2>) are the coordinates of the corner that completes the box.
* There are no limitations on the corners used, as long as they are binary opposites, that is top-left and bottom-right or bottom-left and top-right. Additionally, the order they are used in is not significant.
Example
Draws a box around the border of the screen.
Draws a border 2 pixels thick around the screen. More concisely:
This allows you to easily adjust the thickness of your border by simply adjusting the FOR command; for "FOR X= TO Z" the border will always be (Z-1) pixels thick.

## ERASE

Syntax
Detail
* Erases the contents of the screen, as simple as that.
* Adding ERASE: before any of the drawing commands is usually a good idea to prevent the program from drawing over the programs catalog, or any other view that the user happens to be in at the time.

## FREEZE

Syntax
Detail
* Stops the program, and waits for a keypress to continue.
* Use it after you finish your drawing commands, so that the user has time to look at the screen!

## LINE

Syntax
Detail
* Draws a line from point (<x-start>,<y-start>) to point (<x-end>,<y-end>).
Example
Draws a cross across the screen.

## PIXON/PIXOFF

Syntax
Detail
* Turns the pixel at (<x>,<y>) on or off.
Dangers
* PIXON and PIXOFF are reasonably fast, but when inside a FOR loop (see below), can be appreciably slow. If you want to do something like a 'pretend' loading bar (or even a real one if it's applicable), you should use LINE or TLINE as they are faster.
Example
Fills the screen with pixels from left-to-right, top-to-bottom, then reverses the process.

## TLINE

Syntax
Detail
* Same as LINE, except the command performs a slightly different task - instead of turning a line of pixels on, it toggles them. That is to say, if all the pixels you're drawing across are off already (say you just used ERASE:), it will function as a regular LINE, but if there are already pixels turned on, it will turn those off, and conversely turn off pixels on.
Example
Draws a cross in white across the screen, after turning on all the pixels. Therefore, it acts the same as: