Rectangle

Create Simple Rectangle

Like previous topics, this one is also about adding a shape and this time the shape we will discuss about is Rectangle. In this topic, we have described that how developers can add simple or formatted rectangles to their slides using Aspose.Slides for C++ . To add a simple rectangle to a selected slide of the presentation, please follow the steps below:

  1. Create an instance of Presentation class.
  2. Obtain the reference of a slide by using its Index.
  3. Add an IAutoShape of Rectangle type using AddAutoShape method exposed by IShapes object.
  4. Write the modified presentation as a PPTX file.

In the example given below, we have added a simple rectangle to the first slide of the presentation.

Create Formatted Rectangle

To add a formatted rectangle to a slide, please follow the steps below:

  1. Create an instance of Presentation class.
  2. Obtain the reference of a slide by using its Index.
  3. Add an IAutoShape of Rectangle type using AddAutoShape method exposed by IShapes object.
  4. Set the Fill Type of the Rectangle to Solid.
  5. Set the Color of the Rectangle using SolidFillColor.Color property as exposed by FillFormat object associated with the IShape object.
  6. Set the Color of the lines of the Rectangle.
  7. Set the Width of the lines of the Rectangle.
  8. Write the modified presentation as PPTX file. The above steps are implemented in the example given below.