cls: Clear or fill the screen

cls color

Fills the entire screen with a color, overwriting anything which is already there. If color is not given, defaults to 0 (which is white).

pix: Set individual pixels

pix x,y,color
pix x1,y1;x2,y2;;xN,yN,color
pix color

In the first form, sets the individual pixel at (x, y) to color. In the second form, sets multiple pixels at to color. In the third form, sets the pixel at the current default location (see the at command) to color.

In any of the three forms, color may be omitted (in this case also omit the comma before color), to default to color 1 (black).

You may also modify the current color of the pixel by adding to or subtracting from it. Instead of giving a specific color, write ~ (the tilde character) followed by a positive or negative number. For example:

pix x,y,~16

will add 16 to whatever color is currently in the pixel at (x,y). (PixelNote's color codes are very regular; adding 16 to any color other than black selects a darker shade of the same hue.)

pix function: Get current pixel color

pix(buffer, x, y)

Returns the current pixel color at (x,y). If no buffer is given, this refers to the current screen. If buffer is given, this refers to the pixels copied into that buffer by a copy command.

If (x,y) lies outside the visible screen, this function always returns 0; it's not an error.

last function: Get pixel color from previous frame


While animating, returns the pixel color at (x,y) within the previous frame. (For example, prior to the last pause or photo command, or from the last loop through an anim command.) If this is the first frame, returns 0.

line: Draw a line

line x1,y1,x2,y2,color
line x1,y1,x2,y2
line x2,y2,color
line x2,y2

Draws a line from (x1,y1) to (x2,y2).

If x1 and y1 are omitted, the line starts at the current default location (see the at command). After the line command completes, the current default location is updated to (x2,y2), so a sequence of line commands can be used to draw a connected path or polygon.

box: Fill in a rectangle

box x,y,w,h,color
box x,y,w,h
box w,h,color
box w,h

Fills in a rectangle with one corner at (x,y) and another corner at (x+w,y+h) with color color. (w and h may be negative if needed.) If x and y are omitted, uses the current default location (see the at command).

disk: Fill in a circle

disk x,y,r,color
disk x,y,r
disk r,color
disk r

Fills in a circle with center (x,y) and radius r with color color. If x and y are omitted, uses the current default location (see the at command).

exdisk: Fill outside a circle

exdisk x,y,r,color
exdisk x,y,r
exdisk r,color
exdisk r

Sets every pixel ouside the circle with center (x,y) and radius r. This is basically the inverse of the disk command.

photo: Take/use a photo


First, if you have drawn on the screen, the screen is updated and an animation frame is captured. The app then pops up a menu allowing the user to take a photo, pick from their photo library, reuse the last photo (if this isn't the first time), or cancel. If the user cancels this menu, PixelNote stops the program; otherwise, the photo is loaded, converted into PixelNote's color codes, pixelated, and copied onto the screen. The photo pixels always cover the entire screen.

This does not change PixelNote's resolution--the image will come out a little blocky looking!

copy: Copy pixels into a buffer

copy box x,y,w,h
copy disk x,y,r
copy buffer box x,y,w,h
copy buffer disk x,y,r

Copies the pixels in a given region to a background buffer; use paste to paste them back on the screen later.

The box and disk options are exactly as in the box and disk commands. In this case, the copied shape has an "anchor point" at (x,y). This is the point used to position the shape when doing a paste.

If no box or disk is given, the entire screen is copied, and the anchor point is set to (0,0). Thus, if you run:


then the entire screen is copied and then pasted right back on top of itself. This is useless. It is not useless, however, to copy the screen, then modify it for a step in some animation, then paste it back to restore it before going on to the next step.

If buffer is not given, this uses the default copy buffer; this is normally what you want to use. If buffer is given, it must be a small integer and can be used to copy multiple sets of data for later use.

paste: Paste pixels from a buffer

paste x,y
paste buffer,x,y
paste *magnification,x,y
paste *magnification,buffer,x,y

Pastes pixels copied using the copy command back onto the screen. The anchor point from the copied pixels is moved to (x,y) (this is the center of the disk, or the first corner of the box, specified in the copy command).

If buffer is not given, this uses the default copy buffer; if it is given, it must be a small integer and must match a copy buffer created by the copy command.

If magnification is given, it can be any positive number; the pixels will be scaled up (if greater than 1) or down (if less than 1) before pasting. Note that the * character is required to do this magnification.

txt: Draw text and symbols

txt string
txt x,y,string
txt string,color
txt x,y,string,color

Draws string on the screen at (x,y), with the given color, using the current font. Use the font command to select a font (there are only a couple).

If (x,y) are omitted, the current default location is used (see the at command). After drawing a string, the default location is moved to the upper right corner of the drawn string, so that if you draw another string, it reads left to right.

If color is omitted, it defaults to 1 (black).

Each font has a fixed character size, e.g. 3x5 or 5x7, in pixels. Every character in the font takes up this much space. By default, a single pixel padding is placed between each character by this command.

string may contain a variety of special codes starting with a backslash (\):

font: Set current font

font n

Selects font n for subsequent txt commands. n is a number; currently the valid fonts are:

These fonts are hand-crafted, not very good, and do not define many characters. Fonts 1 and 2 cover uppercase English letters, digits, and some punctuation and other Latin-based characters. If you use a character that is not defined, it prints as a ?. This program is for graphics, not really for text.

at: Set default X/Y location

at x,y

Most commands which take X and Y coordinates allow you to omit them, in which case they use the so-called "default location". This starts out at (0,0) when you first run a program, and gets updated by various drawing commands. For example, the line command updates it to the end of the line, while the txt command updates it to the upper right corner of the text string. This lets you easily chain drawing commands together, without having to repeat yourself so much.

Use the at command to explicitly set this if needed. You will rarely need to, but it can sometimes simplify your code.

Relative coordinates


Computes a value relative to its context. If you say ~1 for an X coordinate, it uses the current default location's X plus 1; if you say ~-3 for a Y coordinate, it uses the current default location's Y minus 3. You can use these relative values anywhere that a coordinate value is allowed.

axes: Draw axes


This just draws and labels the X and Y axes. This can be helpful when designing a new program, or when first learning PixelNote.