pub struct ShadowSpec {
pub offset_x: f32,
pub offset_y: f32,
pub blur: f32,
pub spread: f32,
pub color: Color,
pub inset: bool,
}Expand description
A box-shadow specification.
Fields§
§offset_x: f32Horizontal offset in logical pixels.
offset_y: f32Vertical offset in logical pixels.
blur: f32Blur radius in logical pixels.
spread: f32Spread radius in logical pixels (grows the shadow before blurring).
color: ColorShadow colour (usually semi-transparent black).
inset: boolWhether the shadow is drawn inside the box (inset) rather than outside.
Implementations§
Source§impl ShadowSpec
impl ShadowSpec
Sourcepub const fn drop(offset_y: f32, blur: f32, color: Color) -> Self
pub const fn drop(offset_y: f32, blur: f32, color: Color) -> Self
A drop shadow (outset) with the given parameters.
Sourcepub fn new(
offset_x: f32,
offset_y: f32,
blur_radius: f32,
color_rgba: [u8; 4],
) -> Self
pub fn new( offset_x: f32, offset_y: f32, blur_radius: f32, color_rgba: [u8; 4], ) -> Self
Construct a shadow from explicit offset, blur, and RGBA byte array.
color_rgba is [r, g, b, a] where each channel is 0..=255.
spread defaults to 0 and inset defaults to false.
Sourcepub fn drop_shadow(offset_x: f32, offset_y: f32, blur: f32) -> Self
pub fn drop_shadow(offset_x: f32, offset_y: f32, blur: f32) -> Self
Construct a directional drop shadow with a default semi-transparent black colour.
Equivalent to ShadowSpec::new(offset_x, offset_y, blur, [0, 0, 0, 160]).
Sourcepub fn with_spread(self, spread: f32) -> Self
pub fn with_spread(self, spread: f32) -> Self
Builder: set the spread radius (positive expands, negative contracts).
Sourcepub fn with_inset(self, inset: bool) -> Self
pub fn with_inset(self, inset: bool) -> Self
Builder: set the inset flag.
Sourcepub fn to_pixel_color(&self) -> u32
pub fn to_pixel_color(&self) -> u32
Encode the shadow colour as a packed 0xAARRGGBB u32.
§Example
let spec = ShadowSpec::new(0.0, 0.0, 0.0, [255, 0, 0, 128]);
assert_eq!(spec.to_pixel_color(), 0x80FF_0000);Sourcepub fn is_invisible(&self) -> bool
pub fn is_invisible(&self) -> bool
Returns true if this shadow would render nothing.
Trait Implementations§
Source§impl Clone for ShadowSpec
impl Clone for ShadowSpec
Source§fn clone(&self) -> ShadowSpec
fn clone(&self) -> ShadowSpec
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShadowSpec
impl Debug for ShadowSpec
Source§impl PartialEq for ShadowSpec
impl PartialEq for ShadowSpec
Source§fn eq(&self, other: &ShadowSpec) -> bool
fn eq(&self, other: &ShadowSpec) -> bool
self and other values to be equal, and is used by ==.