Images
Image draws a texture into an element's box. Load the texture once with CC_LoadImage, then each frame wrap its address in ImgFill, ImgFit or ImgCrop to choose how it scales. These names need the raylib backend.
raylib only, except CC_ImageScale.
Example
static Texture2D avatar; // CC_LoadImage after CC_Init
static void profile(void) {
Row("Profile", .layout = { .childGap = 12 }) {
Image("Avatar", ImgCrop(&avatar),
.layout = { .sizing = { Fixed(64), Fixed(64) } },
.cornerRadius = RadiusAll(999)); // circle
Text("Display name", .fontSize = 20);
}
}
// startup: avatar = CC_LoadImage("resources/avatar.png");
// shutdown: CC_UnloadImage(avatar);
Reference
| Name | Form | What it does | Page |
|---|---|---|---|
Image | Image("id", CC_ImageRef *ref, .field = ...) | Image leaf drawn into the element's box. | Images |
ImgFill | CC_ImageRef *ImgFill(Texture2D *tex) | Stretch to fill the box, ignoring aspect ratio. | Images |
ImgFit | CC_ImageRef *ImgFit(Texture2D *tex) | Fit inside the box, keeping aspect ratio (letterboxed). | Images |
ImgCrop | CC_ImageRef *ImgCrop(Texture2D *tex) | Cover the box, keeping aspect ratio, cropping overflow. | Images |
CC_AcquireImageRef | CC_ImageRef *(Texture2D *tex, CC_ImageScale scale) | The pool call behind ImgFill / ImgFit / ImgCrop. Returns NULL when the 128-entry per-frame pool is full. | Images |
CC_ImageRef | struct { Texture2D *texture; CC_ImageScale scale; } | What Image draws. | Images |
CC_ImageScale | CC_IMAGE_FILL, CC_IMAGE_FIT, CC_IMAGE_CROP | Scale modes. | Images |
CC_LoadImage | Texture2D (const char *path) | Load an image file as a texture. Call after CC_Init. | Images |
CC_UnloadImage | void (Texture2D texture) | Free a texture from CC_LoadImage. Call before CC_Shutdown. | Images |