Language Specification

Color_Scheme

A 2D Stack-Based Esoteric Programming Language created by ablit

1. Executive Summary

Color_Scheme is a two-dimensional, stack-oriented esoteric programming language where instructions are encoded as visually distinct colored cells arranged on a 2D grid.

Programs can be written in human-readable CSV source text using color abbreviations or directly synthesized into 2D PNG pixel grid images where the program code is fully readable from the image's raw pixel data.

2. Grid & Execution Model

  • Grid Structure: Source text consists of cell instructions separated by commas (,). Rows are separated by pipes (|).
  • Instruction Pointer (IP): Execution begins at Row 0, Column 0 moving horizontally to the right.
  • Wrapping & Newline: When the IP reaches the end of a row or encounters the W instruction, it wraps to Column 0 of the next row.
  • Stack Mechanics: Operates on a single LIFO stack storing signed integers. If an instruction requires values when the stack is empty, 0 is implicitly pushed.
  • Halting: Execution terminates when the IP hits a B instruction, a halting branch instruction (e.g., Y-B-BL with zero top-item), or moves beyond the final row.

3. Color Palette Code Map

Cells use 13 canonical palette colors specified by short codes:

O #FF8C00
LB #70D6FF
L #5FFF9F
R #FF5F5F
Y #FFFF5F
P #FF5FFF
RO #FF69B4
BL #3A86FF
A #00FFFF
W #FFFFFF
B #111111
G #00E676
OR #FF4500

4. Complete Instruction Command Reference

Code Name Visual Pattern Category Description
O-LB Push 0
Stack Push integer 0 onto the stack
L Increment / Push 1
Stack Increment top item on stack (or push 1 if stack is empty)
O-L Increment / Push 1
Stack Increment top item on stack (or push 1 if empty)
R / O-R Decrement
Stack Decrement top item on stack
O-Y Duplicate (DUP)
Stack Duplicate top item on stack
O-P Rotate (ROT)
Stack Move top item to bottom of stack (or swap top 2)
O-B Clear Stack
Stack Clear all items from stack
BL-L Add (ADD)
Arithmetic Pop b, add b to top item on stack
BL-LB Multiply (MUL)
Arithmetic Pop b, multiply top item by b
A-W Output Number
I/O Pop top item and output as integer string
A-B Output Custom Char
I/O Pop top item and output custom mapped character (see Sec. 5)
A-G Output Raw ASCII
I/O Pop top item and output String.fromCharCode(val)
A-L Read Input
I/O Pop value from input queue and push onto stack
A-OR Clear Output
I/O Clear standard output text buffer
W Next Line
Control Jump IP to start of next row
B / B-B Halt / Padding
Control Halt execution or serve as blank grid padding
G Pass / No-Op
Control Do nothing, advance IP to next cell
GR-O / Y-W-BL Jump Row 2 if Non-Zero
Branching If top item != 0, jump IP to row index 1 (2nd row)
Y-W-R Loop Row if Non-Zero
Branching If top item != 0, jump IP to start of current row
Y-B-BL / Y-B-R Halt if Zero
Branching If stack is empty or top item == 0, halt program

5. Custom Character Mapping (A-B Encoding)

The A-B character printer maps integer stack values to characters as follows:

Integer Value Mapped Character Example
0Newline (\n)Stack 0 → Newline
1Space (' ')Stack 1 → Space
2 – 27Lowercase a – zStack 2 → 'a', 3 → 'b', ..., 27 → 'z'
28 – 53Uppercase A – ZStack 28 → 'A', 29 → 'B', ..., 53 → 'Z'
54+ASCII offset (code - 22)Stack 55 → '!' (55 - 22 = 33 ASCII)

6. Pure 2D Pixel Encoding (PNG Format)

Color_Scheme images encode programs directly into the canvas pixels without relying on PNG metadata metadata chunks:

  • Magic Marker Pixel (0, 0): Aqua #00FFFF (RGB: 0, 255, 255)
  • Magic Marker Pixel (1, 0): Orange #FF8C00 (RGB: 255, 140, 0)
  • Geometry Pixel (2, 0): RGB(numRows, maxCols, cellSize)
  • Offset Pixel (3, 0): RGB(startX, startY, 0)
  • Grid Cell Sampling: Cells are sampled by calculating RGB distances against the 13 canonical palette colors across 1, 2, or 3 color segment regions per cell block.

7. Example Program: Hello World!

Source CSV String:

O-LB,L,L,L,L,L,O-LB,L,L,BL-LB|O-Y,O-LB,L,L,L,BL-LB,L,L,L,L|L,A-B,O-Y,R,R,R,R,A-B,O-Y,L|L,L,O-Y,A-B,A-B,O-Y,L,L,L,L|L,L,A-B,O-LB,L,A-B,O-Y,O-LB,L,L|L,L,L,BL-LB,A-B,O-Y,L,L,L,L|L,L,A-B,O-Y,O-Y,BL-L,R,A-B,O-Y,L|L,L,A-B,O-LB,L,L,L,L,L,A-B|O-Y,L,O-LB,L,L,L,L,L,BL-LB,A-B