Graphics Overview

PIGO8's graphics system is designed for simplicity: a fixed-size screen, a limited color palette, and immediate-mode drawing.

Coordinate System

The screen uses a standard 2D coordinate system:

  • (0, 0) is the top-left corner
  • X increases to the right
  • Y increases downward
  • Default size is 128×128 pixels
(0,0) ────────────────► X (127,0)
  │
  │
  │
  │
  ▼
  Y
(0,127)                 (127,127)

Drawing Order

PIGO8 uses immediate-mode rendering. Each frame:

  1. Call Cls() to clear the screen
  2. Draw background elements first
  3. Draw foreground elements on top
  4. Draw UI elements last

Later draws appear on top of earlier draws—like painting on a canvas.

func (g *game) Draw() {
    p8.Cls(0)                    // 1. Clear (black background)
    p8.Map()                     // 2. Background tiles
    p8.Spr(1, g.playerX, g.playerY) // 3. Player sprite
    p8.Print(g.score, 2, 2, 7)   // 4. UI on top
}

The 16-Color Palette

PIGO8 uses a 16-color palette by default (the PICO-8 palette):

IndexColorHexIndexColorHex
0Black#0000008Red#FF004D
1Dark Blue#1D2B539Orange#FFA300
2Dark Purple#7E255310Yellow#FFEC27
3Dark Green#00875111Green#00E436
4Brown#AB523612Blue#29ADFF
5Dark Gray#5F574F13Indigo#83769C
6Light Gray#C2C3C714Pink#FF77A8
7White#FFF1E815Peach#FFCCAA

Use color indices (0-15) in all drawing functions.

Graphics Functions Summary

FunctionPurpose
Cls(color)Clear screen
Pset(x, y, color)Draw single pixel
Pget(x, y)Read pixel color
Rect(), Rectfill()Draw rectangles
Circ(), Circfill()Draw circles
Line()Draw lines
Print()Draw text
Spr()Draw sprites
Sspr()Draw sprite regions
Map()Draw tile maps