

A Forth haiku is an attempt to mix math, art and Forth - pointfree
http://forthsalon.appspot.com/

======
evincarofautumn
This is awesome and really shows off the beautiful compactness of Forth.

It took me a moment to figure out what to actually do. Basically you just
write a little program that produces three floating-point values from 0.0 to
1.0, and these are used as the R, G, and B channels of each pixel in the
output. For example, an all-red image is:

    
    
        1 0 0
    

And a blue-cyan-magenta rectangle is:

    
    
        x y 1
    

You get the x and y of the current pixel with the “x” and “y” words, and you
get the current time with the “t” word in order to make animations. Here’s one
that continually oscillates between black and white:

    
    
        : r 5 ;
        : sin' sin 1 + 2 / ;
        : t' t r * sin' ;
        t' t' t'
    

(You can change the value of “r” to make it oscillate faster or slower.)

Looking at the glossary[1] and cannibalising other examples is really helpful.

[1]: [http://forthsalon.appspot.com/word-
list](http://forthsalon.appspot.com/word-list)

~~~
to3m
You can put a 4th value on the stack, and it's interpreted as the alpha value.

~~~
evincarofautumn
Cool. Unfortunately I saw all these things on the “about” page _after_ I had
figured out how to use it through trial and error. That’s what I get for not
paying attention!

------
ANTSANTS
See also IBNIZ, a livecoding environment with a language inspired by (and even
more terse than) FORTH.

[http://countercomplex.blogspot.com/2011/12/ibniz-hardcore-
au...](http://countercomplex.blogspot.com/2011/12/ibniz-hardcore-audiovisual-
virtual.html)

------
amenghra
[http://forthsalon.appspot.com/haiku-
view/ahBzfmZvcnRoc2Fsb24...](http://forthsalon.appspot.com/haiku-
view/ahBzfmZvcnRoc2Fsb24taHJkchILEgVIYWlrdRiAgICAstmWCgw)

------
kaoD
I wondered if the Forth code was being transpiled into JS or GLSL. Inspecting
the source reveals it is JS, which seems sensible since it has stacks.

That made me wonder, how hard would it be to turn Forth code into imperative
GLSL? Seems like a fun exercise and would allow huge canvases.

------
pkaye
I seem to remember something similar but used a C like language.

~~~
to3m
[http://shadertoy.com/](http://shadertoy.com/) uses GLSL (or whatever its
WebGL equivalent is). Is that what you're thinking of?

(The language is syntactically similar to C, but quite different from it in
some respects, as it compiles to code that runs directly on the GPU. GPUs have
a very different execution model from a CPU - though they have been moving
closer together and I guess that trend will continue. On the plus side, the
performance can be excellent, provided your PC has a decent GPU.)

