Skip to main content

ShadowConfig

Struct ShadowConfig 

Source
pub struct ShadowConfig {
    pub style: ShadowStyle,
    pub offset_x: i8,
    pub offset_y: i8,
    pub color: Color,
    pub surface_color: Option<Color>,
    pub edges: ShadowEdges,
    pub soft_edges: bool,
    pub composite_mode: ShadowCompositeMode,
    pub grade: Option<ShadowGradeConfig>,
}
Expand description

Configuration for rendering a shadow effect.

Use the builder pattern to construct a configuration:

use tui_vfx_shadow::{ShadowConfig, ShadowStyle, ShadowEdges};
use tui_vfx_types::Color;

let config = ShadowConfig::new(Color::BLACK.with_alpha(128))
    .with_offset(2, 1)
    .with_style(ShadowStyle::HalfBlock)
    .with_edges(ShadowEdges::BOTTOM_RIGHT)
    .with_soft_edges(true);

Fields§

§style: ShadowStyle

Shadow rendering style.

§offset_x: i8

X offset from element (positive = right, negative = left).

§offset_y: i8

Y offset from element (positive = down, negative = up).

§color: Color

Shadow color.

§surface_color: Option<Color>

Background/surface color for half-block blending.

When rendering half-block shadows, this color is used for the “empty” half of edge cells. If None, the shadow will use transparent background.

§edges: ShadowEdges

Which edges to render shadow on.

§soft_edges: bool

Whether to use soft edges (half-blocks at shadow boundaries).

Only applies to ShadowStyle::HalfBlock. When true, the shadow edge uses half-block characters for a softer transition.

§composite_mode: ShadowCompositeMode

Shadow compositing mode.

Controls how rendered shadow data is applied onto destination cells. The default GlyphOverlay preserves backward-compatible glyph-based shadow rendering.

§grade: Option<ShadowGradeConfig>

Optional color grading parameters for GradeUnderlying mode.

Ignored when composite_mode is GlyphOverlay. When None with GradeUnderlying, the compositor uses ShadowGradeConfig::default() (zero-strength, effectively no grading).

Implementations§

Source§

impl ShadowConfig

Source

pub fn new(color: Color) -> Self

Create a new shadow configuration with the specified color.

Uses defaults for other settings:

  • Style: HalfBlock
  • Offset: (1, 1)
  • Edges: BOTTOM_RIGHT
  • Soft edges: enabled
Source

pub fn with_offset(self, x: i8, y: i8) -> Self

Set the shadow offset (x, y).

Positive x = shadow to the right, negative = left. Positive y = shadow below, negative = above.

Source

pub fn with_style(self, style: ShadowStyle) -> Self

Set the shadow rendering style.

Source

pub fn with_color(self, color: Color) -> Self

Set the shadow color.

Source

pub fn with_surface_color(self, color: Color) -> Self

Set the surface/background color for half-block blending.

Source

pub fn with_edges(self, edges: ShadowEdges) -> Self

Set which edges should have shadows.

Source

pub fn with_soft_edges(self, enabled: bool) -> Self

Enable or disable soft edges (half-block transitions).

Source

pub fn with_composite_mode(self, mode: ShadowCompositeMode) -> Self

Set the shadow compositing mode.

See ShadowCompositeMode for available modes.

Source

pub fn with_grade(self, grade: ShadowGradeConfig) -> Self

Set custom grade parameters for grade-underlying mode.

This also sets composite_mode to GradeUnderlying.

Source

pub fn with_dramatic_grade(self) -> Self

Enable dramatic grade-underlying mode with the recommended preset.

Convenience builder that sets composite_mode to GradeUnderlying and grade to ShadowGradeConfig::dramatic().

Source

pub fn color_at_progress(&self, progress: f64) -> Color

Calculate the actual shadow color at a given progress value.

This allows shadows to animate in/out by interpolating alpha.

Trait Implementations§

Source§

impl Clone for ShadowConfig

Source§

fn clone(&self) -> ShadowConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ShadowConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ShadowConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for ShadowConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for ShadowConfig

Source§

fn eq(&self, other: &ShadowConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ShadowConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Copy for ShadowConfig

Source§

impl StructuralPartialEq for ShadowConfig

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,