Graphics
Here are some graphics basics. More words needed.
First, initialize the framebuffer. Do it with
monolith/gfx-fb-init
.
(monolith/gfx-fb-init)
An optional zoom amount can be set with
monolith/gfx-zoom
.
(monolith/gfx-zoom 4) # set to 4x
Set dimensions with monolith/gfx-setsize
.
Note that the size cannot exceed 320x200
, or
64000
pixels.
(monolith/gfx-setsize 128 128)
The currently set framebuffer dimensions can be retrieved
using monolith/gfx-width
and monolith/gfx-height
.
(print (monolith/gfx-width))
(print (monolith/gfx-height))
Pixels can be directly written to the buffer with
monolith/set-pixel
, it has the arguments, x, y,
then, R, G, B, A for the colors.
The code below sets a red pixel at coordinate (10, 10).
(monolith/gfx-pixel-set 10 10 255 0 0 255)
Write to PNG with monolith/gfx-write-png
.
Filled rectangle with monolith/gfx-rect-fill
.
(monolith/gfx-rect-fill x y w h r g b)
Write a png with monolith/gfx-write-png
:
(monolith/gfx-write-png "test.png")
Draw a line with monolith/gfx-line
(monolith/gfx-line x0 y0 x1 y1 r g b)
Fill the screen with one color using monolith/gfx-fill
(monolith/gfx-fill 255 255 255)