Convert EOLs from CRs to LFs on this text file.
Chris Pressey
1 year, 11 months ago
0 | The Whothm Drawing Language | |
1 | =========================== | |
2 | ||
3 | _Try it online_ [@ catseye.tc](https://catseye.tc/installation/Whothm) | |
4 | | _See also:_ [Etcha](https://github.com/catseye/Etcha) | |
5 | ||
6 | - - - - | |
7 | ||
8 | Overview | |
9 | -------- | |
10 | ||
11 | Whothm is a language for describing infinite two-colour bitmapped | |
12 | graphics. | |
13 | ||
14 | ### Prerequisites | |
15 | ||
16 | I'd love to tell you about Whothm, but first I need to tell you about | |
17 | Joanie, the Gnostic Babysitter. Have you seen her? She's a very normal | |
18 | twelve-year-old girl, with very normal twelve-year-old girl concerns — | |
19 | she worries if her friends will make fun of her for liking different | |
20 | music than they do, worries if that cute boy in home room likes her or | |
21 | not, worries if she'll be able to achieve a transcendant state of gnosis | |
22 | at the moment of her physical death so that her soul may be freed from | |
23 | the reincarnation cycle. Because, you see, she's a Gnostic. Not just | |
24 | curious about Gnosticism, not just going through a phase, or anything | |
25 | like that — Joanie is a die-hard, demiurge-rejecting, | |
26 | rotten-material-world-shunning Gnostic. And she charges $15 an hour. | |
27 | ||
28 | OK, *now* I can tell you about Whothm. | |
29 | ||
30 | ### Program Structure | |
31 | ||
32 | Each Whothm program consists of a variable declaration section and a | |
33 | single infinite loop. | |
34 | ||
35 | There are two possible data types for variables: rectangles and truth | |
36 | tables. A rectangle is a structure of four integer members called x, y, | |
37 | w and h. A truth table is a map from pairs of boolean values to a single | |
38 | boolean value. A truth table is denoted by listing only the pairs which | |
39 | evaluate to true; all other pairs evaluate to false. | |
40 | ||
41 | Inside the infinite loop, there are two kinds of commands: draw commands | |
42 | and delta commands. Draw commands apply a rectangle to the drawing | |
43 | canvas. Every pixel on the canvas that lies within w pixels to the right | |
44 | of the x position, and within h pixels to the bottom of the y position, | |
45 | is changed. A truth table is given that determines how it is changed. | |
46 | The existing pixel is looked up in the first column of the table, and | |
47 | the pixel in the rectangle being drawn (which is always true) is looked | |
48 | up in the second column; the resulting pixel state is read off the third | |
49 | column. Truth maps to the foreground colour (typically black), while | |
50 | falsehood maps to the background colour (typically white.) | |
51 | ||
52 | Delta commands alter a named member of a named rectangle. They always | |
53 | add a value to the member, although that value may be negative. The | |
54 | value may be a literal constant, or it may be the current value of a | |
55 | named member of a named rectangle. | |
56 | ||
57 | Syntax | |
58 | ------ | |
59 | ||
60 | ### Grammar | |
61 | ||
62 | Whothm ::= {Declaration ";"} "begin" {Command ";"} "end". | |
63 | Declaration ::= Name<new> ":=" (RectDecl | TableDecl). | |
64 | RectDecl ::= "(" IntLit "," IntLit "," IntLit "," IntLit ")". | |
65 | TableDecl ::= TruthPair {"/" TruthPair}. | |
66 | TruthPair ::= "TT" | "TF" | "FT" | "FF". | |
67 | Command ::= DrawCmd | DeltaCmd. | |
68 | DrawCmd ::= "draw" Name<Rect> "," Name<Table>. | |
69 | DeltaCmd ::= MemberRef "+=" (IntLit | MemberRef). | |
70 | MemberRef ::= Name<Rect> "." RectMember. | |
71 | RectMember ::= "x" | "y" | "w" | "h". | |
72 | ||
73 | ### Example Program | |
74 | ||
75 | r := (0, 0, 1, 2); | |
76 | ||
77 | AND := TT; | |
78 | OR := TT/TF/FT; | |
79 | NAND := TF/FT/FF; | |
80 | NOR := FF; | |
81 | XOR := TF/FT; | |
82 | ||
83 | begin | |
84 | r.x += 5; | |
85 | r.y += r.w; | |
86 | draw r, XOR; | |
87 | end | |
88 | ||
89 | Semantics | |
90 | --------- | |
91 | ||
92 | The meaning of a Whothm program is fairly intuitive. The commands | |
93 | between the `begin` and `end` are executed in sequence, altering the | |
94 | state of the drawing canvas, and of one or more rectangles. (There is no | |
95 | way to alter a truth table, once defined.) The whole sequence of | |
96 | commands is then repeated, *ad infinitum*. | |
97 | ||
98 | However, note that Whothm is a language for describing only shapes which | |
99 | are (countably) infinte in extent. For this reason, it is an error for | |
100 | the state of the program (that is, the variables and the canvas) to be | |
101 | the same on any two (even non-consecutive) iterations of the loop. | |
102 | ||
103 | Discussion | |
104 | ---------- | |
105 | ||
106 | Whothm raises some interesting questions, although not perhaps as | |
107 | interesting as those raised by Joanie's grades this semester. The main | |
108 | one is, what kinds of shapes can Whothm describe? | |
109 | ||
110 | Clearly, the shapes cannot be chaotic in any strong sense, as the | |
111 | equations involved are essentially linear. The sole exception is when a | |
112 | truth tables like XOR, which can reverse previous pixels, is used. In | |
113 | fact, the presence of XOR means that Whothm can generate infinite | |
114 | drawings without a fixed point. (XOR seems a bit like sine in that | |
115 | respect; you can't take the indefinite integral of it, because never | |
116 | ever settles down.) Yet, I believe it is not necessary — any shape that | |
117 | can be drawn with XOR can be drawn with suitable monotonic truth tables, | |
118 | as well. | |
119 | ||
120 | Further, despite not being able to produce clearly chaotic drawings, | |
121 | Whothm can still produce what are in my opinion somewhat pretty ones. | |
122 | ||
123 | Cat's Eye Technologies' implementation of Whothm is called JWhothm, as | |
124 | it is written in Java. Using a browser which supports Java applets, it | |
125 | can be interacted with in the [JWhothm | |
126 | exhibit](http://catseye.tc/gallery/esolangs/jwhothm/) in the [Gallery of | |
127 | Interactive Esolangs](http://catseye.tc/gallery/esolangs/). | |
128 | ||
129 | _(Update 2023: Cat's Eye Technologies now has another implementation of_ | |
130 | _Whothm, called [whothm.lua](impl/whothm.lua/), and_ it is this that is_ | |
131 | _now [installed online at catseye.tc](https://catseye.tc/installation/Whothm),_ | |
132 | _replacing the now-defunct "JWhothm exhibit" linked to above.)_ | |
133 | ||
134 | Happy infinite drawing! | |
135 | Chris Pressey | |
136 | June 29, 2010 | |
137 | Evanston, IL | |
138 | Birthplace of Donald Rumsfeld... and Grace Slick | |
0 | The Whothm Drawing Language | |
1 | =========================== | |
2 | ||
3 | _Try it online_ [@ catseye.tc](https://catseye.tc/installation/Whothm) | |
4 | | _See also:_ [Etcha](https://github.com/catseye/Etcha) | |
5 | ||
6 | - - - - | |
7 | ||
8 | Overview | |
9 | -------- | |
10 | ||
11 | Whothm is a language for describing infinite two-colour bitmapped | |
12 | graphics. | |
13 | ||
14 | ### Prerequisites | |
15 | ||
16 | I'd love to tell you about Whothm, but first I need to tell you about | |
17 | Joanie, the Gnostic Babysitter. Have you seen her? She's a very normal | |
18 | twelve-year-old girl, with very normal twelve-year-old girl concerns — | |
19 | she worries if her friends will make fun of her for liking different | |
20 | music than they do, worries if that cute boy in home room likes her or | |
21 | not, worries if she'll be able to achieve a transcendant state of gnosis | |
22 | at the moment of her physical death so that her soul may be freed from | |
23 | the reincarnation cycle. Because, you see, she's a Gnostic. Not just | |
24 | curious about Gnosticism, not just going through a phase, or anything | |
25 | like that — Joanie is a die-hard, demiurge-rejecting, | |
26 | rotten-material-world-shunning Gnostic. And she charges $15 an hour. | |
27 | ||
28 | OK, *now* I can tell you about Whothm. | |
29 | ||
30 | ### Program Structure | |
31 | ||
32 | Each Whothm program consists of a variable declaration section and a | |
33 | single infinite loop. | |
34 | ||
35 | There are two possible data types for variables: rectangles and truth | |
36 | tables. A rectangle is a structure of four integer members called x, y, | |
37 | w and h. A truth table is a map from pairs of boolean values to a single | |
38 | boolean value. A truth table is denoted by listing only the pairs which | |
39 | evaluate to true; all other pairs evaluate to false. | |
40 | ||
41 | Inside the infinite loop, there are two kinds of commands: draw commands | |
42 | and delta commands. Draw commands apply a rectangle to the drawing | |
43 | canvas. Every pixel on the canvas that lies within w pixels to the right | |
44 | of the x position, and within h pixels to the bottom of the y position, | |
45 | is changed. A truth table is given that determines how it is changed. | |
46 | The existing pixel is looked up in the first column of the table, and | |
47 | the pixel in the rectangle being drawn (which is always true) is looked | |
48 | up in the second column; the resulting pixel state is read off the third | |
49 | column. Truth maps to the foreground colour (typically black), while | |
50 | falsehood maps to the background colour (typically white.) | |
51 | ||
52 | Delta commands alter a named member of a named rectangle. They always | |
53 | add a value to the member, although that value may be negative. The | |
54 | value may be a literal constant, or it may be the current value of a | |
55 | named member of a named rectangle. | |
56 | ||
57 | Syntax | |
58 | ------ | |
59 | ||
60 | ### Grammar | |
61 | ||
62 | Whothm ::= {Declaration ";"} "begin" {Command ";"} "end". | |
63 | Declaration ::= Name<new> ":=" (RectDecl | TableDecl). | |
64 | RectDecl ::= "(" IntLit "," IntLit "," IntLit "," IntLit ")". | |
65 | TableDecl ::= TruthPair {"/" TruthPair}. | |
66 | TruthPair ::= "TT" | "TF" | "FT" | "FF". | |
67 | Command ::= DrawCmd | DeltaCmd. | |
68 | DrawCmd ::= "draw" Name<Rect> "," Name<Table>. | |
69 | DeltaCmd ::= MemberRef "+=" (IntLit | MemberRef). | |
70 | MemberRef ::= Name<Rect> "." RectMember. | |
71 | RectMember ::= "x" | "y" | "w" | "h". | |
72 | ||
73 | ### Example Program | |
74 | ||
75 | r := (0, 0, 1, 2); | |
76 | ||
77 | AND := TT; | |
78 | OR := TT/TF/FT; | |
79 | NAND := TF/FT/FF; | |
80 | NOR := FF; | |
81 | XOR := TF/FT; | |
82 | ||
83 | begin | |
84 | r.x += 5; | |
85 | r.y += r.w; | |
86 | draw r, XOR; | |
87 | end | |
88 | ||
89 | Semantics | |
90 | --------- | |
91 | ||
92 | The meaning of a Whothm program is fairly intuitive. The commands | |
93 | between the `begin` and `end` are executed in sequence, altering the | |
94 | state of the drawing canvas, and of one or more rectangles. (There is no | |
95 | way to alter a truth table, once defined.) The whole sequence of | |
96 | commands is then repeated, *ad infinitum*. | |
97 | ||
98 | However, note that Whothm is a language for describing only shapes which | |
99 | are (countably) infinte in extent. For this reason, it is an error for | |
100 | the state of the program (that is, the variables and the canvas) to be | |
101 | the same on any two (even non-consecutive) iterations of the loop. | |
102 | ||
103 | Discussion | |
104 | ---------- | |
105 | ||
106 | Whothm raises some interesting questions, although not perhaps as | |
107 | interesting as those raised by Joanie's grades this semester. The main | |
108 | one is, what kinds of shapes can Whothm describe? | |
109 | ||
110 | Clearly, the shapes cannot be chaotic in any strong sense, as the | |
111 | equations involved are essentially linear. The sole exception is when a | |
112 | truth tables like XOR, which can reverse previous pixels, is used. In | |
113 | fact, the presence of XOR means that Whothm can generate infinite | |
114 | drawings without a fixed point. (XOR seems a bit like sine in that | |
115 | respect; you can't take the indefinite integral of it, because never | |
116 | ever settles down.) Yet, I believe it is not necessary — any shape that | |
117 | can be drawn with XOR can be drawn with suitable monotonic truth tables, | |
118 | as well. | |
119 | ||
120 | Further, despite not being able to produce clearly chaotic drawings, | |
121 | Whothm can still produce what are in my opinion somewhat pretty ones. | |
122 | ||
123 | Cat's Eye Technologies' implementation of Whothm is called JWhothm, as | |
124 | it is written in Java. Using a browser which supports Java applets, it | |
125 | can be interacted with in the [JWhothm | |
126 | exhibit](http://catseye.tc/gallery/esolangs/jwhothm/) in the [Gallery of | |
127 | Interactive Esolangs](http://catseye.tc/gallery/esolangs/). | |
128 | ||
129 | _(Update 2023: Cat's Eye Technologies now has another implementation of_ | |
130 | _Whothm, called [whothm.lua](impl/whothm.lua/), and_ it is this that is_ | |
131 | _now [installed online at catseye.tc](https://catseye.tc/installation/Whothm),_ | |
132 | _replacing the now-defunct "JWhothm exhibit" linked to above.)_ | |
133 | ||
134 | Happy infinite drawing! | |
135 | Chris Pressey | |
136 | June 29, 2010 | |
137 | Evanston, IL | |
138 | Birthplace of Donald Rumsfeld... and Grace Slick |