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).
- install lua packages by
sh ./requirements_install.sh
, makesureluarocks
is already installed.
lua main.lua
for REPL mode.lua main.lua --build <OPTIONAL_FILE_NAME>
, to output 1-bit graphic image.
x y ^ 5 % !
will compute an image as.pbm
file. the procedurals are- start from
x
xory
- then modulo by
5
- and convert to
1
or0
by!
- the process will be computed in matrix's manner(current size is
128px
*128px
, these number can be substituted byw
,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)
- start from
flure
use reverse polish notation (RPN) eg10 10 +
=20
x
andy
correspond to x,y coordinatesw
andh
=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
inFORTH
'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> )
immediate
ly call a function = eg.: bob 20 20 + ; immediate
, will return40
without callingbob
function.- to exit =
bye