pub struct ShapeProperties {
pub xfrm: Transform,
pub geometry: Option<Geometry>,
pub fill: Fill,
pub line: Option<Line>,
pub effects: Option<EffectList>,
pub scene3d: Option<Scene3d>,
pub sp3d: Option<Sp3d>,
pub rot_deg: Option<f64>,
}Expand description
形状属性 <p:spPr>。
Fields§
§xfrm: Transform仿射变换(位置/尺寸/旋转/翻转)。
geometry: Option<Geometry>几何(预设或自定义)。None 默认为 Preset(Rectangle)。
TODO-024:从 Option<PresetGeometry> 改为 Option<Geometry>,
支持自定义几何(<a:custGeom>)。
fill: Fill填充(实色/图片/无/继承)。
line: Option<Line>边框(<a:ln>)。None 表示不写出边框。
effects: Option<EffectList>效果列表(<a:effectLst>,可选)。
scene3d: Option<Scene3d>三维场景(<a:scene3d>,可选,TODO-050)。
定义相机与光照;与 sp3d 共同表达 3D 效果。
sp3d: Option<Sp3d>形状 3D 属性(<a:sp3d>,可选,TODO-050)。
定义形状本身的拉伸/棱台/材质。
rot_deg: Option<f64>旋转角度(度数,正向顺时针)。
Implementations§
Source§impl ShapeProperties
impl ShapeProperties
Sourcepub fn write_xml(&self, w: &mut XmlWriter, tag: &str)
pub fn write_xml(&self, w: &mut XmlWriter, tag: &str)
写 XML。tag 一般为 "p:spPr"。
按 OOXML 规范,<p:spPr> 内部必须按以下顺序排列:
<a:xfrm>(可选):位置/尺寸/旋转;<a:prstGeom>/<a:custGeom>:几何;- 填充相关(
<a:noFill>/<a:solidFill>/<a:gradFill>/<a:blipFill>/<a:pattFill>); <a:ln>:边框;- 效果(
<a:effectLst>等); <a:scene3d>/<a:sp3d>:三维效果;<a:extLst>:扩展。
顺序错误会导致 PowerPoint 弹出“Invalid OOXML“对话框。
Sourcepub fn write_xfrm_only(&self, w: &mut XmlWriter, tag: &str)
pub fn write_xfrm_only(&self, w: &mut XmlWriter, tag: &str)
仅写 xfrm 元素(<p:xfrm><a:xfrm>...</a:xfrm></p:xfrm>)。
仅 pptx-rs 主 crate 的 oxml::shape::GraphicFrame 使用 —— OOXML 中
<p:graphicFrame> 的子元素顺序是:
<p:graphicFrame>
<p:nvGraphicFramePr>...</p:nvGraphicFramePr>
<p:xfrm>...</p:xfrm> ← 本方法
<a:graphic>...</a:graphic>
<p:extLst>...</p:extLst> ← 可选
</p:graphicFrame>与 ShapeProperties::write_xml 的区别是:本方法不输出 prstGeom /
填充 / 边框(这些是 <p:spPr> 的职责),只输出位置 / 尺寸变换。
tag 参数指定外层元素标签名(如 "p:xfrm" 用于 PPTX)。
Sourcepub fn effects(&self) -> Option<&EffectList>
pub fn effects(&self) -> Option<&EffectList>
读取效果列表(<a:effectLst>)。None 表示未设置。
Sourcepub fn effects_mut(&mut self) -> &mut EffectList
pub fn effects_mut(&mut self) -> &mut EffectList
读取效果列表的可变引用。若未设置,自动初始化为空 EffectList。
调用此方法后即使不设置任何效果,也会写出空 <a:effectLst/>(PowerPoint 兼容)。
若要避免写出空元素,请用 Self::clear_effects。
Sourcepub fn set_outer_shadow(&mut self, shadow: ShadowEffect)
pub fn set_outer_shadow(&mut self, shadow: ShadowEffect)
设置外阴影(<a:outerShdw>)。覆盖既有外阴影,保留其他效果。
对标 python-pptx shape.shadow.inherit = False + shape.shadow.outerShadow。
§参数
shadow:阴影配置(方向/距离/模糊半径/颜色)
Sourcepub fn set_inner_shadow(&mut self, shadow: ShadowEffect)
pub fn set_inner_shadow(&mut self, shadow: ShadowEffect)
设置内阴影(<a:innerShdw>)。覆盖既有内阴影,保留其他效果。
Sourcepub fn set_glow(&mut self, glow: GlowEffect)
pub fn set_glow(&mut self, glow: GlowEffect)
设置发光(<a:glow>)。覆盖既有发光,保留其他效果。
Sourcepub fn set_soft_edge(&mut self, rad: i64)
pub fn set_soft_edge(&mut self, rad: i64)
设置柔化边缘(<a:softEdge>)。覆盖既有柔边,保留其他效果。
Sourcepub fn set_reflection(&mut self, reflection: ReflectionEffect)
pub fn set_reflection(&mut self, reflection: ReflectionEffect)
设置反射(<a:reflection>)。覆盖既有反射,保留其他效果。
Sourcepub fn clear_outer_shadow(&mut self)
pub fn clear_outer_shadow(&mut self)
清除外阴影。
Sourcepub fn clear_inner_shadow(&mut self)
pub fn clear_inner_shadow(&mut self)
清除内阴影。
Sourcepub fn clear_glow(&mut self)
pub fn clear_glow(&mut self)
清除发光。
Sourcepub fn clear_soft_edge(&mut self)
pub fn clear_soft_edge(&mut self)
清除柔化边缘。
Sourcepub fn clear_reflection(&mut self)
pub fn clear_reflection(&mut self)
清除反射。
Sourcepub fn clear_effects(&mut self)
pub fn clear_effects(&mut self)
清除所有效果(删除整个 <a:effectLst> 元素)。
Trait Implementations§
Source§impl Clone for ShapeProperties
impl Clone for ShapeProperties
Source§fn clone(&self) -> ShapeProperties
fn clone(&self) -> ShapeProperties
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more