Skip to main content

Shape

Struct Shape 

Source
pub struct Shape {
    pub shape_type: ShapeType,
    pub x: u32,
    pub y: u32,
    pub width: u32,
    pub height: u32,
    pub fill: Option<ShapeFill>,
    pub gradient: Option<GradientFill>,
    pub line: Option<ShapeLine>,
    pub text: Option<String>,
    pub id: Option<u32>,
    pub rotation: Option<i32>,
    pub hyperlink: Option<Hyperlink>,
}
Expand description

Shape definition

Fields§

§shape_type: ShapeType§x: u32§y: u32§width: u32§height: u32§fill: Option<ShapeFill>§gradient: Option<GradientFill>§line: Option<ShapeLine>§text: Option<String>§id: Option<u32>

Optional fixed shape ID for connector anchoring

§rotation: Option<i32>

Rotation in degrees (0-360)

§hyperlink: Option<Hyperlink>

Optional hyperlink

Implementations§

Source§

impl Shape

Source

pub fn new( shape_type: ShapeType, x: u32, y: u32, width: u32, height: u32, ) -> Self

Create a new shape

Source

pub fn with_id(self, id: u32) -> Self

Set shape ID for connector anchoring

Source

pub fn with_rotation(self, degrees: i32) -> Self

Set shape rotation in degrees

Set shape hyperlink

Source

pub fn with_fill(self, fill: ShapeFill) -> Self

Set shape fill (solid color)

Source

pub fn with_gradient(self, gradient: GradientFill) -> Self

Set gradient fill

Source

pub fn with_line(self, line: ShapeLine) -> Self

Set shape line

Source

pub fn with_text(self, text: &str) -> Self

Set shape text

Source

pub fn from_dimensions( shape_type: ShapeType, x: Dimension, y: Dimension, width: Dimension, height: Dimension, ) -> Self

Create a shape using flexible Dimension units for position and size.

use ppt_rs::core::Dimension;
use ppt_rs::generator::shapes::{Shape, ShapeType};

// Position at 10% from left, 20% from top; size = 80% width, 2 inches height
let shape = Shape::from_dimensions(
    ShapeType::Rectangle,
    Dimension::Ratio(0.1), Dimension::Ratio(0.2),
    Dimension::Ratio(0.8), Dimension::Inches(2.0),
);
Source

pub fn at(self, x: Dimension, y: Dimension) -> Self

Set position using flexible Dimension units (fluent).

use ppt_rs::core::Dimension;
use ppt_rs::generator::shapes::{Shape, ShapeType};

let shape = Shape::new(ShapeType::Rectangle, 0, 0, 914400, 914400)
    .at(Dimension::Ratio(0.5), Dimension::Ratio(0.5));
Source

pub fn with_dimensions(self, width: Dimension, height: Dimension) -> Self

Set size using flexible Dimension units (fluent).

use ppt_rs::core::Dimension;
use ppt_rs::generator::shapes::{Shape, ShapeType};

let shape = Shape::new(ShapeType::Rectangle, 0, 0, 0, 0)
    .with_dimensions(Dimension::Inches(3.0), Dimension::Cm(5.0));

Trait Implementations§

Source§

impl Clone for Shape

Source§

fn clone(&self) -> Shape

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Shape

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Positioned for Shape

Source§

fn x(&self) -> u32

Get X position in EMU
Source§

fn y(&self) -> u32

Get Y position in EMU
Source§

fn set_position(&mut self, x: u32, y: u32)

Set position
Source§

impl ShapeExt for Shape

Source§

fn fill(self, color: Color) -> Self

Set the fill color (shorter alias for with_fill)
Source§

fn stroke(self, color: Color, width_pt: f64) -> Self

Set the stroke/line (shorter alias for with_line)
Source§

fn text(self, text: &str) -> Self

Set the text (shorter alias for with_text)
Source§

impl Sized for Shape

Source§

fn width(&self) -> u32

Get width in EMU
Source§

fn height(&self) -> u32

Get height in EMU
Source§

fn set_size(&mut self, width: u32, height: u32)

Set size

Auto Trait Implementations§

§

impl Freeze for Shape

§

impl RefUnwindSafe for Shape

§

impl Send for Shape

§

impl Sync for Shape

§

impl Unpin for Shape

§

impl UnsafeUnpin for Shape

§

impl UnwindSafe for Shape

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.