Learn how to create 3D effects in PowerPoint PPT using Java:
Created
February 4, 2022 09:24
-
-
Save aspose-com-gists/8d49c40553778f51e27f77372b58e410 to your computer and use it in GitHub Desktop.
Apply 3D Effects in PowerPoint PPT in Java
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
// Create presentation | |
Presentation pres = new Presentation(); | |
try { | |
// Add rectangle shape | |
IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200); | |
// Set image for shape | |
shape.getFillFormat().setFillType(FillType.Picture); | |
IPPImage picture = null; | |
try { | |
picture = pres.getImages().addImage(Files.readAllBytes(Paths.get("tiger.bmp"))); | |
} catch (IOException e) { } | |
shape.getFillFormat().getPictureFillFormat().getPicture().setImage(picture); | |
shape.getFillFormat().getPictureFillFormat().setPictureFillMode(PictureFillMode.Stretch); | |
// Apply 3D effects | |
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront); | |
shape.getThreeDFormat().getCamera().setRotation(10, 20, 30); | |
shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat); | |
shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top); | |
shape.getThreeDFormat().setExtrusionHeight(150); | |
shape.getThreeDFormat().getExtrusionColor().setColor(Color.GRAY); | |
// Save presentation | |
pres.save("3D-Image.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
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
// Create presentation | |
Presentation pres = new Presentation(); | |
try { | |
// Add rectangle shape | |
IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200); | |
// Set text for shape | |
shape.getTextFrame().setText("3D"); | |
shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(64); | |
shape.getFillFormat().setFillType(FillType.Gradient); | |
shape.getFillFormat().getGradientFormat().getGradientStops().add(0, Color.BLUE); | |
shape.getFillFormat().getGradientFormat().getGradientStops().add(100, Color.MAGENTA); | |
// Apply 3D effects | |
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront); | |
shape.getThreeDFormat().getCamera().setRotation(10, 20, 30); | |
shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat); | |
shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top); | |
shape.getThreeDFormat().setExtrusionHeight(150); | |
shape.getThreeDFormat().getExtrusionColor().setColor(new Color(255, 140, 0)); | |
// Save presentation | |
pres.save("3D-Shape-Gradient.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
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
// Create presentation | |
Presentation pres = new Presentation(); | |
try { | |
// Add rectangle shape | |
IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200); | |
// Set text for shape | |
shape.getTextFrame().setText("3D"); | |
shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(64); | |
// Apply 3D effects | |
shape.getThreeDFormat().getCamera().setCameraType(CameraPresetType.OrthographicFront); | |
shape.getThreeDFormat().getCamera().setRotation(20, 30, 40); | |
shape.getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Flat); | |
shape.getThreeDFormat().getLightRig().setDirection(LightingDirection.Top); | |
shape.getThreeDFormat().setMaterial(MaterialPresetType.Flat); | |
shape.getThreeDFormat().setExtrusionHeight(100); | |
shape.getThreeDFormat().getExtrusionColor().setColor(Color.BLUE); | |
// Save presentation | |
pres.save("3D-Shape.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
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
// Create presentation | |
Presentation pres = new Presentation(); | |
try { | |
// Add rectangle shape | |
IAutoShape shape = pres.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.Rectangle, 200, 150, 200, 200); | |
// Set text | |
shape.getFillFormat().setFillType(FillType.NoFill); | |
shape.getLineFormat().getFillFormat().setFillType(FillType.NoFill); | |
shape.getTextFrame().setText("3D Text"); | |
// Add text portion and set its properties | |
Portion portion = (Portion)shape.getTextFrame().getParagraphs().get_Item(0).getPortions().get_Item(0); | |
portion.getPortionFormat().getFillFormat().setFillType(FillType.Pattern); | |
portion.getPortionFormat().getFillFormat().getPatternFormat().getForeColor().setColor(new Color(255, 140, 0)); | |
portion.getPortionFormat().getFillFormat().getPatternFormat().getBackColor().setColor(Color.WHITE); | |
portion.getPortionFormat().getFillFormat().getPatternFormat().setPatternStyle(PatternStyle.LargeGrid); | |
// Set font size of the shape's text | |
shape.getTextFrame().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().setFontHeight(128); | |
// Get text frame | |
ITextFrame textFrame = shape.getTextFrame(); | |
// Set up "Arch Up" WordArt transform effect | |
textFrame.getTextFrameFormat().setTransform(TextShapeType.ArchUp); | |
// Apply 3D effects | |
textFrame.getTextFrameFormat().getThreeDFormat().setExtrusionHeight(3.5f); | |
textFrame.getTextFrameFormat().getThreeDFormat().setDepth(3); | |
textFrame.getTextFrameFormat().getThreeDFormat().setMaterial(MaterialPresetType.Plastic); | |
textFrame.getTextFrameFormat().getThreeDFormat().getLightRig().setDirection(LightingDirection.Top); | |
textFrame.getTextFrameFormat().getThreeDFormat().getLightRig().setLightType(LightRigPresetType.Balanced); | |
textFrame.getTextFrameFormat().getThreeDFormat().getLightRig().setRotation(0, 0, 40); | |
textFrame.getTextFrameFormat().getThreeDFormat().getCamera().setCameraType(CameraPresetType.PerspectiveContrastingRightFacing); | |
// Save presentation | |
pres.save("3D-Text.pptx", SaveFormat.Pptx); | |
} finally { | |
if (pres != null) pres.dispose(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment