Skip to main content

Shape

Trait Shape 

Source
pub trait Shape {
Show 15 methods // Required methods fn id(&self) -> u32; fn set_id(&mut self, id: u32); fn name(&self) -> &str; fn set_name(&mut self, name: String); fn shape_type(&self) -> &'static str; fn left(&self) -> Emu; fn set_left(&mut self, emu: Emu); fn top(&self) -> Emu; fn set_top(&mut self, emu: Emu); fn width(&self) -> Emu; fn set_width(&mut self, emu: Emu); fn height(&self) -> Emu; fn set_height(&mut self, emu: Emu); fn rotation(&self) -> f64; fn set_rotation(&mut self, deg: f64);
}
Expand description

高阶形状的抽象接口。

调用方拿到一个 Shape(trait object)或具体类型时,可通过此 trait 访问“位置 / 尺寸 / 旋转“等通用属性。具体类型特有属性需用具体类型 句柄访问。

Required Methods§

Source

fn id(&self) -> u32

形状唯一 ID(在所属 slide 内)。

ID 由 add_* 流程自动分配,调用方一般不应手动设置。

Source

fn set_id(&mut self, id: u32)

设置 ID。

Source

fn name(&self) -> &str

形状名。

Source

fn set_name(&mut self, name: String)

设置形状名。

Source

fn shape_type(&self) -> &'static str

形状类型(如 "text_box" / "picture" / …)。

返回值与 crate::shape::ShapeKind::shape_type 保持一致。

Source

fn left(&self) -> Emu

左上角 x(EMU)。

Source

fn set_left(&mut self, emu: Emu)

设置左上角 x。

Source

fn top(&self) -> Emu

左上角 y(EMU)。

Source

fn set_top(&mut self, emu: Emu)

设置左上角 y。

Source

fn width(&self) -> Emu

宽(EMU)。

Source

fn set_width(&mut self, emu: Emu)

设置宽。

Source

fn height(&self) -> Emu

高(EMU)。

Source

fn set_height(&mut self, emu: Emu)

设置高。

Source

fn rotation(&self) -> f64

旋转角度(度数,正向顺时针)。

与 OOXML 规范的“60000 分之一度“通过 set_rotation 自动转换; 读取时返回度数。

Source

fn set_rotation(&mut self, deg: f64)

设置旋转角度。

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§