---
title: "Text Effects"
canonical: https://www.graphicsmill.com/samples/Text/EnhancedText/TextEffects_cs
product: "Graphics Mill"
source: "Text/EnhancedText/TextEffects.cs"
---

# Text Effects

Demonstrates how to use shadow and glow effects for drawing text.

## Instruction

This code demonstrates how to apply shadow and glow effects to text rendering.

## Usings

```csharp
using Aurigma.GraphicsMill.Drawing;
using Aurigma.GraphicsMill.Drawing.Effects;
```

## Code Snippet

```csharp
using (var bitmap = new Bitmap(600, 400, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var gr = bitmap.GetGraphics())
{
    // Draw text with shadow effect
    var textWithShadow = new PlainText("Text with shadow.", gr.CreateFont("Arial", 50))
    {
        Position = new System.Drawing.PointF(50, 50),
        Brush = new SolidBrush(RgbColor.Red),
    };

    textWithShadow.Effect = new Shadow()
    {
        Color = RgbColor.Black,
        OffsetX = 3,
        OffsetY = 3,
        Opacity = 0.5f,
        Size = 2.0f,
    };

    gr.DrawText(textWithShadow);

    // Draw text with glow effect
    var textWithGlow = new PlainText("Text with glow.", gr.CreateFont("Arial", 50))
    {
        Position = new System.Drawing.PointF(50, 250),
        Brush = new SolidBrush(RgbColor.Black),
    };

    textWithGlow.Effect = new Glow()
    {
        Color = RgbColor.Red,
        Opacity = 0.75f,
        Size = 2.0f,
    };

    gr.DrawText(textWithGlow);

    bitmap.Save("TextEffects.png");
}
```

## Explanation

The code:

- Creates a `Bitmap` object with a white background (`RgbColor(255, 255, 255, 255)`) and dimensions of 600x400 pixels.
- Initializes an `AdvancedGraphics` object for drawing on the bitmap.
- Draws the first text, "Text with shadow", using the "Arial" font with a size of 50 points and red color. A shadow effect is applied to the text with a black color, an offset of (3, 3), opacity of 50%, and size 2.0f.
- Draws the second text, "Text with glow", with a black color and similar font size. A glow effect is applied with a red color, 75% opacity, and size 2.0f.
- Both texts are positioned at different locations on the bitmap: the first text at `(50, 50)` and the second at `(50, 250)`.
- The final image is saved as a PNG file (`TextEffects.png`).

## Tags

- [Drawing](<https://www.graphicsmill.com/samples/tags/drawing_md>): Drawing vector shapes and text
- [Formatted Text](<https://www.graphicsmill.com/samples/tags/formatted-text_md>): XML-based formatted text syntax
- [Text](<https://www.graphicsmill.com/samples/tags/text_md>): Rendering and formatting text

## Output

- [TextEffects.png](<https://www.graphicsmill.com/samples/Text/compiled/Debug/TextEffects_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Effects.Glow](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Effects_Glow.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Effects.Glow.Color](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Effects_Glow_Color.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Effects.Glow.Opacity](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Effects_Glow_Opacity.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Effects.Glow.Size](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Effects_Glow_Size.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Effects.Shadow](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Effects_Shadow.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Effects.Shadow.Color](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Effects_Shadow_Color.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Effects.Shadow.OffsetX](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Effects_Shadow_OffsetX.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Effects.Shadow.OffsetY](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Effects_Shadow_OffsetY.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Effects.Shadow.Opacity](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Effects_Shadow_Opacity.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Effects.Shadow.Size](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Effects_Shadow_Size.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.CreateFont(String,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_CreateFont_2_1dbfa9fa.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawText(Text)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawText_1_f576d03f.htm.md>)
- [Aurigma.GraphicsMill.Drawing.PlainText](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_PlainText.htm.md>)
- [Aurigma.GraphicsMill.Drawing.PlainText.Position](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_PlainText_Position.htm.md>)
- [Aurigma.GraphicsMill.Drawing.SolidBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_SolidBrush.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Text.Brush](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Text_Brush.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Text.Effect](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Text_Effect.htm.md>)
