#[cfg(feature = "serde")]
use serde::Serialize;
use crate::{
common_types::HexColor,
raw::drawing::{
effect::inner_shadow::XlsxInnerShadow,
scheme::color_scheme::XlsxColorScheme,
st_types::{emu_to_pt, st_angle_to_degree},
},
};
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize))]
pub struct InnerShadow {
pub color: HexColor,
pub blur_radius: f64,
pub direction: f64,
pub distance: f64,
}
impl InnerShadow {
pub(crate) fn from_raw(
raw: Option<XlsxInnerShadow>,
color_scheme: Option<XlsxColorScheme>,
ref_color: Option<HexColor>,
) -> Option<Self> {
let Some(raw) = raw else { return None };
let Some(color) = raw.clone().color else {
return None;
};
let Some(hex) = color.to_hex(color_scheme.clone(), ref_color.clone()) else {
return None;
};
return Some(Self {
color: hex,
blur_radius: emu_to_pt(raw.clone().blur_rad.unwrap_or(0) as i64),
direction: st_angle_to_degree(raw.clone().dir.unwrap_or(0) as i64),
distance: emu_to_pt(raw.clone().dist.unwrap_or(0) as i64),
});
}
}