Repository navigation
v0.1.5
Builds on v0.1.4. No breaking changes.
New: Shadow()
Elements can cast a drop shadow. Set it through the element's .custom field. The shadow follows the element's own .cornerRadius.
Column("Card",
.layout = {.padding = PadAll(16)},
.backgroundColor = Color(28, 28, 34, 255),
.cornerRadius = RadiusAll(10),
.custom = Shadow(.offset = {0, 4}, .blur = 14,
.color = Color(0, 0, 0, 110))) {
Text("card content", .fontSize = 14);
}| Field | Effect | Default |
|---|---|---|
.offset |
Shift in px. {0, 4} drops the shadow down. |
{0, 0} |
.blur |
Width of the soft edge in px. 0 is a hard edge, negative counts as 0. |
0 |
.spread |
Grows (positive) or shrinks (negative) the shadow before the blur. | 0 |
.color |
Shadow color. Alpha 0 falls back to the default. |
Color(0, 0, 0, 64) |
- The shadow sits behind the element and above earlier siblings. On an
Imageit stays behind the picture. - The raylib renderer fakes the blur with 8 rounded rectangles that grow and fade. It needs no shader, so desktop and web draw it the same way.
- An element has one
.customslot, so it can't have both a shadow and aDrawcallback. Put the shadow on a parent that wraps the drawn element. - Up to
CC_SHADOW_POOL_SIZE(128) shadows per frame. Past that,Shadow()returns{.customData = NULL}and the element has no shadow. - In headless builds the element still emits a CUSTOM render command tagged
CC_SHADOW_TAG, so tests can inspect it.
See Styling: Shadow in the wiki.
Other changes
- The demo's Home feature cards have a shadow.
- New headless test
ccompose_shadow_test.
Using it
FetchContent_Declare(ccompose
GIT_REPOSITORY https://github.com/rizukirr/ccompose.git
GIT_TAG v0.1.5
GIT_SHALLOW TRUE
)