添加数学形状
ShapeCollection.AddMathShape 方法
创建一个从默认模板调整到数学内容的新自动形状,并将其添加到集合的末尾。
public IAutoShape AddMathShape(float x, float y, float width, float height)
参数 | 类型 | 描述 |
---|---|---|
x | Single | 形状框架左侧的 X 坐标。 |
y | Single | 形状框架顶部的 Y 坐标。 |
width | Single | 形状框架的宽度。 |
height | Single | 形状框架的高度。 |
返回值
创建的 AutoShape 对象。
示例
以下示例演示如何在 PowerPoint 演示文稿中添加数学方程。
[C#]
using (Presentation pres = new Presentation())
{
IAutoShape mathShape = pres.Slides[0].Shapes.AddMathShape(0, 0, 720, 150);
var mathParagraph = (mathShape.TextFrame.Paragraphs[0].Portions[0] as MathPortion).MathParagraph;
var fraction = new MathematicalText("x").Divide("y");
mathParagraph.Add(new MathBlock(fraction));
var mathBlock = new MathematicalText("c")
.SetSuperscript("2")
.Join("=")
.Join(new MathematicalText("a").SetSuperscript("2"))
.Join("+")
.Join(new MathematicalText("b").SetSuperscript("2"));
mathParagraph.Add(mathBlock);
pres.Save("math.pptx", SaveFormat.Pptx);
}
另请参见
- 接口 IAutoShape
- 类 ShapeCollection
- 命名空间 Aspose.Slides
- 程序集 Aspose.Slides