Shapes
Rectangles, ellipses, stars and custom geometry built from point commands, with fills, lines, rotation and text.
DemoShape
Source file Modules/DemoShape.cs
Slide methods genSlide01 – genSlide03
Output files shape_genSlide*.pptx
1Overview
DemoShape shows the two drawing entry points of the API: slide.addShape(ShapeType.…, ShapeProps) for plain geometry, and addText/addShape options where text and shape are combined.
The point list for custom geometry uses dedicated command classes — MoveToPoint, QuadraticCurvePoint and ClosePoint — mirroring the SVG-style path syntax of PptxGen.js.
2Demo methods
| Method | What it demonstrates |
|---|---|
| genSlide01 | Shape types without text — rect, ellipse, custGeom points, rotate:45, solid/none fills. |
| genSlide02 | Shapes with text — translucent fills, aligned captions, custom geometry re-used. |
| genSlide03 | Hyperlink text — HyperlinkProps(url, tooltip) per run. |
3Code samples
Basic shape types rect, ellipse, custGeom with a MoveTo/Quadratic/Close point path and rotate:45. DemoShape.cs · genSlide01
// TOP-ROW
slide.addShape(ShapeType.rect,
new ShapeProps { x = 0.5, y = 0.8, w = 1.5, h = 3.0,
fill = (SCHEME_COLORS.accent1),
line = new ShapeLineProps { type = ShapeFillType.none }
});
slide.addShape(ShapeType.ellipse, new ShapeProps {
x = 2.2, y = 0.8, w = 3.0, h = 1.5,
fill = new ShapeFillProps(ShapeFillType.solid, SCHEME_COLORS.accent2)
});
slide.addShape(ShapeType.custGeom, new ShapeProps
{
x = 2.5,
y = 2.6,
w = 2.0,
h = 1.0,
fill = (SCHEME_COLORS.accent3),
line = new ShapeLineProps { color = "151515", width = 1 },
points = new List<ShapePropsPoint>
{
new MoveToPoint(0.0, 0.0 ),
new MoveToPoint(0.5, 1.0 ),
new MoveToPoint(1.0, 0.8 ),
new MoveToPoint(1.5, 1.0 ),
new MoveToPoint(2.0, 0.0 ),
new QuadraticCurvePoint(0.0, 0.0, new QuadraticCurvePoint.QuadraticCurve(1.0, 0.5)),
new ClosePoint(true),
},
});
slide.addShape(ShapeType.rect, new ShapeProps {
x = 5.7, y = 0.8, w = 1.5, h = 3.0, rotate = 45,
Shapes with captions Text + geometry: translucent fill, centered label, custom path re-used. DemoShape.cs · genSlide02
x = 2.2,
y = 0.8,
w = 3.0,
h = 1.5,
fill = new ShapeFillProps(SCHEME_COLORS.accent2, 50, ShapeFillType.solid),
align = HAlign.center,
fontSize = 14,
});
slide.addText("CUSTOM", new TextPropsOptions
{
shape = ShapeType.custGeom,
x = 2.5,
y = 2.6,
w = 2.0,
h = 1.0,
fill = (SCHEME_COLORS.accent3),
line = new ShapeLineProps { color = "151515", width = 1 },
shapeProps = new ShapeProps
{
points = new List<ShapePropsPoint>
{
new MoveToPoint(0.0, 0.0 ),
new MoveToPoint(0.5, 1.0 ),
new MoveToPoint(1.0, 0.8 ),
new MoveToPoint(1.5, 1.0 ),
new MoveToPoint(2.0, 0.0 ),
new QuadraticCurvePoint(0.0, 0.0, new QuadraticCurvePoint.QuadraticCurve(1.0, 0.5)),
new ClosePoint (true),
}
},
align = HAlign.center,
fontSize = 14,
});
slide.addText("RECTANGLE (rotate:45)", new TextPropsOptions
{
shape = ShapeType.rect,
x = 5.7,
y = 0.8,
w = 1.5,
Hyperlink text Whole method: HyperlinkProps(url, tooltip) on text runs. DemoShape.cs · genSlide03
public static void genSlide03(PptxGen pptx)
{
var slide = pptx.addSlide(new AddSlideProps { sectionTitle = "Shapes" });
List<TextProps> textes = new List<TextProps>{
new TextProps { text = "test", options = new TextPropsOptions { hyperlink = new HyperlinkProps("https://sina.com", "Visit Sina" ) } },
// { text:"test", options: { hyperlink: { url: "https://github.com/gitbrent/pptxgenjs", tooltip: "Visit Homepage" } } }
};
var options = new TextPropsOptions { hyperlink = new HyperlinkProps("https://baidu.com", "Visit Baidu") };
slide.addText(textes, options);
List<TextProps> textes1 = new List<TextProps>{
new TextProps { text = "test", options = new TextPropsOptions { hyperlink = new HyperlinkProps("https://sina.com", "Visit Sina" ) } },
// { text:"test", options: { hyperlink: { url: "https://github.com/gitbrent/pptxgenjs", tooltip: "Visit Homepage" } } }
};
var options1 = new TextPropsOptions { hyperlink = new HyperlinkProps("https://baidu.com", "Visit Baidu") };
slide.addText(textes1, options1);
}
4Key notes
Coordinates are inches, origin at the top-left of the slide: x = left edge, y = top edge, w = width, h = height.
fills accept either a plain color string, ShapeFillProps(ShapeFillType.solid, color), or ShapeFillProps(color, alpha, ShapeFillType.solid) for translucent fills; line takes ShapeLineProps.
ShapeType.custGeom builds the outline from points: MoveToPoint, QuadraticCurvePoint (with an embedded QuadraticCurve control point) and ClosePoint(true).
Text boxes can carry hyperlinks through HyperlinkProps(url, tooltip); per-run hyperlinks are set in each TextProps.options.