~/2023/flure

a small stack-based language for creating procedural binary graphic.

flure picture

a small stack-based language for creating procedural binary graphic (1-bit). run in FORTH-like interpreter, written in lua, hence the name flure (FORTH-like lua).

basically, flure (build-image mode) run in 128px * 128px, correspond to x,y coordinates. which means it can compute a 1-bit image from simple code like x y ^ 5 % !.

presented in BYOB Bangkok 2023 @ Bangkok City City Gallery

prerequisites

  • install lua packages by sh ./requirements_install.sh, makesure luarocks is already installed.

run

  • lua main.lua for REPL mode.
  • lua main.lua --build <OPTIONAL_FILE_NAME>, to output 1-bit graphic image.

example codes

  • x y ^ 5 % ! will compute an image as .pbm file. the procedurals are
    • start from x xor y
    • then modulo by 5
    • and convert to 1 or 0 by !
    • the process will be computed in matrix's manner(current size is 128px*128px, these number can be substituted by w, h).
    • you can try copy x y ^ 5 % ! to the playground to see the result.

usages

  • flure use reverse polish notation (RPN) eg 10 10 + = 20
  • x and y correspond to x,y coordinates
  • w and h = 128(px), 128(px), eg. x w 2 / - w 4 / * y w 2 / - % ! try on flure playground
  • [operators] arithmatics = +, -, *, /, %, abs(make absolute number)
  • [operators] bitwise = &, |, ^, <<, >>
  • [operators] stack = pop, push, show
  • [operators] core = (-1 = true, 0 = false) see example
    • = (equal)
    • <> (not_equal)
    • and
    • or
    • > (greater_than)
    • < (less_than)
    • dup (duplicate)
    • swap
    • 2dup (double duplicates)
    • rot (rotate)
  • function declaration (or word in FORTH's term) : <function_name> <...args> ; eg. : loop 1 - dup 0 = if else loop then ;
  • compile mode = :, delimited compile mode = ;
  • basic control flow <condition> if <if_case> else <else_case> then ;
  • comments = ( <...any_comments_here> )
  • immediately call a function = eg. : bob 20 20 + ; immediate, will return 40 without calling bob function.
  • to exit = bye

resources

2023

Lua

    DevelopmentProgramming Language ~