mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-14 22:42:46 +00:00
Add shared IDML effect setting writers
This commit is contained in:
1 file changed
+41
@@ -16,6 +16,29 @@ pub struct DropShadowValues {
|
||||
pub blend_mode: Option<String>,
|
||||
}
|
||||
|
||||
impl DropShadowValues {
|
||||
pub fn to_el(&self) -> El {
|
||||
let mut element = El::new("DropShadowSetting");
|
||||
if let Some(value) = &self.mode {
|
||||
element.set_attr("Mode", value);
|
||||
}
|
||||
for (key, value) in
|
||||
[("XOffset", self.x_offset), ("YOffset", self.y_offset), ("Size", self.size), ("Spread", self.spread), ("Opacity", self.opacity)]
|
||||
{
|
||||
if let Some(value) = value {
|
||||
element.set_attr(key, crate::value::num(value));
|
||||
}
|
||||
}
|
||||
if let Some(value) = &self.blend_mode {
|
||||
element.set_attr("BlendMode", value);
|
||||
}
|
||||
if let Some(value) = &self.color {
|
||||
element.set_attr("EffectColor", value);
|
||||
}
|
||||
element
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct FeatherValues {
|
||||
pub mode: Option<String>,
|
||||
@@ -24,6 +47,24 @@ pub struct FeatherValues {
|
||||
pub corner_type: Option<String>,
|
||||
}
|
||||
|
||||
impl FeatherValues {
|
||||
pub fn to_el(&self) -> El {
|
||||
let mut element = El::new("FeatherSetting");
|
||||
if let Some(value) = &self.mode {
|
||||
element.set_attr("Mode", value);
|
||||
}
|
||||
for (key, value) in [("Width", self.width), ("ChokeAmount", self.choke_amount)] {
|
||||
if let Some(value) = value {
|
||||
element.set_attr(key, crate::value::num(value));
|
||||
}
|
||||
}
|
||||
if let Some(value) = &self.corner_type {
|
||||
element.set_attr("CornerType", value);
|
||||
}
|
||||
element
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct OpacityStopValues {
|
||||
pub location: Option<f64>,
|
||||
|
||||
Reference in new issue
Block a user