pub enum Brush {
Linear {
start: (f32, f32),
end: (f32, f32),
stops: Vec<Stop>,
tile: TileMode,
},
Radial {
center: (f32, f32),
radius: f32,
radius_y: f32,
stops: Vec<Stop>,
tile: TileMode,
},
Image {
asset: u32,
tile: TileMode,
},
}Expand description
What a surface can be filled with beyond a flat colour.
The coordinates are fractions of the area being filled, never pixels. A gradient described in pixels would be a gradient that only looks right at one size, and nothing on this side of the boundary knows how large anything ended up.
Variants§
Linear
Radial
Fields
radius: f32As a fraction of the larger side, so a circle stays a circle. For an ellipse it is the horizontal radius.
radius_y: f32The vertical radius of an ellipse, as a fraction of the larger side like
radius. Zero is a circle of radius, which is what CSS radial-gradient(circle ...) draws; anything above zero is an ellipse radius across and radius_y
tall, which is CSS’s default shape. A negative or NaN value is refused by the
Renderer, which reports it and draws the circle.
Image
A registered picture, laid out as a fill.
Implementations§
Source§impl Brush
impl Brush
Sourcepub fn vertical(stops: Vec<Stop>) -> Self
pub fn vertical(stops: Vec<Stop>) -> Self
Top to bottom, which is the gradient almost every screen wants.
Sourcepub fn horizontal(stops: Vec<Stop>) -> Self
pub fn horizontal(stops: Vec<Stop>) -> Self
Left to right.
Sourcepub fn elliptical(radius_x: f32, radius_y: f32, stops: Vec<Stop>) -> Self
pub fn elliptical(radius_x: f32, radius_y: f32, stops: Vec<Stop>) -> Self
Out from the middle as an ellipse radius_x across and radius_y tall, each a
fraction of the larger side. CSS radial-gradient(ellipse ...).
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
The bytes the Renderer reads, in this module’s own layout.
Fixed fields throughout: a kind, a stop count, four coordinates, and then eight bytes per stop. A radial brush’s four are the centre, the radius and the vertical radius, which is zero for a circle. Nothing is skipped for a brush that does not use a coordinate, because a reader that has to know the kind before it knows where the stops start is a reader that can be walked off the end of a short buffer.