Helper Example: Persona

Created: 2026-05-29 · Updated: 2026-05-29

Helper Reference · Advanced Snippet Editor

Parameterized persona figure (torso from Freeform Bezier curves + head oval + name label). Demonstrates Freeform with msoEditingAuto, Nodes.SetPosition, Group, and Scale.


ppptools Methods Used

Method Purpose
ppptools.BuildFreeform(editingType, x, y) Torso as Bezier freeform
ppptools.AddOval(x, y, w, h) Head
ppptools.AddRect(x, y, w, h) Name label (transparent)
ppptools.Group(shape1, ...) Group all three shapes
ppptools.SlideWidth / SlideHeight Center on slide

Parameters

@param Type Default Description
Groesse enum "Mittel" Small (25%), Medium (50%), Large (100%)
Koerperfarbe color #4472C4 Body and head color
Schriftfarbe color #262626 Name text color
PersonaName string "Persona" Text below the figure
Zentrieren bool true Center on slide

Result

Persona

Full Code

// @help https://ppptools.happy-pc.ch/help/en/helper-example-persona
// @param enum   Groesse      "Size"                 options="Klein|Mittel|Gross"  default="Mittel"
// @param color  Koerperfarbe "Body color"           default=#4472C4
// @param color  Schriftfarbe "Font color"           default=#262626
// @param string PersonaName  "Name"                 default="Persona"
// @param bool   Zentrieren   "Center on slide"      default=true

string groesse     = Params.GetString("Groesse",      "Mittel");
var    bodyColor   = Params.GetColor("Koerperfarbe",  Color.FromArgb(68, 114, 196));
var    fontColor   = Params.GetColor("Schriftfarbe",  Color.FromArgb(38,  38,  38));
string personaName = Params.GetString("PersonaName",  "Persona");
bool   zentrieren  = Params.GetBool("Zentrieren",    true);

int bodyRgb = System.Drawing.ColorTranslator.ToOle(bodyColor);
int fontRgb = System.Drawing.ColorTranslator.ToOle(fontColor);

// ── Torso (Freeform) ──────────────────────────────────────────────────
var ff = ppptools.BuildFreeform(MsoEditingType.msoEditingAuto, 272.9073f, 363.8064f);
ff.AddNodes(MsoSegmentType.msoSegmentCurve, MsoEditingType.msoEditingCorner,
    320.5420f, 363.8064f, 359.7210f, 399.0247f, 364.4324f, 444.1556f);
ff.AddNodes(MsoSegmentType.msoSegmentLine,  MsoEditingType.msoEditingCorner,
    364.9130f, 452.5568f);
ff.AddNodes(MsoSegmentType.msoSegmentCurve, MsoEditingType.msoEditingAuto,
    364.9130f, 473.3365f, 323.7406f, 490.1818f, 272.9519f, 490.1818f);
ff.AddNodes(MsoSegmentType.msoSegmentCurve, MsoEditingType.msoEditingCorner,
    222.1631f, 490.1818f, 180.9908f, 473.3365f, 180.9908f, 452.5568f);
ff.AddNodes(MsoSegmentType.msoSegmentLine,  MsoEditingType.msoEditingCorner,
    181.3824f, 444.1556f);
ff.AddNodes(MsoSegmentType.msoSegmentCurve, MsoEditingType.msoEditingAuto,
    186.0936f, 399.0247f, 225.2728f, 363.8064f, 272.9073f, 363.8064f);

var oBody = ff.ConvertToShape();

// Node correction (ensures exact Bezier positions)
oBody.Nodes.SetPosition(1,  272.9073f, 363.8064f);
oBody.Nodes.SetPosition(2,  320.5420f, 363.8064f);
oBody.Nodes.SetPosition(3,  359.7210f, 399.0247f);
oBody.Nodes.SetPosition(4,  364.4324f, 444.1556f);
oBody.Nodes.SetPosition(5,  364.9130f, 452.5568f);
oBody.Nodes.SetPosition(6,  364.9130f, 473.3365f);
oBody.Nodes.SetPosition(7,  323.7406f, 490.1818f);
oBody.Nodes.SetPosition(8,  272.9519f, 490.1818f);
oBody.Nodes.SetPosition(9,  222.1631f, 490.1818f);
oBody.Nodes.SetPosition(10, 180.9908f, 473.3365f);
oBody.Nodes.SetPosition(11, 180.9908f, 452.5568f);
oBody.Nodes.SetPosition(12, 181.3824f, 444.1556f);
oBody.Nodes.SetPosition(13, 186.0936f, 399.0247f);
oBody.Nodes.SetPosition(14, 225.2728f, 363.8064f);
oBody.Nodes.SetPosition(15, 272.9073f, 363.8064f);

oBody.Name = "Persona_Body";
oBody.Fill.ForeColor.RGB = bodyRgb;
oBody.Fill.Transparency  = 0f;
oBody.Line.Visible = MsoTriState.msoFalse;

// ── Head (oval) ───────────────────────────────────────────────────────
var oHead = ppptools.AddOval(224.9519f, 260.5564f, 96f, 96f);
oHead.Name = "Persona_Head";
oHead.Fill.ForeColor.RGB = bodyRgb;
oHead.Fill.Transparency  = 0f;
oHead.Line.Visible = MsoTriState.msoFalse;

// ── Name label (transparent text box) ────────────────────────────────
var oText = ppptools.AddRect(180.9908f, 497.4318f, 183.9222f, 30f);
oText.Name = "Persona_Text";
oText.Fill.ForeColor.RGB = 16777215;
oText.Fill.Transparency  = 1f;
oText.Line.Visible = MsoTriState.msoFalse;

oText.TextFrame.TextRange.Text = personaName;
oText.TextFrame.TextRange.Font.Name  = "Arial";
oText.TextFrame.TextRange.Font.Size  = 12;
oText.TextFrame.TextRange.Font.Bold  = MsoTriState.msoFalse;
oText.TextFrame.TextRange.Font.Color.RGB = fontRgb;
oText.TextFrame2.TextRange.Font.Fill.Solid();
oText.TextFrame.TextRange.ParagraphFormat.Alignment         = PpParagraphAlignment.ppAlignCenter;
oText.TextFrame.TextRange.ParagraphFormat.BaseLineAlignment = PpBaselineAlignment.ppBaselineAlignCenter;
oText.TextFrame2.VerticalAnchor   = MsoVerticalAnchor.msoAnchorMiddle;
oText.TextFrame.VerticalAnchor    = MsoVerticalAnchor.msoAnchorMiddle;
oText.TextFrame2.Orientation      = MsoTextOrientation.msoTextOrientationHorizontal;
oText.TextFrame2.MarginTop    = 3.6f;
oText.TextFrame2.MarginRight  = 7.2f;
oText.TextFrame2.MarginBottom = 3.6f;
oText.TextFrame2.MarginLeft   = 7.2f;
oText.TextFrame.WordWrap      = MsoTriState.msoTrue;
oText.TextFrame2.Column.Number    = 1;
oText.TextFrame2.Column.Spacing   = 0;
oText.TextFrame2.AutoSize = MsoAutoSize.msoAutoSizeTextToFitShape;

// ── Group ─────────────────────────────────────────────────────────────
dynamic oGroup = ppptools.Group(oBody, oHead, oText);
oGroup.Name = "Persona";

// ── Scale ─────────────────────────────────────────────────────────────
float scale = groesse == "Klein" ? 0.25f : groesse == "Gross" ? 1.0f : 0.5f;
oGroup.Width  = (float)oGroup.Width  * scale;
oGroup.Height = (float)oGroup.Height * scale;

// ── Center ────────────────────────────────────────────────────────────
if (zentrieren)
{
    oGroup.Left = (ppptools.SlideWidth  - (float)oGroup.Width)  / 2f;
    oGroup.Top  = (ppptools.SlideHeight - (float)oGroup.Height) / 2f;
}

Step by Step

1. Torso as Bezier freeform with ppptools.BuildFreeform

msoEditingAuto allows mixed curve and line segments in the same freeform. For curve nodes (msoSegmentCurve), three points are passed: Bezier control point 1, Bezier control point 2, endpoint.

2. Node correction with Nodes.SetPosition

oBody.Nodes.SetPosition(1,  272.9073f, 363.8064f);

After ConvertToShape(), PowerPoint may slightly reposition nodes internally. SetPosition ensures the exact Bezier coordinates — important for pixel-accurate reproduction.

3. Head and label with ppptools.AddOval / ppptools.AddRect

The head is a circle (w=h=96) positioned directly above the torso. The text label is a rectangle with Transparency = 1f (100% transparent) — only the text is visible.

4. Group all three shapes with ppptools.Group

dynamic oGroup = ppptools.Group(oBody, oHead, oText);

ppptools.Group(params dynamic[] shapes) selects all given shapes and groups them in a single call. Returns the finished group.

5. Scale and center

The base size is designed for "Large = 100%" (torso approx. 185×230pt). ppptools.SlideWidth/Height replaces aPowerPoint.ActivePresentation.PageSetup.*.

Alternatively: ppptools.CenterOnSlide(oGroup) centers in a single line.


Why Freeform instead of AutoShape?

A human torso cannot be represented by any MsoAutoShapeType. Freeform with Bezier segments (Code Generator output) produces a precise, scalable vector shape in PowerPoint.


Back: Helper Reference · All Examples