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: ShadowStyleShadow rendering style.
offset_x: i8X offset from element (positive = right, negative = left).
offset_y: i8Y offset from element (positive = down, negative = up).
color: ColorShadow 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: ShadowEdgesWhich edges to render shadow on.
soft_edges: boolWhether 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: ShadowCompositeModeShadow 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
impl ShadowConfig
Sourcepub fn new(color: Color) -> Self
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
Sourcepub fn with_offset(self, x: i8, y: i8) -> Self
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.
Sourcepub fn with_style(self, style: ShadowStyle) -> Self
pub fn with_style(self, style: ShadowStyle) -> Self
Set the shadow rendering style.
Sourcepub fn with_color(self, color: Color) -> Self
pub fn with_color(self, color: Color) -> Self
Set the shadow color.
Sourcepub fn with_surface_color(self, color: Color) -> Self
pub fn with_surface_color(self, color: Color) -> Self
Set the surface/background color for half-block blending.
Sourcepub fn with_edges(self, edges: ShadowEdges) -> Self
pub fn with_edges(self, edges: ShadowEdges) -> Self
Set which edges should have shadows.
Sourcepub fn with_soft_edges(self, enabled: bool) -> Self
pub fn with_soft_edges(self, enabled: bool) -> Self
Enable or disable soft edges (half-block transitions).
Sourcepub fn with_composite_mode(self, mode: ShadowCompositeMode) -> Self
pub fn with_composite_mode(self, mode: ShadowCompositeMode) -> Self
Set the shadow compositing mode.
See ShadowCompositeMode for available modes.
Sourcepub fn with_grade(self, grade: ShadowGradeConfig) -> Self
pub fn with_grade(self, grade: ShadowGradeConfig) -> Self
Set custom grade parameters for grade-underlying mode.
This also sets composite_mode to
GradeUnderlying.
Sourcepub fn with_dramatic_grade(self) -> Self
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().
Sourcepub fn color_at_progress(&self, progress: f64) -> Color
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
impl Clone for ShadowConfig
Source§fn clone(&self) -> ShadowConfig
fn clone(&self) -> ShadowConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more