clay/bindings/c3/README.md
2025-01-29 12:34:07 -05:00

2.6 KiB

Clay-C3-Bindings

C3 Bindings for Clay, a UI layout library written in C. This directory contains the clay.c3 bindings file as well as a recreation of the clay-raylib-renderer and the video-example raylib/clay project.

Special thanks to:

TODO:

  • Find out how to build a static-lib with additional C sources

- C3 macros

Traditional Clay C Macro System

/* FILTER BUTTON */
CLAY(
    CLAY_ID("FilterButton"),
    Clay_Hovered() ? CLAY_RECTANGLE({
        .color = Clay_Hovered() ? FIRE_ORANGE : (Clay_Color){80, 25, 200, 255},
        .cornerRadius = 8,
    }) : 0,
    CLAY_LAYOUT({
        .sizing = {
            .width = CLAY_SIZING_FIT(),
            .height = CLAY_SIZING_GROW()
        },
        .padding = 10
    }) 
) {
    // define children...
}

Clay C3 Macro System

/* FILTER BUTTON */
@clay(
    clay::id("FilterButton"),
    clay::@bodyIf(clay::hovered(), clay::rectangle({
            .color = clay::hovered() ? FIRE_ORANGE : {80, 25, 200, 255},
            .cornerRadius = clay::cornerRadiusUni(8)
        })
    ),
    clay::layout({
        .sizing = {
            .width = clay::sizingFit(),
            .height = clay::sizingGrow()
        },
        .padding = clay::paddingUni(8)
    })
){
    // define children...
};

To Get Started:

  • Download c3c here
  • If you wish to compile the website-example, I've already provided a target to build in the project.json
    • set your cd to c3
    • use the c3c vendor-fetch raylib55 command to download a c3 compressed archive of raylib
      • once you have raylib55.c3l in the lib folder you've got it right
    • then use the command c3c run video-example to compile and run the video example
      • (note: to use the c3c build <target> command with video-example, you'll need to copy the resource folder into the build directory to run it
      • run executes the build result from the project directory, somehow. This means that run will look for the resource folder in c3, while build will look for it in build)

RESOURCES:

- C3 (A C-a-like, that aims to bring modern language QA features and a revamped Macro system to C)

- Raylib (C Videogame and Graphical API)

- Lexend (Accessible/ Dyslexic Friendly Font)