Incular logoIncular
API ReferencePainting & Animation

Brush

Solid and gradient brushes with normalized stops.

Shader is an alias for Brush: Solid(Color), LinearGradient, RadialGradient, SweepGradient.

BrushParams
Solid(Color)Single color
LinearGradientstart, end, stops
RadialGradientcenter, radius, stops
SweepGradientcenter, start_angle, stops
use incular::prelude::*;

fn main() {
    let app = Application::new(|_cx| {
        Container::builder()
            .padding(EdgeInsets::all(24.0))
            .alignment(Alignment::CENTER)
            .child(
                Container::new()
                    .background(Brush::LinearGradient(LinearGradient {
                        start: Offset::new(0.0, 0.0),
                        end: Offset::new(200.0, 0.0),
                        stops: GradientStops::new(vec![
                            GradientStop {
                                offset: 0.0,
                                color: Color::WHITE,
                            },
                            GradientStop {
                                offset: 1.0,
                                color: Color::BLACK,
                            },
                        ]),
                    }))
                    .padding(EdgeInsets::all(16.0))
                    .child(Text::new("Gradient")),
            )
            .build()
            .into()
    })
    .expect("valid application");
    incular::run(app).expect("run application");
}

RadialGradient { center, radius, stops } and SweepGradient { center, start_angle, stops } share the stops model.

Stops clamp to 0..=1, sort, and normalize (empty becomes transparent, single stop duplicated). Helpers: sample_gradient_stops, linear_gradient_t, radial_gradient_t, sweep_gradient_t. FilterQuality: None / Low (default) / Medium / High. GradientId(u64) is the stable identity of normalized stops (GradientStops::id()).

Related: BlendMode, Paint.