Skip to content

a small stack-based language for creating procedural binary graphic

License

Notifications You must be signed in to change notification settings

karnpapon/flure

Repository files navigation

flure

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).

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.
    • or click here to show the result image ( based-on Martin Kleppe's post)00

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's 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

About

a small stack-based language for creating procedural binary graphic

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published