Tree @rel_1_0_2023_0630 (Download .tar.gz)
The Whothm Drawing Language
Try it online @ catseye.tc | See also: Etcha
Overview
Whothm is a language for describing infinite two-colour bitmapped graphics.
Prerequisites
I'd love to tell you about Whothm, but first I need to tell you about Joanie, the Gnostic Babysitter. Have you seen her? She's a very normal twelve-year-old girl, with very normal twelve-year-old girl concerns — she worries if her friends will make fun of her for liking different music than they do, worries if that cute boy in home room likes her or not, worries if she'll be able to achieve a transcendant state of gnosis at the moment of her physical death so that her soul may be freed from the reincarnation cycle. Because, you see, she's a Gnostic. Not just curious about Gnosticism, not just going through a phase, or anything like that — Joanie is a die-hard, demiurge-rejecting, rotten-material-world-shunning Gnostic. And she charges $15 an hour.
OK, now I can tell you about Whothm.
Program Structure
Each Whothm program consists of a variable declaration section and a single infinite loop.
There are two possible data types for variables: rectangles and truth tables. A rectangle is a structure of four integer members called x, y, w and h. A truth table is a map from pairs of boolean values to a single boolean value. A truth table is denoted by listing only the pairs which evaluate to true; all other pairs evaluate to false.
Inside the infinite loop, there are two kinds of commands: draw commands and delta commands. Draw commands apply a rectangle to the drawing canvas. Every pixel on the canvas that lies within w pixels to the right of the x position, and within h pixels to the bottom of the y position, is changed. A truth table is given that determines how it is changed. The existing pixel is looked up in the first column of the table, and the pixel in the rectangle being drawn (which is always true) is looked up in the second column; the resulting pixel state is read off the third column. Truth maps to the foreground colour (typically black), while falsehood maps to the background colour (typically white.)
Delta commands alter a named member of a named rectangle. They always add a value to the member, although that value may be negative. The value may be a literal constant, or it may be the current value of a named member of a named rectangle.
Syntax
Grammar
Whothm ::= {Declaration ";"} "begin" {Command ";"} "end".
Declaration ::= Name<new> ":=" (RectDecl | TableDecl).
RectDecl ::= "(" IntLit "," IntLit "," IntLit "," IntLit ")".
TableDecl ::= TruthPair {"/" TruthPair}.
TruthPair ::= "TT" | "TF" | "FT" | "FF".
Command ::= DrawCmd | DeltaCmd.
DrawCmd ::= "draw" Name<Rect> "," Name<Table>.
DeltaCmd ::= MemberRef "+=" (IntLit | MemberRef).
MemberRef ::= Name<Rect> "." RectMember.
RectMember ::= "x" | "y" | "w" | "h".
Example Program
r := (0, 0, 1, 2);
AND := TT;
OR := TT/TF/FT;
NAND := TF/FT/FF;
NOR := FF;
XOR := TF/FT;
begin
r.x += 5;
r.y += r.w;
draw r, XOR;
end
Semantics
The meaning of a Whothm program is fairly intuitive. The commands
between the begin
and end
are executed in sequence, altering the
state of the drawing canvas, and of one or more rectangles. (There is no
way to alter a truth table, once defined.) The whole sequence of
commands is then repeated, ad infinitum.
However, note that Whothm is a language for describing only shapes which are (countably) infinte in extent. For this reason, it is an error for the state of the program (that is, the variables and the canvas) to be the same on any two (even non-consecutive) iterations of the loop.
Discussion
Whothm raises some interesting questions, although not perhaps as interesting as those raised by Joanie's grades this semester. The main one is, what kinds of shapes can Whothm describe?
Clearly, the shapes cannot be chaotic in any strong sense, as the equations involved are essentially linear. The sole exception is when a truth tables like XOR, which can reverse previous pixels, is used. In fact, the presence of XOR means that Whothm can generate infinite drawings without a fixed point. (XOR seems a bit like sine in that respect; you can't take the indefinite integral of it, because never ever settles down.) Yet, I believe it is not necessary — any shape that can be drawn with XOR can be drawn with suitable monotonic truth tables, as well.
Further, despite not being able to produce clearly chaotic drawings, Whothm can still produce what are in my opinion somewhat pretty ones.
Cat's Eye Technologies' implementation of Whothm is called JWhothm, as it is written in Java. Using a browser which supports Java applets, it can be interacted with in the JWhothm exhibit in the Gallery of Interactive Esolangs.
(Update 2023: Cat's Eye Technologies now has another implementation of Whothm, called whothm.lua, and it is this that is_ now installed online at catseye.tc, replacing the now-defunct "JWhothm exhibit" linked to above.)
Happy infinite drawing!
Chris Pressey
June 29, 2010
Evanston, IL
Birthplace of Donald Rumsfeld... and Grace Slick
Commit History
@rel_1_0_2023_0630
git clone https://git.catseye.tc/Whothm/
- Merge pull request #2 from catseye/develop-2023 Chris Pressey (commit: GitHub) 1 year, 4 months ago
- Convert EOLs from CRs to LFs on this text file. Chris Pressey 1 year, 4 months ago
- Add updated links to README. Chris Pressey 1 year, 4 months ago
- Move CSS to HTML file Chris Pressey 1 year, 4 months ago
- Update license (copyright year and make detectable by GitHub.) Chris Pressey 1 year, 4 months ago
- Add test script. Chris Pressey 1 year, 4 months ago
- Add driver script for Lua implementation of Whothm. Chris Pressey 1 year, 4 months ago
- Merge branch 'implement-in-lua' into develop-2023 Chris Pressey 1 year, 4 months ago
- Add README for Lua implementation. Chris Pressey 1 year, 4 months ago
- Repository cleanups. Chris Pressey 1 year, 4 months ago