Learn PIET with Real Code Examples

Updated Nov 25, 2025

Explain

Piet uses color codels (color blocks) to represent instructions.

Execution is controlled by the direction pointer (DP) and codel chooser (CC).

Instructions are determined by hue and brightness transitions between adjacent blocks.

Programs resemble abstract art inspired by Mondrian.

Piet is Turing-complete despite its visual and artistic nature.

Core Features

Color blocks act as operators

DP determines direction of movement

CC determines block-choice rules

Hue cycles represent command types

Brightness shifts represent command parameters

Basic Concepts Overview

Codel: smallest unit (pixel block) of a color

DP: direction pointer for execution flow

CC: codel chooser for flow handling

Hue transitions: determine commands

Brightness transitions: define operation magnitude

Project Structure

src/ - Piet image programs

assets/ - helper palettes and grids

examples/ - classic Piet artworks

tools/ - interpreters and debuggers

docs/ - design references and palettes

Building Workflow

Design program image in editor

Ensure valid Piet colors

Avoid compression artifacts

Run via interpreter

Debug using DP/CC visualization tools

Difficulty Use Cases

Beginner: simple push and output

Intermediate: arithmetic and stack manipulation

Advanced: loops using DP/CC blockers

Expert: full algorithms visually encoded

Artistic: large Mondrian-style programs

Comparisons

Piet vs INTERCAL: Piet is visual, INTERCAL is textual parody

Piet vs Brainfuck: Piet artistic, Brainfuck minimal

Piet vs Befunge: Both 2D, Piet uses color

Piet vs Python: Piet art-focused, Python practical

Piet vs Malbolge: Both hard, Piet more visual

Versioning Timeline

2001 – Piet created

2005 – npiet interpreter released

2010s – community examples grew

2020s – online editors and debuggers added

2025 – popular in coding-art events

Glossary

Codel: pixel block executing instruction

DP: direction pointer

CC: codel chooser

Hue cycle: color instruction wheel

Brightness: lightness level controlling command