Shape3DRotationEffect.cs
//
// This code is part of Document Solutions for Word demos.
// Copyright (c) MESCIUS inc. All rights reserved.
//
using System;
using System.IO;
using System.Drawing;
using System.Collections.Generic;
using System.Linq;
using GrapeCity.Documents.Word;
namespace DsWordWeb.Demos
{
// This example shows how to add a 3D rotation effect to a shape.
public class Shape3DRotationEffect
{
public GcWordDocument CreateDocx()
{
var doc = new GcWordDocument();
Paragraph paragraph = doc.Body.Paragraphs.Add();
Run run = paragraph.GetRange().Runs.Add();
Shape shape = run.GetRange().Shapes.Add(200, 200, GeometryType.Rectangle);
shape.Fill.Type = FillType.Solid;
shape.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1;
shape.Line.Fill.Type = FillType.NoFill;
OuterShadow shadow = shape.Effects.Shadow;
shadow.Alignment = RectangleAlignment.Center;
shadow.Angle = 87f;
shadow.Blur = 17.75f;
shadow.Distance = 4f;
shadow.Color.RGB = Color.FromArgb(255, 0, 0, 0);
shadow.Color.Transparency = 0.67f;
// apply 3D format
ThreeDFormat threeDFormat = shape.Effects.ThreeDFormat;
threeDFormat.Depth.Width = 20f;
threeDFormat.Contour.Width = 1.5f;
threeDFormat.Contour.Color.RGB = Color.FromArgb(255, 255, 255, 255);
Bevel topbevel = threeDFormat.TopBevel;
topbevel.Type = BevelType.Angle;
topbevel.Width = 6.5f;
topbevel.Height = 3.5f;
Bevel bottomBevel = threeDFormat.BottomBevel;
bottomBevel.Type = BevelType.Angle;
bottomBevel.Width = 6.5f;
bottomBevel.Height = 3.5f;
// apply 3D scene
Lighting lighting = shape.Effects.ThreeDScene.Lighting;
lighting.Type = LightRigType.Harsh;
lighting.Direction = LightRigDirection.Top;
lighting.Rotation.Latitude = 0f;
lighting.Rotation.Longitude = 0f;
lighting.Rotation.Revolution = 50f;
Camera camera = shape.Effects.ThreeDScene.Camera;
camera.Preset = CameraPreset.PerspectiveFront;
camera.Perspective = 55f;
camera.Rotation.Latitude = 8.1f;
camera.Rotation.Longitude = 325.5f;
camera.Rotation.Revolution = 2.9f;
// Done:
return doc;
}
}
}