pub enum Brush {
Solid(Color),
LinearGradient {
colors: Vec<Color>,
stops: Option<Vec<f32>>,
start: Point,
end: Point,
tile_mode: TileMode,
},
RadialGradient {
colors: Vec<Color>,
stops: Option<Vec<f32>>,
center: Point,
radius: f32,
tile_mode: TileMode,
},
SweepGradient {
colors: Vec<Color>,
stops: Option<Vec<f32>>,
center: Point,
},
}Expand description
Describes how a shape, path or text is filled: a flat color or a gradient. Compose’s Brush.
Variants§
Solid(Color)
A single flat color. Compose’s SolidColor.
LinearGradient
Colors blend along the line from start to end. Compose’s Brush.linearGradient.
Fields
stops: Option<Vec<f32>>Positions of colors along the line from start to end, from 0.0 to 1.0; None
spaces the colors evenly.
start: PointWhere the first color is reached, in logical pixels relative to the top-left corner of the painted area. An infinite coordinate means the far edge of that area.
RadialGradient
Colors blend with distance from center. Compose’s Brush.radialGradient.
Fields
SweepGradient
Colors blend by angle around center. Compose’s Brush.sweepGradient.
Implementations§
Source§impl Brush
impl Brush
Sourcepub fn linear_gradient(colors: Vec<Color>) -> Brush
pub fn linear_gradient(colors: Vec<Color>) -> Brush
Creates a linear gradient that defaults to Compose semantics:
start at (0,0), end at (+inf,+inf), and TileMode::Clamp.
Sourcepub fn linear_gradient_range(
colors: Vec<Color>,
start: Point,
end: Point,
) -> Brush
pub fn linear_gradient_range( colors: Vec<Color>, start: Point, end: Point, ) -> Brush
Creates a linear gradient that spreads colors evenly from start to end, clamping
outside that line.
Sourcepub fn linear_gradient_with_tile_mode(
colors: Vec<Color>,
start: Point,
end: Point,
tile_mode: TileMode,
) -> Brush
pub fn linear_gradient_with_tile_mode( colors: Vec<Color>, start: Point, end: Point, tile_mode: TileMode, ) -> Brush
Creates a linear gradient that spreads colors evenly from start to end, repeating or
clamping outside that line as tile_mode says.
Sourcepub fn linear_gradient_stops(
color_stops: Vec<(f32, Color)>,
start: Point,
end: Point,
tile_mode: TileMode,
) -> Brush
pub fn linear_gradient_stops( color_stops: Vec<(f32, Color)>, start: Point, end: Point, tile_mode: TileMode, ) -> Brush
Creates a linear gradient from (position, color) pairs, with positions from 0.0 at start
to 1.0 at end.
Sourcepub fn vertical_gradient(colors: Vec<Color>, start_y: f32, end_y: f32) -> Brush
pub fn vertical_gradient(colors: Vec<Color>, start_y: f32, end_y: f32) -> Brush
Creates a vertical gradient that spreads colors evenly from start_y to end_y, clamping
outside that range.
Sourcepub fn vertical_gradient_tiled(
colors: Vec<Color>,
start_y: f32,
end_y: f32,
tile_mode: TileMode,
) -> Brush
pub fn vertical_gradient_tiled( colors: Vec<Color>, start_y: f32, end_y: f32, tile_mode: TileMode, ) -> Brush
Creates a vertical gradient that spreads colors evenly from start_y to end_y,
repeating or clamping outside that range as tile_mode says.
Sourcepub fn vertical_gradient_default(colors: Vec<Color>) -> Brush
pub fn vertical_gradient_default(colors: Vec<Color>) -> Brush
Creates a vertical gradient across the full height of the painted area, clamping at both ends.
Sourcepub fn vertical_gradient_stops(
color_stops: Vec<(f32, Color)>,
start_y: f32,
end_y: f32,
tile_mode: TileMode,
) -> Brush
pub fn vertical_gradient_stops( color_stops: Vec<(f32, Color)>, start_y: f32, end_y: f32, tile_mode: TileMode, ) -> Brush
Creates a vertical gradient from (position, color) pairs, with positions from 0.0 at
start_y to 1.0 at end_y.
Sourcepub fn horizontal_gradient(
colors: Vec<Color>,
start_x: f32,
end_x: f32,
) -> Brush
pub fn horizontal_gradient( colors: Vec<Color>, start_x: f32, end_x: f32, ) -> Brush
Creates a horizontal gradient that spreads colors evenly from start_x to end_x,
clamping outside that range.
Sourcepub fn horizontal_gradient_tiled(
colors: Vec<Color>,
start_x: f32,
end_x: f32,
tile_mode: TileMode,
) -> Brush
pub fn horizontal_gradient_tiled( colors: Vec<Color>, start_x: f32, end_x: f32, tile_mode: TileMode, ) -> Brush
Creates a horizontal gradient that spreads colors evenly from start_x to end_x,
repeating or clamping outside that range as tile_mode says.
Sourcepub fn horizontal_gradient_default(colors: Vec<Color>) -> Brush
pub fn horizontal_gradient_default(colors: Vec<Color>) -> Brush
Creates a horizontal gradient across the full width of the painted area, clamping at both ends.
Sourcepub fn horizontal_gradient_stops(
color_stops: Vec<(f32, Color)>,
start_x: f32,
end_x: f32,
tile_mode: TileMode,
) -> Brush
pub fn horizontal_gradient_stops( color_stops: Vec<(f32, Color)>, start_x: f32, end_x: f32, tile_mode: TileMode, ) -> Brush
Creates a horizontal gradient from (position, color) pairs, with positions from 0.0 at
start_x to 1.0 at end_x.
Sourcepub fn radial_gradient(colors: Vec<Color>, center: Point, radius: f32) -> Brush
pub fn radial_gradient(colors: Vec<Color>, center: Point, radius: f32) -> Brush
Creates a radial gradient that spreads colors evenly from center out to radius,
clamping beyond it.
Sourcepub fn radial_gradient_tiled(
colors: Vec<Color>,
center: Point,
radius: f32,
tile_mode: TileMode,
) -> Brush
pub fn radial_gradient_tiled( colors: Vec<Color>, center: Point, radius: f32, tile_mode: TileMode, ) -> Brush
Creates a radial gradient that spreads colors evenly from center out to radius,
repeating or clamping beyond it as tile_mode says.
Sourcepub fn radial_gradient_stops(
color_stops: Vec<(f32, Color)>,
center: Point,
radius: f32,
tile_mode: TileMode,
) -> Brush
pub fn radial_gradient_stops( color_stops: Vec<(f32, Color)>, center: Point, radius: f32, tile_mode: TileMode, ) -> Brush
Creates a radial gradient from (position, color) pairs, with positions from 0.0 at the
center to 1.0 at radius.
Trait Implementations§
Source§impl From<Color> for Brush
A colour paints as a solid brush wherever a brush is taken, as Compose
takes a Color beside each Brush overload.
impl From<Color> for Brush
A colour paints as a solid brush wherever a brush is taken, as Compose
takes a Color beside each Brush overload.