आकारों पर 3D प्रभाव और छायाएँ कैसे लागू करें
Aspose.Slides FOSS प्रत्येक आकार पर दो स्वतंत्र प्रभाव प्रणालियाँ प्रदान करता है:
shape.effect_format(): 2D दृश्य प्रभाव: बाहरी छाया, चमक, धुंधलापन, मुलायम किनाराshape.three_d_format(): 3D उपस्थिति: बिवेल, कैमरा परिप्रेक्ष्य, लाइट रिग, सामग्री, गहराई
दोनों सिस्टम को एक ही आकार पर संयोजित किया जा सकता है।
पूर्वापेक्षाएँ
git clone https://github.com/aspose-slides-foss/Aspose.Slides-FOSS-for-Cpp.git
cd Aspose.Slides-FOSS-for-Cpp && mkdir build && cd build
cmake .. && cmake --build .एक बाहरी ड्रॉप शैडो जोड़ें
#include <Aspose/Slides/Foss/presentation.h>
int main() {
namespace asf = Aspose::Slides::Foss;
asf::Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
asf::ShapeType::RECTANGLE, 100, 100, 300, 120);
shape.text_frame()->set_text("Shadowed Shape");
auto& ef = shape.effect_format();
ef.enable_outer_shadow_effect();
auto* shadow = ef.outer_shadow_effect();
shadow->set_blur_radius(10); // softness in points
shadow->set_direction(315); // 315 deg = upper-left
shadow->set_distance(8); // offset in points
shadow->shadow_color().set_color(
asf::Color::from_argb(128, 0, 0, 0));
prs.save("shadow.pptx", asf::SaveFormat::PPTX);
return 0;
}सामान्य direction मान: 0=दायाँ, 45=निचला-दायाँ, 90=नीचे, 180=बायाँ, 270=ऊपर, 315=ऊपरी-बायाँ.
ग्लो इफ़ेक्ट जोड़ें
#include <Aspose/Slides/Foss/presentation.h>
int main() {
namespace asf = Aspose::Slides::Foss;
asf::Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
asf::ShapeType::ELLIPSE, 150, 100, 250, 250);
auto& ef = shape.effect_format();
ef.enable_glow_effect();
auto* glow = ef.glow_effect();
glow->set_radius(20);
glow->color().set_color(asf::Color::gold);
prs.save("glow.pptx", asf::SaveFormat::PPTX);
return 0;
}एक Gaussian Blur लागू करें
#include <Aspose/Slides/Foss/presentation.h>
int main() {
namespace asf = Aspose::Slides::Foss;
asf::Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
asf::ShapeType::RECTANGLE, 100, 100, 350, 180);
shape.effect_format().set_blur_effect(10, true);
prs.save("blur.pptx", asf::SaveFormat::PPTX);
return 0;
}grow=true ब्लर क्षेत्र को आकार की सीमा से परे विस्तारित करता है; grow=false ब्लर को आकार के भीतर क्लिप करता है।
एक 3D बिवेल लागू करें
#include <Aspose/Slides/Foss/presentation.h>
int main() {
namespace asf = Aspose::Slides::Foss;
asf::Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
asf::ShapeType::RECTANGLE, 150, 150, 280, 120);
shape.text_frame()->set_text("3D Button");
auto& tdf = shape.three_d_format();
tdf.bevel_top().set_bevel_type(asf::BevelPresetType::CIRCLE);
tdf.bevel_top().set_width(12);
tdf.bevel_top().set_height(6);
prs.save("bevel.pptx", asf::SaveFormat::PPTX);
return 0;
}BevelPresetType मान: CIRCLE, RELAXED_INSET, COOL_SLANT, DIVOT, RIBLET, HARD_EDGE, SLOPE, CONVEX
कैमरा और लाइट रिग के साथ 3D बिवेल
#include <Aspose/Slides/Foss/presentation.h>
int main() {
namespace asf = Aspose::Slides::Foss;
asf::Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
asf::ShapeType::RECTANGLE, 150, 150, 280, 120);
shape.text_frame()->set_text("Metal Button");
auto& tdf = shape.three_d_format();
tdf.bevel_top().set_bevel_type(asf::BevelPresetType::CIRCLE);
tdf.bevel_top().set_width(10);
tdf.bevel_top().set_height(5);
tdf.camera().set_camera_type(asf::CameraPresetType::PERSPECTIVE_ABOVE);
tdf.light_rig().set_light_type(asf::LightRigPresetType::BALANCED);
tdf.light_rig().set_direction(asf::LightingDirection::TOP);
tdf.set_material(asf::MaterialPresetType::METAL);
tdf.set_depth(20);
prs.save("3d-metal.pptx", asf::SaveFormat::PPTX);
return 0;
}छाया और 3D बिवेल को मिलाएँ
दोनों प्रभाव प्रणालियाँ एक ही आकार पर एक साथ सक्रिय हो सकती हैं:
#include <Aspose/Slides/Foss/presentation.h>
int main() {
namespace asf = Aspose::Slides::Foss;
asf::Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
asf::ShapeType::ROUND_CORNER_RECTANGLE, 150, 150, 320, 130);
shape.text_frame()->set_text("Premium Card");
// Solid fill
shape.fill_format().set_fill_type(asf::FillType::SOLID);
shape.fill_format().solid_fill_color().set_color(
asf::Color::from_argb(255, 30, 80, 180));
// 3D bevel
auto& tdf = shape.three_d_format();
tdf.bevel_top().set_bevel_type(asf::BevelPresetType::CIRCLE);
tdf.bevel_top().set_width(8);
tdf.camera().set_camera_type(asf::CameraPresetType::PERSPECTIVE_ABOVE);
tdf.set_material(asf::MaterialPresetType::PLASTIC);
// Drop shadow
auto& ef = shape.effect_format();
ef.enable_outer_shadow_effect();
auto* shadow2 = ef.outer_shadow_effect();
shadow2->set_blur_radius(12);
shadow2->set_direction(270);
shadow2->set_distance(6);
shadow2->shadow_color().set_color(
asf::Color::from_argb(80, 0, 0, 0));
prs.save("premium-card.pptx", asf::SaveFormat::PPTX);
return 0;
}जाँचें और प्रभाव हटाएँ
#include <Aspose/Slides/Foss/presentation.h>
#include <iostream>
int main() {
namespace asf = Aspose::Slides::Foss;
asf::Presentation prs;
auto& shape = prs.slides()[0].shapes().add_auto_shape(
asf::ShapeType::RECTANGLE, 100, 100, 200, 100);
auto& ef = shape.effect_format();
ef.enable_outer_shadow_effect();
ef.enable_glow_effect();
std::cout << "Has effects: " << !ef.is_no_effects() << "\n"; // 1
ef.disable_outer_shadow_effect();
ef.disable_glow_effect();
std::cout << "Has effects: " << !ef.is_no_effects() << "\n"; // 0
return 0;
}