Aspose.Slides FOSS for C++ lets you apply professional-quality visual effects to PowerPoint shapes in native C++, with no Microsoft Office and no API keys. This post demonstrates the fill system, 2D effects, and 3D formatting available in the library.
Το Σύστημα Γέμισης
Κάθε σχήμα έχει ένα fill_format() που ελέγχει πώς βαφτεί το εσωτερικό του. Οι πέντε τύποι γεμίσματος καλύπτουν όλο το φάσμα της παλέτας σχεδίασης του PowerPoint.
Συμπαγές Γέμισμα
Το πιο απλό γέμισμα, ένα επίπεδο χρώμα με προαιρετική διαφάνεια:
#include <Aspose/Slides/Foss/presentation.h>
using namespace Aspose::Slides::Foss;
Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
ShapeType::RoundCornerRectangle, 100, 100, 400, 150
);
shape.text_frame()->set_text("Solid Fill");
shape.fill_format().set_fill_type(FillType::SOLID);
shape.fill_format().solid_fill_color().set_color(Color::from_argb(255, 30, 80, 180));
prs.save("solid.pptx", SaveFormat::PPTX);
Γραμμικό Διαβαθμισμένο Γέμισμα
Τα σημεία διαβάθμισης σας επιτρέπουν να μεταβάλλετε από ένα χρώμα σε άλλο κατά μήκος του σχήματος:
#include <Aspose/Slides/Foss/presentation.h>
using namespace Aspose::Slides::Foss;
Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
ShapeType::RECTANGLE, 100, 100, 400, 150
);
auto& ff = shape.fill_format();
ff.set_fill_type(FillType::GRADIENT);
auto& gf = ff.gradient_format();
gf.set_gradient_shape(GradientShape::Linear);
gf.set_linear_gradient_angle(90); // top-to-bottom
gf.gradient_stops().add(0.0f, Color::from_argb(255, 30, 80, 180)); // top: blue
gf.gradient_stops().add(1.0f, Color::from_argb(255, 0, 200, 160)); // bottom: teal
prs.save("gradient.pptx", SaveFormat::PPTX);
2D Visual Effects
Εξωτερική Πτώση Σκιάς
Επισυνάψτε μια ημιδιαφανή πτώση σκιάς σε οποιοδήποτε σχήμα:
#include <Aspose/Slides/Foss/presentation.h>
using namespace Aspose::Slides::Foss;
Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
ShapeType::RoundCornerRectangle, 100, 100, 350, 150
);
shape.text_frame()->set_text("Drop Shadow");
shape.fill_format().set_fill_type(FillType::SOLID);
shape.fill_format().solid_fill_color().set_color(Color::white());
auto& ef = shape.effect_format();
ef.enable_outer_shadow_effect();
ef.outer_shadow_effect().set_blur_radius(12);
ef.outer_shadow_effect().set_direction(315); // upper-left
ef.outer_shadow_effect().set_distance(8);
ef.outer_shadow_effect().shadow_color().set_color(Color::from_argb(100, 0, 0, 0));
prs.save("shadow.pptx", SaveFormat::PPTX);
Εφέ Λάμψης
Μία χρωματιστή αύρα γύρω από την άκρη του σχήματος:
#include <Aspose/Slides/Foss/presentation.h>
using namespace Aspose::Slides::Foss;
Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
ShapeType::Ellipse, 150, 100, 250, 250
);
shape.fill_format().set_fill_type(FillType::SOLID);
shape.fill_format().solid_fill_color().set_color(Color::from_argb(255, 20, 60, 140));
auto& ef = shape.effect_format();
ef.enable_glow_effect();
ef.glow_effect().set_radius(20);
ef.glow_effect().color().set_color(Color::from_argb(200, 0, 180, 255));
prs.save("glow.pptx", SaveFormat::PPTX);
3D Formatting
Πλάγιο και Υλικό
Το three_d_format() η μέθοδος δίνει σε οποιοδήποτε επίπεδο σχήμα μια τρισδιάστατη εμφάνιση. Συνδυάστε ένα bevel με μια προεπιλογή κάμερας και ένα υλικό για το πιο πλούσιο αποτέλεσμα:
#include <Aspose/Slides/Foss/presentation.h>
using namespace Aspose::Slides::Foss;
Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
ShapeType::RECTANGLE, 150, 150, 300, 130
);
shape.text_frame()->set_text("Metal Button");
// Blue solid fill
shape.fill_format().set_fill_type(FillType::SOLID);
shape.fill_format().solid_fill_color().set_color(Color::from_argb(255, 20, 70, 160));
// 3D bevel + camera + light + material
auto& tdf = shape.three_d_format();
tdf.bevel_top().set_bevel_type(BevelPresetType::Circle);
tdf.bevel_top().set_width(10);
tdf.bevel_top().set_height(5);
tdf.camera().set_camera_type(CameraPresetType::PerspectiveAbove);
tdf.light_rig().set_light_type(LightRigPresetType::Balanced);
tdf.light_rig().set_direction(LightingDirection::Top);
tdf.set_material(MaterialPresetType::Metal);
tdf.set_depth(20);
prs.save("metal-button.pptx", SaveFormat::PPTX);
Συνδυασμός Εφέ στο Ίδιο Σχήμα
Η σκιά και η διαμόρφωση 3Δ μπορούν να συνυπάρχουν σε ένα μόνο σχήμα, επιτρέποντας εκλεπτυσμένα σχέδια “card”:
#include <Aspose/Slides/Foss/presentation.h>
using namespace Aspose::Slides::Foss;
Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
ShapeType::RoundCornerRectangle, 120, 120, 360, 150
);
shape.text_frame()->set_text("Premium Card");
// Fill
shape.fill_format().set_fill_type(FillType::SOLID);
shape.fill_format().solid_fill_color().set_color(Color::from_argb(255, 30, 80, 180));
// 3D bevel
auto& tdf = shape.three_d_format();
tdf.bevel_top().set_bevel_type(BevelPresetType::Circle);
tdf.bevel_top().set_width(8);
tdf.camera().set_camera_type(CameraPresetType::PerspectiveAbove);
tdf.set_material(MaterialPresetType::Plastic);
// Drop shadow
auto& ef = shape.effect_format();
ef.enable_outer_shadow_effect();
ef.outer_shadow_effect().set_blur_radius(14);
ef.outer_shadow_effect().set_direction(270);
ef.outer_shadow_effect().set_distance(8);
ef.outer_shadow_effect().shadow_color().set_color(Color::from_argb(70, 0, 0, 0));
prs.save("premium-card.pptx", SaveFormat::PPTX);
Εγκατάσταση
include(FetchContent)
FetchContent_Declare(
aspose_slides_foss
GIT_REPOSITORY https://github.com/aspose-slides-foss/Aspose.Slides-FOSS-for-Cpp.git
GIT_TAG main
)
FetchContent_MakeAvailable(aspose_slides_foss)
target_link_libraries(your_target PRIVATE aspose_slides_foss)
Καμία εγκατάσταση Office, χωρίς κλειδιά άδειας, χωρίς κλήσεις δικτύου· όλη η επεξεργασία γίνεται τοπικά.