# Shape Format

Line format and fill format can be used to format shapes by using various gradient types.

## Content

DsWord allows you to enhance the look of shapes by customizing shape formats. As a shape represents a visual figure containing fill and outline, you can customize its fill format as well as line format. You can also add a shadow to the shape and set the shadow format.

## Fill Format

The fill format of a shape can be customized by using [FillFormat](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.FillFormat.html) class which provides [PatternFill](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.FillFormat.PatternFill.html), [SolidFill](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.FillFormat.SolidFill.html), [ImageFill](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.FillFormat.ImageFill.html), [GradientFill](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.FillFormat.GradientFill.html) properties that represent relevant fill types. The [FillType](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.FillType.html) enumeration can be used to define the active fill type.
To add gradient type fill format to a shape:

1. Add a rectangle shape to a Word document by using **Add** method of **ShapeCollection** class and pass **GeometryType.Rectangle** as its parameter.
2. Set **FillType** enumeration to **Gradient** to set gradient fill format.
3. Add gradient stops at different positions in the shape by using [Add](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.GradientStopList.Add.html) method of [GradientStopList](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.GradientStopList.html) class.

    ```csharp
    var doc = new GcWordDocument();
    var run = doc.Body.Paragraphs.Add().GetRange().Runs.Add();
    var shape = run.GetRange().Shapes.Add(300, 300, GeometryType.Rectangle);
    
    //Set fill format to gradient
    shape.Fill.Type = FillType.Gradient;
    
    //create additional gradient stops           
    //position range is 0..100.
    shape.Fill.GradientFill.Stops.Add(ThemeColorId.Light2, 10f);
    shape.Fill.GradientFill.Stops.Add(ThemeColorId.Accent2, 70f);
    shape.Fill.GradientFill.Stops.Add(ThemeColorId.Light2, 87f);
    
    doc.Save("fillformat.docx");
    ```

## Line Format

The line format of a shape defines appearance of a shape's line. It can be customized by using [LineFormat](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.LineFormat.html) class and can be set to solid, gradient, image, pattern fill types. You can also set various types of line formats like dash type, cap type, join type etc. by using properties of **LineFormat** class.
To add solid type line format to a shape:

1. Add a rectangle shape to a Word document by using **Add** method of **ShapeCollection** class and pass **GeometryType.Rectangle** as its parameter.
2. Set **FillType** enumeration to **Solid** to set solid line format.
3. Set **LineDashType** and **LineJoinType** enumerations to set dash type and join type of line.

    ```csharp
    var doc = new GcWordDocument();
    var run = doc.Body.Paragraphs.Add().GetRange().Runs.Add();
    var shape = run.GetRange().Shapes.Add(300, 300, GeometryType.Rectangle);
    
    //Set line format to solid
    shape.Line.Fill.Type = FillType.Solid;
    //Set line type to dotted
    shape.Line.DashType = LineDashType.Dot;
    //Set line join type to round
    shape.Line.JoinType = LineJoinType.Round;
    
    doc.Save("lineformat.docx");
    ```

## Shadow Format

The shadow format adds additional depth to a shape and creates a three-dimensional effect. DsWord allows you to apply shadow format to shape using [ApplyBuiltInShadow](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.TextEffects.ApplyBuiltInShadow.html) method of the [ShapeEffects](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ShapeEffects.html) class that accepts [BuiltInShadowId](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.BuiltInShadowId.html) enumeration as its parameter. However, for applying custom shadow effect to a shape, you can use **OuterShadow**, InnerShadow or **ShadowPreset** type of the [ShapeEffects](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ShapeEffects.html) class and set their properties.
The code below shows how to apply built-in shadow effect to a shape:

```csharp
// apply lower right prospective offset shadow effect to the shape
shape.Effects.ApplyBuiltInShadow(BuiltInShadowId.ProspectiveLowerRight);
```

The code below shows how to apply custom shadow effect to a shape:

```csharp
var canvas_shape = run.GetRange().CanvasShapes.Add(500, 500);
var shape2 = canvas_shape.GetRange().Shapes.Add(202, 250, "Shape");
shape2.Fill.SolidFill.RGB = Color.LemonChiffon;
shape2.Position.Horizontal.Offset = 4f;

var shape2InnerShadow = shape2.Effects.InnerShadow;
shape2InnerShadow.Blur = 4f;
shape2InnerShadow.Color.RGB = Color.Green;
shape2InnerShadow.Angle = 35;
shape2InnerShadow.Distance = 40f;
```

## Blur Format

The blur effect makes the edges of shapes appear fuzzy or out of focus. DsWord allows you to apply blur effect to the shape by using **Blur** property of the [ShapeEffects](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ShapeEffects.html) class. You can also apply this effect through [shape styles](/document-solutions/dot-net-word-api/docs/online/features/shapes/shape-styles#shapestyles).
![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/blur-direct.png)

```csharp
// Shape Blur - direct:
Paragraph p = doc.Body.Paragraphs.Add();
Run run = p.GetRange().Runs.Add();
Shape shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Star4);
shape.Fill.Type = FillType.Solid;
shape.Fill.SolidFill.RGB = Color.Yellow;
shape.Line.Width = 4;
shape.Line.Fill.SolidFill.RGB = Color.Red;
// apply 7 point blur effect to the shape
shape.Effects.Blur.Radius = 7f;
p.GetRange().Runs.Add("Shape Blur - direct.", doc.Styles[BuiltInStyleId.Strong]);
```

To view this sample code in action, see [Blur Effect demo](https://developer.mescius.com/documents-api-word/demos/features/effects/blur-effect/word-cs) sample.

## Reflection Format

DsWord allows you to apply reflection format to shape using **ApplyBuiltInReflection** method of the [ShapeEffects](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ShapeEffects.html) class that accepts [BuiltInReflectionId](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.BuiltInReflectionId.html) enumeration as its parameter. You can also use [styles](/document-solutions/dot-net-word-api/docs/online/features/shapes/shape-styles#shapestylesref) to define and apply custom reflection effects to a shape.
![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/reflection-direct-shape.png)
The code below shows how to apply built-in reflection to a shape using the ApplyBuiltInReflection method:

```csharp
// Shape reflection - direct effects:
Paragraph p = doc.Body.Paragraphs.Add();
Run run = p.GetRange().Runs.Add();
Shape shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Heptagon);
shape.Fill.Type = FillType.Solid;
shape.Fill.SolidFill.RGB = Color.PeachPuff;
shape.Line.Width = 4;
shape.Line.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1;
shape.Effects.ApplyBuiltInReflection(BuiltInReflectionId.TightTouching);
```

The code below shows how to apply custom reflection effect to a shape:

```csharp
Paragraph p = doc.Body.Paragraphs.Add();
Run run = p.GetRange().Runs.Add();
var canvas_shape = run.GetRange().CanvasShapes.Add(500, 500);
var shape = canvas_shape.GetRange().Shapes.Add(202, 250, "Shape");
shape.Fill.SolidFill.RGB = Color.Red;
shape.Position.Horizontal.Offset = 4f;
var shapeCustomReflection = shape.Effects.Reflection;
shapeCustomReflection.Angle = 35;
shapeCustomReflection.Distance = 40f;
```

To view the code in action, see [Reflection Effect demo](https://developer.mescius.com/documents-api-word/demos/features/effects/reflection-effect/word-cs) sample.

## Glow Format

DsWord allows you to apply glow effect to shape using **ApplyBuiltInGlow** method of the [ShapeEffects](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ShapeEffects.html) class that accepts [BuiltInGlowId](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.BuiltInGlowId.html) enumeration as its parameter. You can also use styles to define and apply custom glow effects to a shape.
![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/shape-glow-direct.png)
The code below shows how to apply built-in glow to a shape using the ApplyBuiltInGlow method:

```csharp
var shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Star5);
shape.Fill.Type = FillType.Solid;
shape.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1;
// apply 18 point accent 6 glow effect to the shape
shape.Effects.ApplyBuiltInGlow(BuiltInGlowId.Radius18Accent6);
p.GetRange().Runs.Add("Shape glow - direct.", doc.Styles[BuiltInStyleId.Strong]);
```

The code below shows how to apply custom glow effect to a shape:

```csharp
var canvas_shape = run.GetRange().CanvasShapes.Add(900, 900);
var shape = canvas_shape.GetRange().Shapes.Add(102, 102, "Shape");
shape.Fill.SolidFill.RGB = Color.LemonChiffon;
shape.Position.Horizontal.Offset = 9f;
var shapeGlow = shape.Effects.Glow;
shapeGlow.Radius = 30;
shapeGlow.Color.RGB = Color.Red;
```

To view the code in action, see [Glow Effect demo](https://developer.mescius.com/documents-api-word/demos/features/effects/glow-effect/word-cs) sample.

## SoftEdge Format

DsWord allows you to apply SoftEdge effect to the shape by using [SoftEdge](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ShapeEffects.SoftEdge.html) property of the [ShapeEffects](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ShapeEffects.html) class. You can also apply this effect through [shape styles](/document-solutions/dot-net-word-api/docs/online/features/shapes/shape-styles#shapestyles).
![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/softedge-direct.png)

```csharp
// Shape Soft Edge - direct:
Paragraph p = doc.Body.Paragraphs.Add();
Run run = p.GetRange().Runs.Add();
Shape shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Star7);
shape.Fill.Type = FillType.Solid;
shape.Fill.SolidFill.RGB = Color.Yellow;
shape.Line.Width = 8;
shape.Line.Fill.SolidFill.RGB = Color.Red;

// apply 5 point soft edge effect to the shape
shape.Effects.SoftEdge.Radius = 5f;
p.GetRange().Runs.Add("Shape Soft Edge - direct.", doc.Styles[BuiltInStyleId.Strong]);
```

To view this sample code in action, see [SoftEdge Effect demo](https://developer.mescius.com/documents-api-word/demos/features/effects/softedge-effect/word-cs) sample.

## FillOverlay Format

DsWord allows you to apply FillOverlay effect to the shape by using [FillOverlay](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ShapeEffects.FillOverlay.html) property of the **ShapeEffects** class. You can also apply this effect through [shape styles](/document-solutions/dot-net-word-api/docs/online/features/shapes/shape-styles#shapestyles).
![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/filloverlay-direct.png)

```csharp
// Shape fill overlay - direct:
var p = doc.Body.Paragraphs.Add();
var run = p.GetRange().Runs.Add();
var shape = run.GetRange().Shapes.Add(100, 100, GeometryType.Star8);
shape.Fill.Type = FillType.Solid;
shape.Fill.SolidFill.RGB = Color.LightBlue;
// Apply solid fill overlay with another color to mix with the main fill:
FillOverlay overlay = shape.Effects.FillOverlay;
overlay.BlendMode = BlendMode.Multiply;
overlay.Fill.Type = FillType.Solid;
overlay.Fill.SolidFill.RGB = Color.Yellow;
p.GetRange().Runs.Add("Shape fill overlay - direct.", doc.Styles[BuiltInStyleId.Strong]);
```

To view this sample code in action, see [FillOverlay Effect demo](https://developer.mescius.com/documents-api-word/demos/features/effects/fill-overlay-effect/word-cs) sample.

## 3D Format

The 3D effects refer to the effects applied in three spatial dimensions: width, height, and depth. The 3D effects give the shape a unique and artistic look. For applying 3D effects, DsWord provides the [ThreeDFormat](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ThreeDFormat.html) and [ThreeDScene](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.ThreeDScene.html) classes and the [ApplyEffectsPreset](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.Shape.ApplyEffectsPreset.html) method. The ApplyEffectsPreset method allows a user to add preset 3D effects. However, the ThreeDFormat and ThreeDScene classes allow a user to add custom 3D effects.

| **Preset 3D Effect** | **Custom 3D Effect** | **3D Rotation** |
| ---------------- | ---------------- | ----------- |
| ![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/shape-preset-3d-effect.png) | ![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/shape-3d-effect.png) | ![](https://cdn.mescius.io/document-site-files/images/d623c730-bceb-4e85-a6b2-a3dbe84720b2/images/shape-3d-rotation.png) |

Refer to the following example code to add a preset 3D effect:

```csharp
// Initialize GcWordDocument.
GcWordDocument doc = new GcWordDocument();

// Add a shape to the document.
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;

// Apply a preset 3D shape effect.
shape.ApplyEffectsPreset(ShapeEffectsPreset.Preset10);

// Save the Word document.
doc.Save("Preset3DEffects.docx");
```

Refer to the following example code to add a custom 3D effect:

```csharp
// Initialize GcWordDocument.
GcWordDocument doc = new GcWordDocument();

// Add a shape to the document.
Paragraph paragraph = doc.Body.Paragraphs.Add();
Run run = paragraph.GetRange().Runs.Add();
var shape = run.GetRange().Shapes.Add(200, 200, GeometryType.Rectangle);
shape.Fill.Type = FillType.Solid;
shape.Fill.SolidFill.ThemeColor = ThemeColorId.Accent1;

// Apply 3D format to the shape.
ThreeDFormat threeD = shape.Effects.ThreeDFormat;
threeD.TopBevel.ApplyPreset(BevelType.Convex);
threeD.Contour.Color.ThemeColor = ThemeColorId.Accent2;
threeD.Contour.Width = 3f;
threeD.Contour.Color.ThemeColor = ThemeColorId.Accent6;
threeD.Contour.Width = 12f;

// Apply 3D scene to the shape.
ThreeDScene scene = shape.Effects.ThreeDScene;
scene.Camera.Preset = CameraPreset.PerspectiveContrastingRightFacing;
scene.Lighting.Type = LightRigType.BrightRoom;
scene.Lighting.Rotation.Latitude = 90f;
scene.Lighting.Rotation.Revolution = 5f;

// Save the Word document.
doc.Save("3DEffects.docx");
```

Refer to the following example code to add a 3D rotation effect:

```csharp
// Initialize GcWordDocument.
GcWordDocument doc = new GcWordDocument();

// Add a shape to the document.
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;

// Add outershadow to the shape.
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);

// Add top bevel.
Bevel topbevel = threeDFormat.TopBevel;
topbevel.Type = BevelType.Angle;
topbevel.Width = 6.5f;
topbevel.Height = 3.5f;

// Add bottom bevel.
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;

// Apply rotation to the shape.
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;

// Save the Word document.
doc.Save("Shape3DRotation.docx");
```

**Limitation**
DsWord does not support the export of 3D effects to PDF or images.