---
title: "Gradient Color"
canonical: https://www.graphicsmill.com/samples/Text/EnhancedText/GradientColor_cs
product: "Graphics Mill"
source: "Text/EnhancedText/GradientColor.cs"
---

# Gradient Color

Demonstrates drawing text with a gradient fill.

## Instruction

This code creates a bitmap with gradient-colored text and saves it as an image.

## Usings

```csharp
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
using (var bitmap = new Bitmap(600, 250, PixelFormat.Format24bppRgb, new RgbColor(255, 255, 255, 255)))
using (var graphics = bitmap.GetGraphics())
{
    var gradientBrush = new LinearGradientBrush()
    {
        BackgroundColor = RgbColor.Green,
        StartPoint = new System.Drawing.PointF(0, 0),
        EndPoint = new System.Drawing.PointF(600, 400),
        ColorStops = new ColorStop[]
        {
            new ColorStop() { Color = RgbColor.Aqua, Position = 0.0f },
            new ColorStop() { Color = RgbColor.Black, Position = 0.66f },
            new ColorStop() { Color = RgbColor.Violet, Position = 1 },
        },
    };

    var dummyText = "GRADIENT";

    var text = new PlainText(dummyText, graphics.CreateFont("Verdana", 110f))
    {
        Position = new System.Drawing.PointF(10f, 230f),
        Brush = gradientBrush,
    };

    graphics.DrawText(text);

    bitmap.Save("GradientColor.png");
}
```

## Explanation

The code:

- Creates a `Bitmap` object with a white background (`RgbColor(255, 255, 255, 255)`).
- Initializes an `AdvancedGraphics` object to handle the drawing on the bitmap.
- Defines a `LinearGradientBrush` for coloring the text, with a gradient that starts with Aqua, transitions to Black, and ends with Violet.
- Specifies the start and end points for the gradient and positions the color stops at defined positions (0.0, 0.66, 1.0).
- Defines the text "GRADIENT" and applies the gradient brush as its fill color.
- The text is drawn on the bitmap using a font (`Verdana`, 110pt) at the position `(10f, 230f)`.
- The final result is saved as a new PNG file (`GradientColor.png`).

## Tags

- [Drawing](<https://www.graphicsmill.com/samples/tags/drawing_md>): Drawing vector shapes and text
- [Gradient](<https://www.graphicsmill.com/samples/tags/gradient_md>): Using gradient brushes and fills
- [Text](<https://www.graphicsmill.com/samples/tags/text_md>): Rendering and formatting text

## Output

- [GradientColor.png](<https://www.graphicsmill.com/samples/Text/compiled/Debug/GradientColor_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Drawing.ColorStop](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_ColorStop.htm.md>)
- [Aurigma.GraphicsMill.Drawing.ColorStop.Color](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_ColorStop_Color.htm.md>)
- [Aurigma.GraphicsMill.Drawing.ColorStop.Position](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_ColorStop_Position.htm.md>)
- [Aurigma.GraphicsMill.Drawing.GradientBrush.BackgroundColor](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_GradientBrush_BackgroundColor.htm.md>)
- [Aurigma.GraphicsMill.Drawing.GradientBrush.ColorStops](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_GradientBrush_ColorStops.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.LinearGradientBrush](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_LinearGradientBrush.htm.md>)
- [Aurigma.GraphicsMill.Drawing.LinearGradientBrush.EndPoint](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_LinearGradientBrush_EndPoint.htm.md>)
- [Aurigma.GraphicsMill.Drawing.LinearGradientBrush.StartPoint](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_LinearGradientBrush_StartPoint.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.Text.Brush](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Text_Brush.htm.md>)
