Learn how to apply 3D effects in PowerPoint PPT/PPTX presentations in C# .NET: https://blog.aspose.com/2022/01/24/create-three-d-effects-in-ppt-csharp-net/
Last active
January 24, 2022 15:14
-
-
Save aspose-com-gists/9111ed69eeb4cf031293753aa445d405 to your computer and use it in GitHub Desktop.
Apply 3D Effects in PowerPoint using C# .NET
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 | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Add a new shape | |
IAutoShape shape = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 200, 150, 200, 200); | |
// Add image | |
shape.FillFormat.FillType = FillType.Picture; | |
shape.FillFormat.PictureFillFormat.Picture.Image = presentation.Images.AddImage(File.ReadAllBytes("tiger.bmp")); | |
shape.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch; | |
// Apply 3D effects | |
shape.ThreeDFormat.Camera.CameraType = CameraPresetType.OrthographicFront; | |
shape.ThreeDFormat.Camera.SetRotation(20, 30, 40); | |
shape.ThreeDFormat.LightRig.LightType = LightRigPresetType.Flat; | |
shape.ThreeDFormat.LightRig.Direction = LightingDirection.Top; | |
shape.ThreeDFormat.Material = MaterialPresetType.Flat; | |
shape.ThreeDFormat.ExtrusionHeight = 100; | |
shape.ThreeDFormat.ExtrusionColor.Color = Color.DarkGray; | |
// Save presentation | |
presentation.Save("3D-Image.pptx", SaveFormat.Pptx); | |
} |
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 | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Add a new shape | |
IAutoShape shape = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 200, 150, 200, 200); | |
// Set text | |
shape.TextFrame.Text = "3D"; | |
shape.TextFrame.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 64; | |
// Apply gradient | |
shape.FillFormat.FillType = FillType.Gradient; | |
shape.FillFormat.GradientFormat.GradientStops.Add(0, Color.Blue); | |
shape.FillFormat.GradientFormat.GradientStops.Add(100, Color.LightBlue); | |
// Apply 3D effects | |
shape.ThreeDFormat.Camera.CameraType = CameraPresetType.OrthographicFront; | |
shape.ThreeDFormat.Camera.SetRotation(20, 30, 40); | |
shape.ThreeDFormat.LightRig.LightType = LightRigPresetType.Flat; | |
shape.ThreeDFormat.LightRig.Direction = LightingDirection.Top; | |
shape.ThreeDFormat.Material = MaterialPresetType.Flat; | |
shape.ThreeDFormat.ExtrusionHeight = 100; | |
shape.ThreeDFormat.ExtrusionColor.Color = Color.Blue; | |
// Save presentation | |
presentation.Save("3D-Shape-Gradient.pptx", SaveFormat.Pptx); | |
} |
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 | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Add a new shape | |
IAutoShape shape = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 200, 150, 200, 200); | |
// Set text | |
shape.TextFrame.Text = "3D"; | |
shape.TextFrame.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 64; | |
// Apply 3D effects | |
shape.ThreeDFormat.Camera.CameraType = CameraPresetType.OrthographicFront; | |
shape.ThreeDFormat.Camera.SetRotation(20, 30, 40); | |
shape.ThreeDFormat.LightRig.LightType = LightRigPresetType.Flat; | |
shape.ThreeDFormat.LightRig.Direction = LightingDirection.Top; | |
shape.ThreeDFormat.Material = MaterialPresetType.Flat; | |
shape.ThreeDFormat.ExtrusionHeight = 100; | |
shape.ThreeDFormat.ExtrusionColor.Color = Color.Blue; | |
// Save presentation | |
presentation.Save("3D-Shape.pptx", SaveFormat.Pptx); | |
} |
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 | |
using (Presentation presentation = new Presentation()) | |
{ | |
// Create a rectangle shape | |
IAutoShape shape = presentation.Slides[0].Shapes.AddAutoShape(ShapeType.Rectangle, 200, 150, 250, 250); | |
shape.FillFormat.FillType = FillType.NoFill; | |
shape.LineFormat.FillFormat.FillType = FillType.NoFill; | |
shape.TextFrame.Text = "3D Text"; | |
// Get text portion | |
Portion portion = (Portion)shape.TextFrame.Paragraphs[0].Portions[0]; | |
portion.PortionFormat.FillFormat.FillType = FillType.Pattern; | |
portion.PortionFormat.FillFormat.PatternFormat.ForeColor.Color = Color.DarkOrange; | |
portion.PortionFormat.FillFormat.PatternFormat.BackColor.Color = Color.White; | |
portion.PortionFormat.FillFormat.PatternFormat.PatternStyle = PatternStyle.LargeGrid; | |
shape.TextFrame.Paragraphs[0].ParagraphFormat.DefaultPortionFormat.FontHeight = 128; | |
// Access text frame | |
ITextFrame textFrame = shape.TextFrame; | |
// Set up "Arch Up" WordArt transform effect | |
textFrame.TextFrameFormat.Transform = TextShapeType.ArchUp; | |
// Apply 3D effects | |
textFrame.TextFrameFormat.ThreeDFormat.ExtrusionHeight = 3.5f; | |
textFrame.TextFrameFormat.ThreeDFormat.Depth = 3; | |
textFrame.TextFrameFormat.ThreeDFormat.Material = MaterialPresetType.Plastic; | |
textFrame.TextFrameFormat.ThreeDFormat.LightRig.Direction = LightingDirection.Top; | |
textFrame.TextFrameFormat.ThreeDFormat.LightRig.LightType = LightRigPresetType.Balanced; | |
textFrame.TextFrameFormat.ThreeDFormat.LightRig.SetRotation(0, 0, 40); | |
textFrame.TextFrameFormat.ThreeDFormat.Camera.CameraType = CameraPresetType.PerspectiveContrastingRightFacing; | |
// Save presentation | |
presentation.Save("3D-Text.pptx", SaveFormat.Pptx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment