Overview
The CURIO LED runs small Lua scripts. You write one in the browser, press Upload, and it is drawing on the LEDs a moment later. These pages start with a first script and end with how the panel’s shader compiler and virtual machine work inside.
Where to start
Section titled “Where to start”| If you want to | Read |
|---|---|
| Get something on the panel in five minutes | Your first script |
| Try a script without a panel | The preview |
| Understand what a script is and how it runs | How a script runs |
| Draw shapes and move them | Drawing, then Animation and uniforms |
| Colour every pixel with a formula | Fragment shaders |
| Make a shader run at full frame rate | Interpreted and compiled |
| Draw lit, textured 3D | 3D |
| Look something up | API reference, Shader built-ins, Limits |
| Know how it works underneath | From source to pixels, The bytecode, The shader VM |
The short version
Section titled “The short version”A script is plain Lua 5.4 with three optional functions the panel calls for you:
function _init() -- once, when the script startsend
function _update(dt) -- every frame; dt is seconds since the last frameend
function _draw() -- every frame, after _update gfx.cls(0, 0, 40) gfx.pset(32, 32, 255, 255, 255)endThere are three ways to put pixels on the panel, and you can mix them in one script:
- Drawing calls such as
gfx.pset,gfx.rectfillandgfx.line. Simple and fast for shapes and sprites. - A fragment shader: one function,
fragment(x, y, u), that returns the colour of a pixel. The panel calls it for every pixel, or runs a compiled version of it several times faster. - 3D meshes drawn through a built-in pipeline with a camera, lights and textures.
The panel is 64 pixels wide and 64 high. Everything on these pages uses gfx.width() and gfx.height() rather than assuming that.