Shape3DRotationEffect.cs
  1. //
  2. // This code is part of Document Solutions for Word demos.
  3. // Copyright (c) MESCIUS inc. All rights reserved.
  4. //
  5. using System;
  6. using System.IO;
  7. using System.Drawing;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using GrapeCity.Documents.Word;
  11.  
  12. namespace DsWordWeb.Demos
  13. {
  14. // This example shows how to add a 3D rotation effect to a shape.
  15. public class Shape3DRotationEffect
  16. {
  17. public GcWordDocument CreateDocx()
  18. {
  19. var doc = new GcWordDocument();
  20.  
  21. Paragraph paragraph = doc.Body.Paragraphs.Add();
  22. Run run = paragraph.GetRange().Runs.Add();
  23. Shape shape = run.GetRange().Shapes.Add(200, 200, GeometryType.Rectangle);
  24. shape.Fill.Type = FillType.Solid;
  25. shape.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1;
  26.  
  27. shape.Line.Fill.Type = FillType.NoFill;
  28.  
  29. OuterShadow shadow = shape.Effects.Shadow;
  30. shadow.Alignment = RectangleAlignment.Center;
  31. shadow.Angle = 87f;
  32. shadow.Blur = 17.75f;
  33. shadow.Distance = 4f;
  34. shadow.Color.RGB = Color.FromArgb(255, 0, 0, 0);
  35. shadow.Color.Transparency = 0.67f;
  36.  
  37. // apply 3D format
  38. ThreeDFormat threeDFormat = shape.Effects.ThreeDFormat;
  39. threeDFormat.Depth.Width = 20f;
  40. threeDFormat.Contour.Width = 1.5f;
  41. threeDFormat.Contour.Color.RGB = Color.FromArgb(255, 255, 255, 255);
  42.  
  43. Bevel topbevel = threeDFormat.TopBevel;
  44. topbevel.Type = BevelType.Angle;
  45. topbevel.Width = 6.5f;
  46. topbevel.Height = 3.5f;
  47.  
  48. Bevel bottomBevel = threeDFormat.BottomBevel;
  49. bottomBevel.Type = BevelType.Angle;
  50. bottomBevel.Width = 6.5f;
  51. bottomBevel.Height = 3.5f;
  52.  
  53. // apply 3D scene
  54. Lighting lighting = shape.Effects.ThreeDScene.Lighting;
  55. lighting.Type = LightRigType.Harsh;
  56. lighting.Direction = LightRigDirection.Top;
  57. lighting.Rotation.Latitude = 0f;
  58. lighting.Rotation.Longitude = 0f;
  59. lighting.Rotation.Revolution = 50f;
  60.  
  61. Camera camera = shape.Effects.ThreeDScene.Camera;
  62. camera.Preset = CameraPreset.PerspectiveFront;
  63. camera.Perspective = 55f;
  64. camera.Rotation.Latitude = 8.1f;
  65. camera.Rotation.Longitude = 325.5f;
  66. camera.Rotation.Revolution = 2.9f;
  67.  
  68. // Done:
  69. return doc;
  70. }
  71. }
  72. }
  73.