Skip to main content

GradientRenderer

Struct GradientRenderer 

Source
pub struct GradientRenderer;
Expand description

Multi-layer gradient shadow renderer.

Renders shadows as multiple concentric layers with different colors, creating a visible falloff effect. Each layer is rendered slightly further from the element with a different color from the provided gradient.

Implementations§

Source§

impl GradientRenderer

Source

pub fn render_with_colors<G: Grid>( grid: &mut G, element_rect: Rect, config: &ShadowConfig, colors: &[Color], progress: f64, )

Render a gradient shadow using an array of colors.

§Arguments
  • grid - The grid to render into
  • element_rect - The rect of the element casting the shadow
  • config - Shadow configuration (offset and edges used, color ignored)
  • colors - Gradient colors from lightest (outer) to darkest (inner)
  • progress - Animation progress 0.0-1.0
§Example
// Use theme surface ladder for visible gradient
let colors = [
    theme.surface.surface_container,      // outer (lightest)
    theme.surface.surface_container_low,  // middle
    theme.surface.surface_container_lowest, // inner (darkest)
];
GradientRenderer::render_with_colors(&mut grid, rect, &config, &colors, 1.0);
Source

pub fn render<G: Grid>( grid: &mut G, element_rect: Rect, config: &ShadowConfig, layers: u8, progress: f64, )

Render a gradient shadow for the given element rect (legacy alpha-based).

Note: This uses alpha variation which may not be visible in terminals. Prefer render_with_colors with theme colors for visible gradients.

§Arguments
  • grid - The grid to render into
  • element_rect - The rect of the element casting the shadow
  • config - Shadow configuration
  • layers - Number of gradient layers (1-4)
  • progress - Animation progress 0.0-1.0

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V