Skip to main content

Custom drawing

Draw creates a container whose final position and size are handed to your callback, so you can draw anything with raylib inside a box that ccompose lays out.

Example​

static void paint_bars(CC_BoundingBox bb, void *user) {
const float *values = user; // your own data
float w = bb.width / 3;
for (int i = 0; i < 3; ++i) {
float h = bb.height * values[i];
DrawRectangle((int)(bb.x + i * w), (int)(bb.y + bb.height - h),
(int)w - 4, (int)h, SKYBLUE);
}
}

static float values[3] = { 0.3f, 0.8f, 0.5f };

static void chart(void) {
Draw("Chart", paint_bars, values,
.layout = { .sizing = { Grow(), Fixed(120) } }) {}
}

Reference​

NameFormWhat it doesPage
DrawDraw("id", CC_DrawFn fn, void *user, .field = ...) { }A Column whose final bounding box is passed to your callback, so you can draw into it with raylib.Custom drawing
DrawRowDrawRow("id", fn, user, ...) { }Same, with children flowing left to right.Custom drawing
DrawColumnDrawColumn("id", fn, user, ...) { }Same as Draw.Custom drawing
CC_DrawFnvoid (*)(CC_BoundingBox bb, void *user)Callback type. bb is in screen pixels.Custom drawing
CC_AcquireDrawSlotCC_DrawSlot *(CC_DrawFn fn, void *user)Pool call behind the macros. Use it to attach a callback to Element or another container. Returns NULL when the 128-entry pool is full.Custom drawing
CC_DrawSlotstructPool entry. Don't fill it yourself.Custom drawing