Skip to content
Vadim Grigoruk edited this page Nov 22, 2026 · 1 revision

Fill patterns

Added in 1.5.

Every shape primitive that takes a color can carry a two-color 4×4 fill pattern in the same argument. This is the only extra data the color word carries; there is no separate API.

color = c1 + c2 * 256 + pattern * 65536
  • c1 — palette index drawn where the pattern bit is set
  • c2 — palette index drawn where the pattern bit is clear
  • pattern — a 4×4 bitmap of the screen. Bit n is (y & 3) * 4 + (x & 3), bit 0 at the top left. pattern = 0 draws a solid c1
  • c2 = 255 leaves the screen unchanged under the clear bits, which makes the pattern a stipple overlay

The functions that accept a fill pattern are line, rect, rectb, rrect, rrectb, circ, circb, elli, ellib, paint, tri and trib.

Examples

function TIC()
    cls(0)

    -- checkerboard: c1 where (x+y) is even, c2 where it is odd
    local checker = 12 + 4 * 256 + 0xA5A5 * 65536
    rect(10, 10, 100, 50, checker)

    -- 1/16 stipple: one dot per 4x4 cell, the rest left as it is
    local dots = 15 + 255 * 256 + 0x0001 * 65536
    rect(10, 70, 100, 50, dots)

    -- solid c1, the old behavior
    rect(120, 10, 100, 50, 12)

    -- the pattern also works on primitives
    line(10, 130, 230, 130, checker)
end

Ordered dither masks

These masks cover 1/16 … 15/16 of each 4×4 cell and are the values help fill prints:

Coverage Pattern
1/16 0x0001
2/16 0x0401
3/16 0x0405
4/16 0x0505
5/16 0x0525
6/16 0x8525
7/16 0x85A5
8/16 0xA5A5
9/16 0xA5A7
10/16 0xADA7
11/16 0xADAF
12/16 0xAFAF
13/16 0xAFBF
14/16 0xEFBF
15/16 0xEFFF

Use help fill in the console to print the same table.

Home
Tips for newcomers

Built-in Editors

Code | Sprites | Maps | SFX | Music

Console

All commands

save | export | load | import | menu | config | surf | shelf | demo | eval 

Platform

RAM | VRAM | Display | Palette | Bits per Pixel (BPP) | .tic Format | Supported Languages

Other

Tutorials | Code Snippets | Libraries | External Tools | FFT


API

All API functions

Callbacks

TIC | BOOT | MENU | BDR

  • SCN (deprecated)
  • OVR (deprecated)

Input

btn | btnp | btnr | key | keyp | keyr | mouse

Drawing

circ | circb | clip | cls | elli | ellib | font | line | map | paint | pix | print | rect | rectb | rrect | rrectb | spr | tri | trib | ttri | fill patterns

Sound

music | sfx | FFT | VQT

Memory

memcpy | memset | mget | mset | peek | poke | pmem | sync | vbank

System

exit | reset | time | tstamp | trace

Clone this wiki locally