العمل مع التأثيرات الثلاثية الأبعاد والتأثرات المرئية Aspose.Slides FOSS for Java
Aspose.Slides FOSS for Java provides two separate effect systems accessible on every shape:
EffectFormat(shape.getEffectFormat()): تأثيرات بصرية ثنائية الأبعاد: الظل، الوهج، الحافة الناعمة، التشويه، الانعكاس.ThreeDFormat(shape.getThreeDFormat()): مظهر ثلاثي الأبعاد: المظلة، عرض الكاميرا، جهاز الإضاءة، المواد، عمق التخريب
كلاهما يستمر خلال دورات الحفاظ/إعادة التحميل.
الآثار المرئية (نموذج الأثر)
ظل القفز الخارجي
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.drawing.Color;
import org.aspose.slides.foss.export.SaveFormat;
try (Presentation prs = new Presentation()) {
var shape = prs.getSlides().get(0).getShapes().addAutoShape(ShapeType.RECTANGLE, 100, 100, 300, 120);
shape.addTextFrame("Shadowed Text");
var ef = shape.getEffectFormat();
ef.enableOuterShadowEffect();
ef.getOuterShadowEffect().setBlurRadius(10); // softness in points
ef.getOuterShadowEffect().setDirection(315); // angle: 315 = upper-left cast
ef.getOuterShadowEffect().setDistance(8); // offset in points
ef.getOuterShadowEffect().getShadowColor().setColor(Color.fromArgb(128, 0, 0, 0)); // semi-transparent black
prs.save("shadow.pptx", SaveFormat.PPTX);
}شائع direction القيم: 0 = صحيح،, 45 = أسفل اليمين،, 90 = أسفل،, 270 = فوق،, 315 = أعلى اليسار.
تأثير الوهج
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.drawing.Color;
import org.aspose.slides.foss.export.SaveFormat;
try (Presentation prs = new Presentation()) {
var shape = prs.getSlides().get(0).getShapes().addAutoShape(ShapeType.ELLIPSE, 150, 100, 200, 200);
var ef = shape.getEffectFormat();
ef.enableGlowEffect();
ef.getGlowEffect().setRadius(15);
ef.getGlowEffect().getColor().setColor(Color.fromArgb(255, 255, 215, 0)); // gold
prs.save("glow.pptx", SaveFormat.PPTX);
}الحافة الناعمة (الحدود المُتَوَرَّشة)
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.export.SaveFormat;
try (Presentation prs = new Presentation()) {
var shape = prs.getSlides().get(0).getShapes().addAutoShape(ShapeType.RECTANGLE, 100, 100, 350, 180);
var ef = shape.getEffectFormat();
ef.enableSoftEdgeEffect();
ef.getSoftEdgeEffect().setRadius(12); // feather radius in points
prs.save("soft-edge.pptx", SaveFormat.PPTX);
}التلوث
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.export.SaveFormat;
try (Presentation prs = new Presentation()) {
var shape = prs.getSlides().get(0).getShapes().addAutoShape(ShapeType.RECTANGLE, 100, 100, 350, 180);
shape.getEffectFormat().setBlurEffect(8, true);
prs.save("blur.pptx", SaveFormat.PPTX);
}التحقق من الآثار وإزالتها
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
try (Presentation prs = new Presentation()) {
var shape = prs.getSlides().get(0).getShapes().addAutoShape(ShapeType.RECTANGLE, 100, 100, 200, 100);
var ef = shape.getEffectFormat();
ef.enableOuterShadowEffect();
ef.enableGlowEffect();
System.out.println("Has effects: " + !ef.isNoEffects()); // true
ef.disableOuterShadowEffect();
ef.disableGlowEffect();
System.out.println("Has effects: " + !ef.isNoEffects()); // false
}3D Formatting (ThreeDFormat)
تأثير الدوامة
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.BevelPresetType;
import org.aspose.slides.foss.export.SaveFormat;
try (Presentation prs = new Presentation()) {
var shape = prs.getSlides().get(0).getShapes().addAutoShape(ShapeType.RECTANGLE, 150, 150, 250, 120);
shape.addTextFrame("3D Button");
var tdf = shape.getThreeDFormat();
tdf.getBevelTop().setBevelType(BevelPresetType.CIRCLE);
tdf.getBevelTop().setWidth(12);
tdf.getBevelTop().setHeight(6);
prs.save("bevel.pptx", SaveFormat.PPTX);
}قيم BevelPresetType (صورة التوضيح): CIRCLE, RELAXED_INSET, COOL_SLANT, DIVOT, RIBLET, HARD_EDGE, SLOPE, CONVEX
إعدادات الكاميرا المسبقة
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.BevelPresetType;
import org.aspose.slides.foss.CameraPresetType;
import org.aspose.slides.foss.export.SaveFormat;
try (Presentation prs = new Presentation()) {
var shape = prs.getSlides().get(0).getShapes().addAutoShape(ShapeType.RECTANGLE, 150, 150, 250, 120);
var tdf = shape.getThreeDFormat();
tdf.getBevelTop().setBevelType(BevelPresetType.CIRCLE);
tdf.getBevelTop().setWidth(10);
tdf.getCamera().setCameraType(CameraPresetType.PERSPECTIVE_ABOVE);
prs.save("camera.pptx", SaveFormat.PPTX);
}آلة الإضاءة والمواد
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.BevelPresetType;
import org.aspose.slides.foss.CameraPresetType;
import org.aspose.slides.foss.LightRigPresetType;
import org.aspose.slides.foss.LightingDirection;
import org.aspose.slides.foss.MaterialPresetType;
import org.aspose.slides.foss.export.SaveFormat;
try (Presentation prs = new Presentation()) {
var shape = prs.getSlides().get(0).getShapes().addAutoShape(ShapeType.RECTANGLE, 150, 150, 250, 120);
shape.addTextFrame("Metal Button");
var tdf = shape.getThreeDFormat();
tdf.getBevelTop().setBevelType(BevelPresetType.CIRCLE);
tdf.getBevelTop().setWidth(10);
tdf.getBevelTop().setHeight(5);
tdf.getCamera().setCameraType(CameraPresetType.PERSPECTIVE_ABOVE);
tdf.getLightRig().setLightType(LightRigPresetType.BALANCED);
tdf.getLightRig().setDirection(LightingDirection.TOP);
tdf.setMaterial(MaterialPresetType.METAL);
tdf.setDepth(20);
prs.save("3d-metal.pptx", SaveFormat.PPTX);
}قيم الموادPresetType: MATTE, WARM_MATTE, PLASTIC, METAL, FLAT, SOFT_EDGE, CLEAR
الجمع بين تأثيرات 2D و 3D
يمكنك تطبيق كليهما. getEffectFormat() و getThreeDFormat() بنفس الشكل:
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ShapeType;
import org.aspose.slides.foss.FillType;
import org.aspose.slides.foss.BevelPresetType;
import org.aspose.slides.foss.CameraPresetType;
import org.aspose.slides.foss.MaterialPresetType;
import org.aspose.slides.foss.drawing.Color;
import org.aspose.slides.foss.export.SaveFormat;
try (Presentation prs = new Presentation()) {
var shape = prs.getSlides().get(0).getShapes().addAutoShape(ShapeType.ROUND_CORNER_RECTANGLE, 150, 150, 300, 120);
shape.addTextFrame("Premium Card");
// Solid fill
shape.getFillFormat().setFillType(FillType.SOLID);
shape.getFillFormat().getSolidFillColor().setColor(Color.fromArgb(255, 30, 80, 180));
// 3D bevel
var tdf = shape.getThreeDFormat();
tdf.getBevelTop().setBevelType(BevelPresetType.CIRCLE);
tdf.getBevelTop().setWidth(8);
tdf.getCamera().setCameraType(CameraPresetType.PERSPECTIVE_ABOVE);
tdf.setMaterial(MaterialPresetType.PLASTIC);
// Drop shadow
var ef = shape.getEffectFormat();
ef.enableOuterShadowEffect();
ef.getOuterShadowEffect().setBlurRadius(12);
ef.getOuterShadowEffect().setDirection(270);
ef.getOuterShadowEffect().setDistance(6);
ef.getOuterShadowEffect().getShadowColor().setColor(Color.fromArgb(80, 0, 0, 0));
prs.save("premium-card.pptx", SaveFormat.PPTX);
}