Эллипс
Contents
[
Hide
]
Создание Эллипса
В этой теме мы познакомим разработчиков с добавлением эллипсных форм на их слайды с помощью Aspose.Slides для C++. Aspose.Slides для C++ предоставляет более простой набор API для рисования различных видов форм всего за несколько строк кода. Чтобы добавить простой эллипс на выбранный слайд презентации, выполните следующие шаги:
- Создайте экземпляр класса Presentation
- Получите ссылку на слайд, используя его индекс.
- Добавьте автоформу типа Эллипс с помощью метода AddAutoShape, предоставляемого объектом IShapes.
- Запишите измененную презентацию в виде файла PPTX.
В приведенном ниже примере мы добавили эллипс на первый слайд.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
Создание Форматированного Эллипса
Чтобы добавить лучше отформатированный эллипс на слайд, выполните следующие шаги:
- Создайте экземпляр класса Presentation.
- Получите ссылку на слайд, используя его индекс.
- Добавьте автоформу типа Эллипс с помощью метода AddAutoShape, предоставляемого объектом IShapes.
- Установите тип заливки эллипса на Сплошной.
- Установите цвет эллипса с использованием свойства SolidFillColor.Color, предоставляемого объектом FillFormat, связанным с объектом IShape.
- Установите цвет линий эллипса.
- Установите ширину линий эллипса.
- Запишите измененную презентацию в виде файла PPTX.
В приведенном ниже примере мы добавили форматированный эллипс на первый слайд презентации.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |