- cls: Clear or fill the screen
- pix: Set individual pixels
- pix function: Get current pixel color
- last function: Get pixel color from previous frame
- line: Draw a line
- box: Fill in a rectangle
- disk: Fill in a circle
- exdisk: Fill outside a circle
- photo: Take/use a photo
- copy: Copy pixels into a buffer
- paste: Paste pixels from a buffer
- txt: Draw text and symbols
- font: Set current font
- at: Set default X/Y location
- axes: Draw axes
cls: Clear or fill the screen
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
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:
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
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
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
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
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
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
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
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
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 (\):
- \h - Home: Moves up to the upper-left corner of the screen
- \n - Newline: Moves down one line and back to the left
- \w, \a, \s, \d - Move up, left, down, or right one character size
- \t - Tight: Toggles off/on the single-pixel padding between characters
- \1, \2, ⋯, \9: Inserts an N-pixel horizontal gap at this point in the string
font: Set current font
Selects font n for subsequent txt commands. n is a number; currently the valid fonts are:
- 1 (the default): a 3x5 alphanumeric font
- 2: A 5x7 alphanumeric font
- 3: A 7x7 symbol font; for example, the letters A, B, C, and D are the four poker suit symbols (spade, heart, club, and diamond).
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
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.
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.