Basic Nim bindings for the Clay layout library
To call nicbarker/clay from Nim, we only need to cover the basic types. The CLAY
macro is optional, and you can recreate it with templates/macros if needed.
Each element is declared like this:
OpenElement()
ConfigureOpenElement(ClayElementDeclaration(
id: clayId("CenterBox"),
layout: ClayLayoutConfig(
sizing: ClaySizing(
width: sizingAxisFixed(100),
height: sizingAxisFixed(40),
),
),
backgroundColor: ClayColor(r: 255, g: 0, b: 0),
cornerRadius: cornerRadius(5)
))
CloseElement()
clay.c
is simply:
#define CLAY_IMPLEMENTATION
#include "clay.h"
Get the binding module here: turbo/clay.nim
Demo:
Note that Clay doesn't do any rendering, you need to hook it into your existing renderer.
Cheers ☕