Repository navigation
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. Bitnis(y & 3) * 4 + (x & 3), bit 0 at the top left.pattern = 0draws a solidc1 -
c2 = 255leaves 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.
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)
endThese 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.
TIC-80 tiny computer https://tic80.com | Twitter | Telegram | Terms
Built-in Editors
Console
save | export | load | import | menu | config | surf | shelf | demo | eval
Platform
RAM | VRAM | Display | Palette | Bits per Pixel (BPP) |
.ticFormat | Supported Languages
Other
Tutorials | Code Snippets | Libraries | External Tools | FFT
API
Callbacks
Input
Drawing
circ | circb | clip | cls | elli | ellib | font | line | map | paint | pix | print | rect | rectb | rrect | rrectb | spr | tri | trib | ttri | fill patterns
- textri (deprecated)
Sound
Memory
memcpy | memset | mget | mset | peek | poke | pmem | sync | vbank
System