Ellipse

Ellipse erstellen

In diesem Thema werden wir Entwicklern vorstellen, wie man Ellipsenformen zu ihren Folien mit Aspose.Slides für C++ hinzufügt. Aspose.Slides für C++ bietet eine einfachere API-Schnittstelle, um verschiedene Arten von Formen mit nur wenigen Codezeilen zu zeichnen. Um eine einfache Ellipse zu einer ausgewählten Folie der Präsentation hinzuzufügen, befolgen Sie bitte die folgenden Schritte:

  1. Erstellen Sie eine Instanz der Presentation-Klasse
  2. Erhalten Sie die Referenz einer Folie, indem Sie deren Index verwenden.
  3. Fügen Sie eine AutoShape vom Typ Ellipse mit der Methode AddAutoShape hinzu, die vom Objekt IShapes bereitgestellt wird.
  4. Schreiben Sie die modifizierte Präsentation als PPTX-Datei.

Im folgenden Beispiel haben wir eine Ellipse zur ersten Folie hinzugefügt.

For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String outPath = u"../out/SimpleEllipse.pptx";
const String templatePath = u"../templates/HelloWorld.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add autoshape of ellipse type
SharedPtr<IAutoShape> ashp = slide->get_Shapes()->AddAutoShape(ShapeType::Ellipse, 50, 150, 150, 50);
// Save PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

Formattierte Ellipse erstellen

Um eine besser formatierte Ellipse zu einer Folie hinzuzufügen, befolgen Sie bitte die folgenden Schritte:

  1. Erstellen Sie eine Instanz der Presentation-Klasse.
  2. Erhalten Sie die Referenz einer Folie, indem Sie deren Index verwenden.
  3. Fügen Sie eine AutoShape vom Typ Ellipse mit der Methode AddAutoShape hinzu, die vom Objekt IShapes bereitgestellt wird.
  4. Setzen Sie den Fülltyp der Ellipse auf Solid.
  5. Setzen Sie die Farbe der Ellipse mit der Eigenschaft SolidFillColor.Color, die vom FillFormat-Objekt bereitgestellt wird, das mit dem IShape-Objekt assoziiert ist.
  6. Setzen Sie die Farbe der Linien der Ellipse.
  7. Setzen Sie die Breite der Linien der Ellipse.
  8. Schreiben Sie die modifizierte Präsentation als PPTX-Datei.

Im folgenden Beispiel haben wir eine formatierte Ellipse zur ersten Folie der Präsentation hinzugefügt.

For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String outPath = u"../out/FormattedEllipse_out.pptx";
const String templatePath = u"../templates/AltText.pptx";
// Load the desired the presentation
SharedPtr<Presentation> pres = MakeObject<Presentation>();
// Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add an autoshape of type line
SharedPtr<IAutoShape> shape = slide->get_Shapes()->AddAutoShape(ShapeType::Ellipse, 50, 150, 150, 50);
// Set the fill color of the rectangle shape
shape->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Chocolate());
// Apply some formatting on the line
shape->get_LineFormat()->set_Style(LineStyle::ThickThin);
shape->get_LineFormat()->set_Width(5);
shape->get_LineFormat()->set_DashStyle(LineDashStyle::DashDot);
shape->get_LineFormat()->get_FillFormat()->set_FillType(FillType::Solid);
shape->get_LineFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(Color::get_Black());
//Write the PPTX to Disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);