Skip to content

ui::RadialGradientBrush

Header: winui/render/Brush.hpp.

A radial gradient. The defaults: an ellipse centered on the box with radii of half its size, the gradient starting at the center. gradient_origin is a point in the same space as center, not an offset from it.

Example:

auto rect = std::make_unique<ui::RectangleControl>();
rect->set_fill(ui::RadialGradientBrush{
    .stops  = {{0.0f, ui::Color::from_rgba(255, 255, 0)}, {1.0f, ui::Color::from_rgba(0, 0, 255)}},
    .center = ui::Point{0.25f, 0.25f},
});

Field Type Default
stops GradientStops The color stops, from gradient_origin (offset 0) out to the ellipse's edge (offset 1).
center Point {0.5f, 0.5f} Center of the outer ellipse, in the space mapping_mode picks.
radius_x float 0.5f Horizontal radius of the outer ellipse, in the space mapping_mode picks.
radius_y float 0.5f Vertical radius of the outer ellipse, in the space mapping_mode picks.
gradient_origin Point {0.5f, 0.5f} Where offset 0 sits; moving it off center gives an off-center highlight.
mapping_mode BrushMappingMode BrushMappingMode::RelativeToBoundingBox Whether the points and radii above are box fractions or DIPs.
spread_method GradientSpreadMethod GradientSpreadMethod::Pad What is painted outside the outer ellipse.