Skip to main content

Crate skia_engine_macro

Crate skia_engine_macro 

Source
Expand description

Procedural macros for constructing skia-engine element trees.

skia_ui! provides a brace-based syntax, while skia_rsx! accepts RSX-like tags. Both macros produce skia_engine_core::ElementNode values and expect the generated code’s skia_engine_core and skia_safe paths to be available to the consuming crate.

Supported elements are Container, Rect, Image, and Text. Containers may contain nested elements; the other elements are leaves. Element properties use Rust expressions. Text content can be supplied through its content property, or as a quoted string literal in the RSX body.

§Brace syntax

ⓘ
skia_ui! {
    Container {
        width: 320.0,
        height: 180.0,
        background_color: skia_safe::Color::WHITE,
        Rect {
            width: 80.0,
            height: 60.0,
            color: skia_safe::Color::BLUE,
        }
    }
}

§RSX syntax

ⓘ
skia_rsx! {
    <Container width={320.0} height={180.0}>
        <Text font_size={24.0}>{"Hello, Skia!"}</Text>
    </Container>
}

Macros§

skia_rsx
Builds an ElementNode tree using RSX-like tag syntax.
skia_ui
Builds an ElementNode tree using nested Rust-like brace syntax.