Skip to main content

Line

Struct Line 

Source
pub struct Line {
    pub width_emu: Option<i64>,
    pub fill: Option<Fill>,
    pub dash: Option<PresetLineDash>,
    pub cap: Option<LineCap>,
    pub join: Option<LineJoin>,
    pub head_end: Option<LineEnd>,
    pub tail_end: Option<LineEnd>,
    pub compound: Option<LineCompound>,
}
Expand description

A shape’s outline stroke (<a:ln>, CT_LineProperties).

Not modeled: <a:extLst> (extension list) and the pen-alignment (algn — center/inset) attribute — a rare, cosmetic refinement. The compound-line attribute (cmpd) is modeled, see LineCompound.

Fields§

§width_emu: Option<i64>

w — the stroke’s width, in EMUs.

§fill: Option<Fill>

EG_LineFillProperties — how the stroke itself is painted (the same fill choices as a shape’s interior, minus image/group fills, which aren’t valid here per the schema).

§dash: Option<PresetLineDash>

<a:prstDash val=".."> — one of the 11 preset dash patterns. Custom dash patterns (<a:custDash>, an explicit dash/space stop list) are deferred.

§cap: Option<LineCap>

cap — the stroke’s end-cap style.

§join: Option<LineJoin>

EG_LineJoinProperties — how the stroke’s corners are drawn.

§head_end: Option<LineEnd>

<a:headEnd> — the arrowhead (or other decoration) at the line’s start.

§tail_end: Option<LineEnd>

<a:tailEnd> — the arrowhead (or other decoration) at the line’s end.

§compound: Option<LineCompound>

cmpd — the stroke’s compound-line style (single/double/thick-thin/ thin-thick/triple). None omits the attribute (ST_CompoundLine’s own schema default, "sng", applies). Grounded against a real fixture’s slide master border (cmpd="sng").

Implementations§

Source§

impl Line

Source

pub fn new() -> Line

Examples found in repository?
examples/pptx_grouping_and_connectors.rs (line 114)
16fn main() -> office_toolkit::Result<()> {
17    let path = output_path("pptx_grouping_and_connectors.pptx");
18
19    // Every shape below sets an explicit fill (and the connector an
20    // explicit line): with neither a fill/line nor a `<p:style>` theme
21    // reference, a shape has nothing to paint and renders as fully
22    // invisible — the slide then looks blank even though the shapes are
23    // there. `AutoShape`/`Connector` have no `<p:style>` support yet, so an
24    // explicit `Fill`/`Line` is the only way to make a shape actually show.
25    let circle_fill = || Fill::Solid(Color::Rgb("4472C4".to_string()));
26
27    let circle = AutoShape::new(11, "Circle").with_properties(
28        ShapeProperties::new()
29            .with_transform(
30                Transform2D::new()
31                    .with_offset(0, 0)
32                    .with_extent(1_000_000, 1_000_000),
33            )
34            .with_fill(circle_fill()),
35    );
36    let label = AutoShape::new(12, "Label")
37        .with_properties(
38            ShapeProperties::new()
39                .with_transform(
40                    Transform2D::new()
41                        .with_offset(1_200_000, 300_000)
42                        .with_extent(1_500_000, 400_000),
43                )
44                .with_fill(Fill::Solid(Color::Rgb("E8622C".to_string()))),
45        )
46        .with_text_body(
47            TextBody::new()
48                .with_paragraph(TextParagraph::new().with_run(TextRun::text("Grouped label"))),
49        );
50
51    let group = ShapeGroup::new(2, "Group")
52        .with_transform(
53            (838_200, 838_200),
54            (2_700_000, 1_000_000),
55            (0, 0),
56            (2_700_000, 1_000_000),
57        )
58        .with_shape(Shape::AutoShape(circle))
59        .with_shape(Shape::AutoShape(label));
60
61    let rotated_circle = AutoShape::new(11, "Circle").with_properties(
62        ShapeProperties::new()
63            .with_transform(
64                Transform2D::new()
65                    .with_offset(0, 0)
66                    .with_extent(1_000_000, 1_000_000),
67            )
68            .with_fill(circle_fill()),
69    );
70    let rotated_group = ShapeGroup::new(2, "Rotated and flipped group")
71        .with_transform(
72            (838_200, 838_200),
73            (1_000_000, 1_000_000),
74            (0, 0),
75            (1_000_000, 1_000_000),
76        )
77        .with_rotation_degrees(45.0)
78        .with_flip_horizontal(true)
79        .with_shape(Shape::AutoShape(rotated_circle));
80
81    let box_a = AutoShape::new(2, "Box A").with_properties(
82        ShapeProperties::new()
83            .with_transform(
84                Transform2D::new()
85                    .with_offset(838_200, 838_200)
86                    .with_extent(1_000_000, 1_000_000),
87            )
88            .with_fill(Fill::Solid(Color::Rgb("2E86AB".to_string()))),
89    );
90    let box_b = AutoShape::new(3, "Box B").with_properties(
91        ShapeProperties::new()
92            .with_transform(
93                Transform2D::new()
94                    .with_offset(3_500_000, 838_200)
95                    .with_extent(1_000_000, 1_000_000),
96            )
97            .with_fill(Fill::Solid(Color::Rgb("6FB98F".to_string()))),
98    );
99    // `Connector::new` leaves position/size unset, which the writer then
100    // emits as a zero-size `<a:xfrm>` (off 0,0 / ext 0,0) — a real point
101    // with no length, invisible regardless of line/fill. `stCxn`/`endCxn`
102    // alone don't supply geometry; PowerPoint only recomputes it once you
103    // drag one of the attached shapes. So this also sets an explicit
104    // transform spanning Box A's right edge to Box B's left edge.
105    let connector = Connector::new(4, "Connector")
106        .with_properties(
107            ShapeProperties::new()
108                .with_transform(
109                    Transform2D::new()
110                        .with_offset(1_838_200, 1_338_200)
111                        .with_extent(1_662_000, 0),
112                )
113                .with_line(
114                    Line::new()
115                        .with_width_emu(25_400)
116                        .with_fill(Fill::Solid(Color::Rgb("000000".to_string()))),
117                ),
118        )
119        .with_start_connection(2, 0)
120        .with_end_connection(3, 0);
121
122    let presentation = Presentation::new()
123        .with_slide(Slide::new().with_shape(Shape::Group(group)))
124        .with_slide(Slide::new().with_shape(Shape::Group(rotated_group)))
125        .with_slide(
126            Slide::new()
127                .with_shape(Shape::AutoShape(box_a))
128                .with_shape(Shape::AutoShape(box_b))
129                .with_shape(Shape::Connector(connector)),
130        );
131
132    presentation.save_to_file(&path)?;
133    println!("Wrote {}", path.display());
134    Ok(())
135}
Source

pub fn with_compound(self, compound: LineCompound) -> Line

Source

pub fn with_width_emu(self, width_emu: i64) -> Line

Examples found in repository?
examples/pptx_grouping_and_connectors.rs (line 115)
16fn main() -> office_toolkit::Result<()> {
17    let path = output_path("pptx_grouping_and_connectors.pptx");
18
19    // Every shape below sets an explicit fill (and the connector an
20    // explicit line): with neither a fill/line nor a `<p:style>` theme
21    // reference, a shape has nothing to paint and renders as fully
22    // invisible — the slide then looks blank even though the shapes are
23    // there. `AutoShape`/`Connector` have no `<p:style>` support yet, so an
24    // explicit `Fill`/`Line` is the only way to make a shape actually show.
25    let circle_fill = || Fill::Solid(Color::Rgb("4472C4".to_string()));
26
27    let circle = AutoShape::new(11, "Circle").with_properties(
28        ShapeProperties::new()
29            .with_transform(
30                Transform2D::new()
31                    .with_offset(0, 0)
32                    .with_extent(1_000_000, 1_000_000),
33            )
34            .with_fill(circle_fill()),
35    );
36    let label = AutoShape::new(12, "Label")
37        .with_properties(
38            ShapeProperties::new()
39                .with_transform(
40                    Transform2D::new()
41                        .with_offset(1_200_000, 300_000)
42                        .with_extent(1_500_000, 400_000),
43                )
44                .with_fill(Fill::Solid(Color::Rgb("E8622C".to_string()))),
45        )
46        .with_text_body(
47            TextBody::new()
48                .with_paragraph(TextParagraph::new().with_run(TextRun::text("Grouped label"))),
49        );
50
51    let group = ShapeGroup::new(2, "Group")
52        .with_transform(
53            (838_200, 838_200),
54            (2_700_000, 1_000_000),
55            (0, 0),
56            (2_700_000, 1_000_000),
57        )
58        .with_shape(Shape::AutoShape(circle))
59        .with_shape(Shape::AutoShape(label));
60
61    let rotated_circle = AutoShape::new(11, "Circle").with_properties(
62        ShapeProperties::new()
63            .with_transform(
64                Transform2D::new()
65                    .with_offset(0, 0)
66                    .with_extent(1_000_000, 1_000_000),
67            )
68            .with_fill(circle_fill()),
69    );
70    let rotated_group = ShapeGroup::new(2, "Rotated and flipped group")
71        .with_transform(
72            (838_200, 838_200),
73            (1_000_000, 1_000_000),
74            (0, 0),
75            (1_000_000, 1_000_000),
76        )
77        .with_rotation_degrees(45.0)
78        .with_flip_horizontal(true)
79        .with_shape(Shape::AutoShape(rotated_circle));
80
81    let box_a = AutoShape::new(2, "Box A").with_properties(
82        ShapeProperties::new()
83            .with_transform(
84                Transform2D::new()
85                    .with_offset(838_200, 838_200)
86                    .with_extent(1_000_000, 1_000_000),
87            )
88            .with_fill(Fill::Solid(Color::Rgb("2E86AB".to_string()))),
89    );
90    let box_b = AutoShape::new(3, "Box B").with_properties(
91        ShapeProperties::new()
92            .with_transform(
93                Transform2D::new()
94                    .with_offset(3_500_000, 838_200)
95                    .with_extent(1_000_000, 1_000_000),
96            )
97            .with_fill(Fill::Solid(Color::Rgb("6FB98F".to_string()))),
98    );
99    // `Connector::new` leaves position/size unset, which the writer then
100    // emits as a zero-size `<a:xfrm>` (off 0,0 / ext 0,0) — a real point
101    // with no length, invisible regardless of line/fill. `stCxn`/`endCxn`
102    // alone don't supply geometry; PowerPoint only recomputes it once you
103    // drag one of the attached shapes. So this also sets an explicit
104    // transform spanning Box A's right edge to Box B's left edge.
105    let connector = Connector::new(4, "Connector")
106        .with_properties(
107            ShapeProperties::new()
108                .with_transform(
109                    Transform2D::new()
110                        .with_offset(1_838_200, 1_338_200)
111                        .with_extent(1_662_000, 0),
112                )
113                .with_line(
114                    Line::new()
115                        .with_width_emu(25_400)
116                        .with_fill(Fill::Solid(Color::Rgb("000000".to_string()))),
117                ),
118        )
119        .with_start_connection(2, 0)
120        .with_end_connection(3, 0);
121
122    let presentation = Presentation::new()
123        .with_slide(Slide::new().with_shape(Shape::Group(group)))
124        .with_slide(Slide::new().with_shape(Shape::Group(rotated_group)))
125        .with_slide(
126            Slide::new()
127                .with_shape(Shape::AutoShape(box_a))
128                .with_shape(Shape::AutoShape(box_b))
129                .with_shape(Shape::Connector(connector)),
130        );
131
132    presentation.save_to_file(&path)?;
133    println!("Wrote {}", path.display());
134    Ok(())
135}
Source

pub fn with_fill(self, fill: Fill) -> Line

Examples found in repository?
examples/pptx_grouping_and_connectors.rs (line 116)
16fn main() -> office_toolkit::Result<()> {
17    let path = output_path("pptx_grouping_and_connectors.pptx");
18
19    // Every shape below sets an explicit fill (and the connector an
20    // explicit line): with neither a fill/line nor a `<p:style>` theme
21    // reference, a shape has nothing to paint and renders as fully
22    // invisible — the slide then looks blank even though the shapes are
23    // there. `AutoShape`/`Connector` have no `<p:style>` support yet, so an
24    // explicit `Fill`/`Line` is the only way to make a shape actually show.
25    let circle_fill = || Fill::Solid(Color::Rgb("4472C4".to_string()));
26
27    let circle = AutoShape::new(11, "Circle").with_properties(
28        ShapeProperties::new()
29            .with_transform(
30                Transform2D::new()
31                    .with_offset(0, 0)
32                    .with_extent(1_000_000, 1_000_000),
33            )
34            .with_fill(circle_fill()),
35    );
36    let label = AutoShape::new(12, "Label")
37        .with_properties(
38            ShapeProperties::new()
39                .with_transform(
40                    Transform2D::new()
41                        .with_offset(1_200_000, 300_000)
42                        .with_extent(1_500_000, 400_000),
43                )
44                .with_fill(Fill::Solid(Color::Rgb("E8622C".to_string()))),
45        )
46        .with_text_body(
47            TextBody::new()
48                .with_paragraph(TextParagraph::new().with_run(TextRun::text("Grouped label"))),
49        );
50
51    let group = ShapeGroup::new(2, "Group")
52        .with_transform(
53            (838_200, 838_200),
54            (2_700_000, 1_000_000),
55            (0, 0),
56            (2_700_000, 1_000_000),
57        )
58        .with_shape(Shape::AutoShape(circle))
59        .with_shape(Shape::AutoShape(label));
60
61    let rotated_circle = AutoShape::new(11, "Circle").with_properties(
62        ShapeProperties::new()
63            .with_transform(
64                Transform2D::new()
65                    .with_offset(0, 0)
66                    .with_extent(1_000_000, 1_000_000),
67            )
68            .with_fill(circle_fill()),
69    );
70    let rotated_group = ShapeGroup::new(2, "Rotated and flipped group")
71        .with_transform(
72            (838_200, 838_200),
73            (1_000_000, 1_000_000),
74            (0, 0),
75            (1_000_000, 1_000_000),
76        )
77        .with_rotation_degrees(45.0)
78        .with_flip_horizontal(true)
79        .with_shape(Shape::AutoShape(rotated_circle));
80
81    let box_a = AutoShape::new(2, "Box A").with_properties(
82        ShapeProperties::new()
83            .with_transform(
84                Transform2D::new()
85                    .with_offset(838_200, 838_200)
86                    .with_extent(1_000_000, 1_000_000),
87            )
88            .with_fill(Fill::Solid(Color::Rgb("2E86AB".to_string()))),
89    );
90    let box_b = AutoShape::new(3, "Box B").with_properties(
91        ShapeProperties::new()
92            .with_transform(
93                Transform2D::new()
94                    .with_offset(3_500_000, 838_200)
95                    .with_extent(1_000_000, 1_000_000),
96            )
97            .with_fill(Fill::Solid(Color::Rgb("6FB98F".to_string()))),
98    );
99    // `Connector::new` leaves position/size unset, which the writer then
100    // emits as a zero-size `<a:xfrm>` (off 0,0 / ext 0,0) — a real point
101    // with no length, invisible regardless of line/fill. `stCxn`/`endCxn`
102    // alone don't supply geometry; PowerPoint only recomputes it once you
103    // drag one of the attached shapes. So this also sets an explicit
104    // transform spanning Box A's right edge to Box B's left edge.
105    let connector = Connector::new(4, "Connector")
106        .with_properties(
107            ShapeProperties::new()
108                .with_transform(
109                    Transform2D::new()
110                        .with_offset(1_838_200, 1_338_200)
111                        .with_extent(1_662_000, 0),
112                )
113                .with_line(
114                    Line::new()
115                        .with_width_emu(25_400)
116                        .with_fill(Fill::Solid(Color::Rgb("000000".to_string()))),
117                ),
118        )
119        .with_start_connection(2, 0)
120        .with_end_connection(3, 0);
121
122    let presentation = Presentation::new()
123        .with_slide(Slide::new().with_shape(Shape::Group(group)))
124        .with_slide(Slide::new().with_shape(Shape::Group(rotated_group)))
125        .with_slide(
126            Slide::new()
127                .with_shape(Shape::AutoShape(box_a))
128                .with_shape(Shape::AutoShape(box_b))
129                .with_shape(Shape::Connector(connector)),
130        );
131
132    presentation.save_to_file(&path)?;
133    println!("Wrote {}", path.display());
134    Ok(())
135}
Source

pub fn with_dash(self, dash: PresetLineDash) -> Line

Source

pub fn with_cap(self, cap: LineCap) -> Line

Source

pub fn with_join(self, join: LineJoin) -> Line

Source

pub fn with_head_end(self, end: LineEnd) -> Line

Source

pub fn with_tail_end(self, end: LineEnd) -> Line

Trait Implementations§

Source§

impl Clone for Line

Source§

fn clone(&self) -> Line

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 Line

Source§

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

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

impl Default for Line

Source§

fn default() -> Line

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Line

Source§

fn eq(&self, other: &Line) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Line

Auto Trait Implementations§

§

impl Freeze for Line

§

impl RefUnwindSafe for Line

§

impl Send for Line

§

impl Sync for Line

§

impl Unpin for Line

§

impl UnsafeUnpin for Line

§

impl UnwindSafe for Line

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.