// ExStart:UsingShapeUtils // For complete examples and data files, please go to https://github.com/aspose-page/Aspose.Page-for-C // The path to the documents directory. System::String dataDir = RunExamples::GetDataDir_WorkingWithShapes(); // Create new XPS Document { System::SharedPtr<XpsDocument> doc = System::MakeObject<XpsDocument>(); // Clearing resources under 'using' statement System::Details::DisposeGuard<1> __dispose_guard_0({ doc}); // ------------------------------------------ try { // Set first page's size. doc->get_Page()->set_Width(650.f); doc->get_Page()->set_Height(240.f); // Draw a circle with center (120, 120) and radius 100. System::SharedPtr<XpsPath> path = doc->CreatePath(doc->get_Utils()->CreateCircle(System::Drawing::PointF(120.f, 120.f), 100.f)); path->set_Fill(doc->CreateSolidColorBrush(System::Drawing::Color::get_Green())); doc->Add<System::SharedPtr<XpsPath>>(path); // Inscribe a regular pentagon in the circle. path = doc->CreatePath(doc->get_Utils()->CreateRegularInscribedNGon(5, System::Drawing::PointF(120.f, 120.f), 100.f)); path->set_Fill(doc->CreateSolidColorBrush(System::Drawing::Color::get_Red())); doc->Add<System::SharedPtr<XpsPath>>(path); // Circumscribe a regular hexagon around the circle. path = doc->CreatePath(doc->get_Utils()->CreateRegularCircumscribedNGon(6, System::Drawing::PointF(120.f, 120.f), 100.f)); path->set_Stroke(doc->CreateSolidColorBrush(System::Drawing::Color::get_Magenta())); path->set_StrokeThickness(3.f); doc->Add<System::SharedPtr<XpsPath>>(path); // Draw a sector of the circle centered at (340, 120), starting at -45 degrees and ending at +45 degrees. path = doc->CreatePath(doc->get_Utils()->CreatePieSlice(System::Drawing::PointF(340.f, 120.f), 100.f, -45.f, 45.f)); path->set_Stroke(doc->CreateSolidColorBrush(System::Drawing::Color::get_Red())); path->set_StrokeThickness(5.f); doc->Add<System::SharedPtr<XpsPath>>(path); // Draw a segment of the circle centered at (340, 120), starting at -45 degrees and ending at +45 degrees. path = doc->CreatePath(doc->get_Utils()->CreateCircularSegment(System::Drawing::PointF(340.f, 120.f), 100.f, -45.f, 45.f)); path->set_Fill(doc->CreateSolidColorBrush(System::Drawing::Color::get_Black())); doc->Add<System::SharedPtr<XpsPath>>(path); // Draw a rectangle with the top left vertex (530, 20), width 100 units and height 200 units. path = doc->CreatePath(doc->get_Utils()->CreateRectangle(System::Drawing::RectangleF(530.f, 20.f, 100.f, 200.f))); path->set_Stroke(doc->CreateSolidColorBrush(System::Drawing::Color::get_Red())); doc->Add<System::SharedPtr<XpsPath>>(path); // Draw an ellipse with center (580, 120) and radii 50 and 100. path = doc->CreatePath(doc->get_Utils()->CreateEllipse(System::Drawing::PointF(580.f, 120.f), 50.f, 100.f)); path->set_Fill(doc->CreateSolidColorBrush(System::Drawing::Color::get_Yellow())); doc->Add<System::SharedPtr<XpsPath>>(path); doc->Save(dataDir + u"UseShapeUtilsXPS_out.xps"); } catch(...) { __dispose_guard_0.SetCurrentException(std::current_exception()); } } // ExEnd:UsingShapeUtils