Hello, World! in Piet
This example uses only 2 commands — push
and out (char)
. To print one character, one has to create a block of any color; the number of pixels in it should be equal to ASCII-code of this character. After this, one should create a block of color one shade darker of arbitrary size immediately to the right of that block (this will perform push
command). Finally, a block of color one hue to the left of the original one of arbitrary size will perform out(char)
command. After this, this sequence repeats for the next character.
To end program execution, we use a loop — a single-color block surrounded with black pixels. When the instruction pointer gets inside this block, it can’t leave in any direction.
The decorative version of the example shows that blocks can have any shape, even with pixels of other colors inside.
"Hello, World!" in Piet (basic)
"Hello, World!" in Piet (basic, 5x scale)
"Hello, World!" in Piet (decorative)
"Hello, World!" in Piet (decorative, 5x scale)
Comments
]]>blog comments powered by Disqus
]]>