1use ppt_rs::generator::{
6 Shape, ShapeType, ShapeFill, ShapeLine,
7 generate_shape_xml, generate_shapes_xml, generate_connector_xml,
8 inches_to_emu, cm_to_emu,
9};
10
11fn main() {
12 println!("╔════════════════════════════════════════════════════════════╗");
13 println!("║ PPTX Shapes Demo ║");
14 println!("╚════════════════════════════════════════════════════════════╝\n");
15
16 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 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 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 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 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 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 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")); let xml = generate_shape_xml(&filled_shape, 1);
134 println!(" Generated XML ({} chars)", xml.len());
135 println!(" Contains fill: {}", xml.contains("solidFill"));
136
137 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)); 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 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")) .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 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 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, );
203 println!(" Generated connector XML ({} chars)", connector_xml.len());
204 println!(" Has arrow head: {}", connector_xml.contains("triangle"));
205
206 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}