pub struct Gradient { /* private fields */ }Expand description
A box’s gradient: see the module’s notes. Built by Gradient::to,
Gradient::angle or Gradient::radial, or read from plain data by
parse_with.
Implementations§
Source§impl Gradient
impl Gradient
Sourcepub fn to<S>(side: Side, stops: impl IntoIterator<Item = S>) -> Gradient
pub fn to<S>(side: Side, stops: impl IntoIterator<Item = S>) -> Gradient
A linear gradient towards a side or a corner of the box. To a
corner the half-way line runs through the other two corners at any
aspect, which is CSS’s to bottom right.
Sourcepub fn angle<S>(turns: f32, stops: impl IntoIterator<Item = S>) -> Gradient
pub fn angle<S>(turns: f32, stops: impl IntoIterator<Item = S>) -> Gradient
A linear gradient along turns, clockwise from east (0.25 is
downwards), measured in the box’s unit square — so an eighth of a
turn runs corner to corner whatever the box’s aspect, which CSS’s
45deg, measured in pixels, does not.
Sourcepub fn radial<S>(stops: impl IntoIterator<Item = S>) -> Gradient
pub fn radial<S>(stops: impl IntoIterator<Item = S>) -> Gradient
A radial gradient from the middle of the box out to its corners.
Sourcepub fn radial_at<S>(at: Vec2, stops: impl IntoIterator<Item = S>) -> Gradient
pub fn radial_at<S>(at: Vec2, stops: impl IntoIterator<Item = S>) -> Gradient
A radial gradient from at — fractions of the box, (0.5, 0) the
middle of its top edge — out to the corner farthest from it.
Sourcepub fn is_drawable(&self) -> bool
pub fn is_drawable(&self) -> bool
Whether there is anything to paint: two stops or more, and a shape made of numbers.
Sourcepub fn key(&self) -> u64
pub fn key(&self) -> u64
The key its raster is held under: equal for equal gradients, whatever box draws them.
Sourcepub fn stops(&self) -> &[(Color, f32)]
pub fn stops(&self) -> &[(Color, f32)]
The stops as resolved: a colour and its position, in order.
Sourcepub fn raster_size(&self) -> (u32, u32)
pub fn raster_size(&self) -> (u32, u32)
The raster’s size in texels: a strip along the axis the gradient runs on, or the square.
Sourcepub fn slot_size(&self) -> (u32, u32)
pub fn slot_size(&self) -> (u32, u32)
The texels its slot takes: Self::raster_size and a gutter of
one all round.
Sourcepub fn rasterize(&self) -> Vec<u8> ⓘ
pub fn rasterize(&self) -> Vec<u8> ⓘ
The raster: Self::slot_size texels of straight RGBA, row after
row, each the gradient at its texel’s centre. The quad draws the
inner Self::raster_size of them; the gutter is the gradient
carried on a texel past each edge, because the quad is stretched
and sampled linearly, and at the box’s edge the sampler reads half
a texel past the rect it was given — a strip one texel high would
otherwise fade into whatever the atlas holds above and below it.
Trait Implementations§
impl StructuralPartialEq for Gradient
Auto Trait Implementations§
impl Freeze for Gradient
impl RefUnwindSafe for Gradient
impl Send for Gradient
impl Sync for Gradient
impl Unpin for Gradient
impl UnsafeUnpin for Gradient
impl UnwindSafe for Gradient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.