Forth Haiku
Vision

November 18, 2017

Brad Nelson / @flagxor

Forth Haiku

  • Tiny programs → Beauty
  • Forth → JavaScript → GLSL (WebGL)
  • Share + Evolve on the Web

Haiku Basics

  • Typical Forth-y words, but with floating point
  • Program runs once per pixel
  • Words x, y provide position
  • Final stack holds red, green, blue, alpha

Primrose Flower - adg


: i 2dup z* log
; x .5 - y .5 -
i i i log over
          

Primrose Flower - adg

Expanding Forth Haiku

  • Thoughtfully grow a small core word set
  • Work within the limits of WebGL
  • Add a few powerful words

Animation

  • Introduce t, adding time
  • Time in seconds since midnight
  • Allows for clocks!

Clock Cutout - Anonymous

PACMAN - www.manwe.ru

: d dup ;
: m 1 min ;
: f d floor - ;
: c cos abs ;
: j t 4 + 2 * x 8 * floor 8 / + 4 * c 2 / t 4 + 2 / c 4 ** * - ;
: a 1 x x 8 * floor 0.5 + 8 / - d * y ;
: b - d * + sqrt 50 * 8 ** ;
: p x t 4 + pi / f 1.6 * - 0.2 + ;
: v t 4 + pi 2 * / f ;
a j 0.5 b -
v d 0.5 < * 4 * m *
1 p d * y 0.5 - d * + 36 * 30 ** m -
y 0.5 - p atan2 abs t 10 * c 0.8 * - 16 * m * 0 max
a 0.5 b - 0 max d p 16 * < * +
p d * y 0.58 b m *
v 0.5 >= *
+ d 0.2
          

PACMAN - www.manwe.ru

Interactivity

  • Introduce mx, my, buttons, button, adding mouse and keyboard

TFKP 4 Flower Redux - Anonymous

Audio

  • Audio is HARD!
  • Audio from corners of image (pentatonic scale)
  • Introduced audio, adding an audio waveform
  • Sample 1
  • Sample 2

Video Input?

  • Limited by WebGL
  • Video feed becomes texture source
http://developer.download.nvidia.com/CgTutorial/cg_tutorial_chapter01.html
http://www.cs.cornell.edu/courses/cs4620/2017sp/cs4621/lecture01/index.html

x y sample
          

x y bwsample
          

forthsalon.appspot.com

Source and slides at: github.com/flagxor

Thank you