Skip to main content

ShapeType

Enum ShapeType 

Source
pub enum ShapeType {
Show 125 variants Rectangle, RoundedRectangle, Ellipse, Circle, Triangle, RightTriangle, Diamond, Pentagon, Hexagon, Octagon, RightArrow, LeftArrow, UpArrow, DownArrow, LeftRightArrow, UpDownArrow, BentArrow, UTurnArrow, Star4, Star5, Star6, Star8, Ribbon, Wave, WedgeRectCallout, WedgeEllipseCallout, CloudCallout, FlowChartProcess, FlowChartDecision, FlowChartTerminator, FlowChartDocument, FlowChartPredefinedProcess, FlowChartInternalStorage, FlowChartData, FlowChartInputOutput, FlowChartManualInput, FlowChartManualOperation, FlowChartConnector, FlowChartOffPageConnector, FlowChartPunchedCard, FlowChartPunchedTape, FlowChartSummingJunction, FlowChartOr, FlowChartCollate, FlowChartSort, FlowChartExtract, FlowChartMerge, FlowChartOnlineStorage, FlowChartDelay, FlowChartMagneticTape, FlowChartMagneticDisk, FlowChartMagneticDrum, FlowChartDisplay, FlowChartPreparation, CurvedRightArrow, CurvedLeftArrow, CurvedUpArrow, CurvedDownArrow, CurvedLeftRightArrow, CurvedUpDownArrow, StripedRightArrow, NotchedRightArrow, PentagonArrow, ChevronArrow, RightArrowCallout, LeftArrowCallout, UpArrowCallout, DownArrowCallout, LeftRightArrowCallout, UpDownArrowCallout, QuadArrow, LeftRightUpArrow, CircularArrow, Parallelogram, Trapezoid, NonIsoscelesTrapezoid, IsoscelesTrapezoid, Cube, Can, Cone, Cylinder, Bevel, Donut, NoSmoking, BlockArc, FoldedCorner, SmileyFace, Arc, Chord, Pie, Teardrop, Plaque, MusicNote, PictureFrame, Star10, Star12, Star16, Star24, Star32, Seal, Seal4, Seal8, Seal16, Seal32, ActionButtonBlank, ActionButtonHome, ActionButtonHelp, ActionButtonInformation, ActionButtonForwardNext, ActionButtonBackPrevious, ActionButtonBeginning, ActionButtonEnd, ActionButtonReturn, ActionButtonDocument, ActionButtonSound, ActionButtonMovie, Heart, Lightning, Sun, Moon, Cloud, Brace, Bracket, Plus, Minus,
}
Expand description

Shape types available in PPTX

Variants§

§

Rectangle

§

RoundedRectangle

§

Ellipse

§

Circle

§

Triangle

§

RightTriangle

§

Diamond

§

Pentagon

§

Hexagon

§

Octagon

§

RightArrow

§

LeftArrow

§

UpArrow

§

DownArrow

§

LeftRightArrow

§

UpDownArrow

§

BentArrow

§

UTurnArrow

§

Star4

§

Star5

§

Star6

§

Star8

§

Ribbon

§

Wave

§

WedgeRectCallout

§

WedgeEllipseCallout

§

CloudCallout

§

FlowChartProcess

§

FlowChartDecision

§

FlowChartTerminator

§

FlowChartDocument

§

FlowChartPredefinedProcess

§

FlowChartInternalStorage

§

FlowChartData

§

FlowChartInputOutput

§

FlowChartManualInput

§

FlowChartManualOperation

§

FlowChartConnector

§

FlowChartOffPageConnector

§

FlowChartPunchedCard

§

FlowChartPunchedTape

§

FlowChartSummingJunction

§

FlowChartOr

§

FlowChartCollate

§

FlowChartSort

§

FlowChartExtract

§

FlowChartMerge

§

FlowChartOnlineStorage

§

FlowChartDelay

§

FlowChartMagneticTape

§

FlowChartMagneticDisk

§

FlowChartMagneticDrum

§

FlowChartDisplay

§

FlowChartPreparation

§

CurvedRightArrow

§

CurvedLeftArrow

§

CurvedUpArrow

§

CurvedDownArrow

§

CurvedLeftRightArrow

§

CurvedUpDownArrow

§

StripedRightArrow

§

NotchedRightArrow

§

PentagonArrow

§

ChevronArrow

§

RightArrowCallout

§

LeftArrowCallout

§

UpArrowCallout

§

DownArrowCallout

§

LeftRightArrowCallout

§

UpDownArrowCallout

§

QuadArrow

§

LeftRightUpArrow

§

CircularArrow

§

Parallelogram

§

Trapezoid

§

NonIsoscelesTrapezoid

§

IsoscelesTrapezoid

§

Cube

§

Can

§

Cone

§

Cylinder

§

Bevel

§

Donut

§

NoSmoking

§

BlockArc

§

FoldedCorner

§

SmileyFace

§

Arc

§

Chord

§

Pie

§

Teardrop

§

Plaque

§

MusicNote

§

PictureFrame

§

Star10

§

Star12

§

Star16

§

Star24

§

Star32

§

Seal

§

Seal4

§

Seal8

§

Seal16

§

Seal32

§

ActionButtonBlank

§

ActionButtonHome

§

ActionButtonHelp

§

ActionButtonInformation

§

ActionButtonForwardNext

§

ActionButtonBackPrevious

§

ActionButtonBeginning

§

ActionButtonEnd

§

ActionButtonReturn

§

ActionButtonDocument

§

ActionButtonSound

§

ActionButtonMovie

§

Heart

§

Lightning

§

Sun

§

Moon

§

Cloud

§

Brace

§

Bracket

§

Plus

§

Minus

Implementations§

Source§

impl ShapeType

Source

pub fn preset_name(&self) -> &'static str

Get the preset geometry name for the shape (OOXML preset name)

Examples found in repository?
examples/shapes_demo.rs (line 33)
11fn main() {
12    println!("╔════════════════════════════════════════════════════════════╗");
13    println!("║         PPTX Shapes Demo                                   ║");
14    println!("╚════════════════════════════════════════════════════════════╝\n");
15
16    // =========================================================================
17    // Basic Shapes
18    // =========================================================================
19    println!("📐 Basic Shapes:");
20    
21    let basic_shapes = [
22        ShapeType::Rectangle,
23        ShapeType::RoundedRectangle,
24        ShapeType::Ellipse,
25        ShapeType::Triangle,
26        ShapeType::Diamond,
27        ShapeType::Pentagon,
28        ShapeType::Hexagon,
29        ShapeType::Octagon,
30    ];
31    
32    for shape_type in &basic_shapes {
33        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
34    }
35
36    // =========================================================================
37    // Arrow Shapes
38    // =========================================================================
39    println!("\n➡️  Arrow Shapes:");
40    
41    let arrow_shapes = [
42        ShapeType::RightArrow,
43        ShapeType::LeftArrow,
44        ShapeType::UpArrow,
45        ShapeType::DownArrow,
46        ShapeType::LeftRightArrow,
47        ShapeType::UpDownArrow,
48    ];
49    
50    for shape_type in &arrow_shapes {
51        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
52    }
53
54    // =========================================================================
55    // Star and Banner Shapes
56    // =========================================================================
57    println!("\n⭐ Stars and Banners:");
58    
59    let star_shapes = [
60        ShapeType::Star4,
61        ShapeType::Star5,
62        ShapeType::Star6,
63        ShapeType::Star8,
64        ShapeType::Ribbon,
65        ShapeType::Wave,
66    ];
67    
68    for shape_type in &star_shapes {
69        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
70    }
71
72    // =========================================================================
73    // Callout Shapes
74    // =========================================================================
75    println!("\n💬 Callout Shapes:");
76    
77    let callout_shapes = [
78        ShapeType::WedgeRectCallout,
79        ShapeType::WedgeEllipseCallout,
80        ShapeType::CloudCallout,
81    ];
82    
83    for shape_type in &callout_shapes {
84        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
85    }
86
87    // =========================================================================
88    // Flow Chart Shapes
89    // =========================================================================
90    println!("\n📊 Flow Chart Shapes:");
91    
92    let flowchart_shapes = [
93        ShapeType::FlowChartProcess,
94        ShapeType::FlowChartDecision,
95        ShapeType::FlowChartTerminator,
96        ShapeType::FlowChartDocument,
97    ];
98    
99    for shape_type in &flowchart_shapes {
100        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
101    }
102
103    // =========================================================================
104    // Other Shapes
105    // =========================================================================
106    println!("\n🎨 Other Shapes:");
107    
108    let other_shapes = [
109        ShapeType::Heart,
110        ShapeType::Lightning,
111        ShapeType::Sun,
112        ShapeType::Moon,
113        ShapeType::Cloud,
114    ];
115    
116    for shape_type in &other_shapes {
117        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
118    }
119
120    // =========================================================================
121    // Shape with Fill
122    // =========================================================================
123    println!("\n🎨 Shape with Fill:");
124    
125    let filled_shape = Shape::new(
126        ShapeType::Rectangle,
127        inches_to_emu(1.0),
128        inches_to_emu(1.0),
129        inches_to_emu(3.0),
130        inches_to_emu(2.0),
131    ).with_fill(ShapeFill::new("4472C4")); // Blue fill
132    
133    let xml = generate_shape_xml(&filled_shape, 1);
134    println!("   Generated XML ({} chars)", xml.len());
135    println!("   Contains fill: {}", xml.contains("solidFill"));
136
137    // =========================================================================
138    // Shape with Line
139    // =========================================================================
140    println!("\n📏 Shape with Line:");
141    
142    let outlined_shape = Shape::new(
143        ShapeType::Ellipse,
144        inches_to_emu(1.0),
145        inches_to_emu(1.0),
146        inches_to_emu(2.0),
147        inches_to_emu(2.0),
148    ).with_line(ShapeLine::new("FF0000", 25400)); // Red outline, 2pt
149    
150    let xml = generate_shape_xml(&outlined_shape, 2);
151    println!("   Generated XML ({} chars)", xml.len());
152    println!("   Contains line: {}", xml.contains("a:ln"));
153
154    // =========================================================================
155    // Shape with Text
156    // =========================================================================
157    println!("\n📝 Shape with Text:");
158    
159    let text_shape = Shape::new(
160        ShapeType::RoundedRectangle,
161        cm_to_emu(5.0),
162        cm_to_emu(3.0),
163        cm_to_emu(8.0),
164        cm_to_emu(4.0),
165    )
166    .with_fill(ShapeFill::new("70AD47")) // Green fill
167    .with_text("Click Here!");
168    
169    let xml = generate_shape_xml(&text_shape, 3);
170    println!("   Generated XML ({} chars)", xml.len());
171    println!("   Contains text: {}", xml.contains("Click Here!"));
172
173    // =========================================================================
174    // Multiple Shapes
175    // =========================================================================
176    println!("\n📦 Multiple Shapes:");
177    
178    let shapes = vec![
179        Shape::new(ShapeType::Rectangle, 0, 0, 1000000, 500000)
180            .with_fill(ShapeFill::new("FF0000")),
181        Shape::new(ShapeType::Ellipse, 1200000, 0, 500000, 500000)
182            .with_fill(ShapeFill::new("00FF00")),
183        Shape::new(ShapeType::Triangle, 1900000, 0, 500000, 500000)
184            .with_fill(ShapeFill::new("0000FF")),
185    ];
186    
187    let xml = generate_shapes_xml(&shapes, 10);
188    println!("   Generated {} shapes", shapes.len());
189    println!("   Total XML: {} chars", xml.len());
190
191    // =========================================================================
192    // Connector (Arrow Line)
193    // =========================================================================
194    println!("\n🔗 Connector:");
195    
196    let connector_xml = generate_connector_xml(
197        0, 0,
198        inches_to_emu(3.0), inches_to_emu(2.0),
199        100,
200        "000000",
201        12700, // 1pt line
202    );
203    println!("   Generated connector XML ({} chars)", connector_xml.len());
204    println!("   Has arrow head: {}", connector_xml.contains("triangle"));
205
206    // =========================================================================
207    // Summary
208    // =========================================================================
209    println!("\n╔════════════════════════════════════════════════════════════╗");
210    println!("║                    Demo Complete                           ║");
211    println!("╠════════════════════════════════════════════════════════════╣");
212    println!("║  Shape Types Available: 40+                                ║");
213    println!("║  Features:                                                 ║");
214    println!("║  ✓ Basic shapes (rect, ellipse, triangle, etc.)            ║");
215    println!("║  ✓ Arrow shapes (8 directions)                             ║");
216    println!("║  ✓ Stars and banners                                       ║");
217    println!("║  ✓ Callouts                                                ║");
218    println!("║  ✓ Flow chart shapes                                       ║");
219    println!("║  ✓ Fill colors with transparency                           ║");
220    println!("║  ✓ Line/border styling                                     ║");
221    println!("║  ✓ Text inside shapes                                      ║");
222    println!("║  ✓ Connectors with arrow heads                             ║");
223    println!("╚════════════════════════════════════════════════════════════╝");
224}
Source

pub fn display_name(&self) -> &'static str

Get a user-friendly name for the shape

Examples found in repository?
examples/shapes_demo.rs (line 33)
11fn main() {
12    println!("╔════════════════════════════════════════════════════════════╗");
13    println!("║         PPTX Shapes Demo                                   ║");
14    println!("╚════════════════════════════════════════════════════════════╝\n");
15
16    // =========================================================================
17    // Basic Shapes
18    // =========================================================================
19    println!("📐 Basic Shapes:");
20    
21    let basic_shapes = [
22        ShapeType::Rectangle,
23        ShapeType::RoundedRectangle,
24        ShapeType::Ellipse,
25        ShapeType::Triangle,
26        ShapeType::Diamond,
27        ShapeType::Pentagon,
28        ShapeType::Hexagon,
29        ShapeType::Octagon,
30    ];
31    
32    for shape_type in &basic_shapes {
33        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
34    }
35
36    // =========================================================================
37    // Arrow Shapes
38    // =========================================================================
39    println!("\n➡️  Arrow Shapes:");
40    
41    let arrow_shapes = [
42        ShapeType::RightArrow,
43        ShapeType::LeftArrow,
44        ShapeType::UpArrow,
45        ShapeType::DownArrow,
46        ShapeType::LeftRightArrow,
47        ShapeType::UpDownArrow,
48    ];
49    
50    for shape_type in &arrow_shapes {
51        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
52    }
53
54    // =========================================================================
55    // Star and Banner Shapes
56    // =========================================================================
57    println!("\n⭐ Stars and Banners:");
58    
59    let star_shapes = [
60        ShapeType::Star4,
61        ShapeType::Star5,
62        ShapeType::Star6,
63        ShapeType::Star8,
64        ShapeType::Ribbon,
65        ShapeType::Wave,
66    ];
67    
68    for shape_type in &star_shapes {
69        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
70    }
71
72    // =========================================================================
73    // Callout Shapes
74    // =========================================================================
75    println!("\n💬 Callout Shapes:");
76    
77    let callout_shapes = [
78        ShapeType::WedgeRectCallout,
79        ShapeType::WedgeEllipseCallout,
80        ShapeType::CloudCallout,
81    ];
82    
83    for shape_type in &callout_shapes {
84        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
85    }
86
87    // =========================================================================
88    // Flow Chart Shapes
89    // =========================================================================
90    println!("\n📊 Flow Chart Shapes:");
91    
92    let flowchart_shapes = [
93        ShapeType::FlowChartProcess,
94        ShapeType::FlowChartDecision,
95        ShapeType::FlowChartTerminator,
96        ShapeType::FlowChartDocument,
97    ];
98    
99    for shape_type in &flowchart_shapes {
100        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
101    }
102
103    // =========================================================================
104    // Other Shapes
105    // =========================================================================
106    println!("\n🎨 Other Shapes:");
107    
108    let other_shapes = [
109        ShapeType::Heart,
110        ShapeType::Lightning,
111        ShapeType::Sun,
112        ShapeType::Moon,
113        ShapeType::Cloud,
114    ];
115    
116    for shape_type in &other_shapes {
117        println!("   {} → {}", shape_type.display_name(), shape_type.preset_name());
118    }
119
120    // =========================================================================
121    // Shape with Fill
122    // =========================================================================
123    println!("\n🎨 Shape with Fill:");
124    
125    let filled_shape = Shape::new(
126        ShapeType::Rectangle,
127        inches_to_emu(1.0),
128        inches_to_emu(1.0),
129        inches_to_emu(3.0),
130        inches_to_emu(2.0),
131    ).with_fill(ShapeFill::new("4472C4")); // Blue fill
132    
133    let xml = generate_shape_xml(&filled_shape, 1);
134    println!("   Generated XML ({} chars)", xml.len());
135    println!("   Contains fill: {}", xml.contains("solidFill"));
136
137    // =========================================================================
138    // Shape with Line
139    // =========================================================================
140    println!("\n📏 Shape with Line:");
141    
142    let outlined_shape = Shape::new(
143        ShapeType::Ellipse,
144        inches_to_emu(1.0),
145        inches_to_emu(1.0),
146        inches_to_emu(2.0),
147        inches_to_emu(2.0),
148    ).with_line(ShapeLine::new("FF0000", 25400)); // Red outline, 2pt
149    
150    let xml = generate_shape_xml(&outlined_shape, 2);
151    println!("   Generated XML ({} chars)", xml.len());
152    println!("   Contains line: {}", xml.contains("a:ln"));
153
154    // =========================================================================
155    // Shape with Text
156    // =========================================================================
157    println!("\n📝 Shape with Text:");
158    
159    let text_shape = Shape::new(
160        ShapeType::RoundedRectangle,
161        cm_to_emu(5.0),
162        cm_to_emu(3.0),
163        cm_to_emu(8.0),
164        cm_to_emu(4.0),
165    )
166    .with_fill(ShapeFill::new("70AD47")) // Green fill
167    .with_text("Click Here!");
168    
169    let xml = generate_shape_xml(&text_shape, 3);
170    println!("   Generated XML ({} chars)", xml.len());
171    println!("   Contains text: {}", xml.contains("Click Here!"));
172
173    // =========================================================================
174    // Multiple Shapes
175    // =========================================================================
176    println!("\n📦 Multiple Shapes:");
177    
178    let shapes = vec![
179        Shape::new(ShapeType::Rectangle, 0, 0, 1000000, 500000)
180            .with_fill(ShapeFill::new("FF0000")),
181        Shape::new(ShapeType::Ellipse, 1200000, 0, 500000, 500000)
182            .with_fill(ShapeFill::new("00FF00")),
183        Shape::new(ShapeType::Triangle, 1900000, 0, 500000, 500000)
184            .with_fill(ShapeFill::new("0000FF")),
185    ];
186    
187    let xml = generate_shapes_xml(&shapes, 10);
188    println!("   Generated {} shapes", shapes.len());
189    println!("   Total XML: {} chars", xml.len());
190
191    // =========================================================================
192    // Connector (Arrow Line)
193    // =========================================================================
194    println!("\n🔗 Connector:");
195    
196    let connector_xml = generate_connector_xml(
197        0, 0,
198        inches_to_emu(3.0), inches_to_emu(2.0),
199        100,
200        "000000",
201        12700, // 1pt line
202    );
203    println!("   Generated connector XML ({} chars)", connector_xml.len());
204    println!("   Has arrow head: {}", connector_xml.contains("triangle"));
205
206    // =========================================================================
207    // Summary
208    // =========================================================================
209    println!("\n╔════════════════════════════════════════════════════════════╗");
210    println!("║                    Demo Complete                           ║");
211    println!("╠════════════════════════════════════════════════════════════╣");
212    println!("║  Shape Types Available: 40+                                ║");
213    println!("║  Features:                                                 ║");
214    println!("║  ✓ Basic shapes (rect, ellipse, triangle, etc.)            ║");
215    println!("║  ✓ Arrow shapes (8 directions)                             ║");
216    println!("║  ✓ Stars and banners                                       ║");
217    println!("║  ✓ Callouts                                                ║");
218    println!("║  ✓ Flow chart shapes                                       ║");
219    println!("║  ✓ Fill colors with transparency                           ║");
220    println!("║  ✓ Line/border styling                                     ║");
221    println!("║  ✓ Text inside shapes                                      ║");
222    println!("║  ✓ Connectors with arrow heads                             ║");
223    println!("╚════════════════════════════════════════════════════════════╝");
224}

Trait Implementations§

Source§

impl Clone for ShapeType

Source§

fn clone(&self) -> ShapeType

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ShapeType

Source§

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

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

impl PartialEq for ShapeType

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for ShapeType

Source§

impl StructuralPartialEq for ShapeType

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more