---
title: "Draw Path"
canonical: https://www.graphicsmill.com/samples/Drawing/DrawingPrimitives/DrawPath_cs
product: "Graphics Mill"
source: "Drawing/DrawingPrimitives/DrawPath.cs"
---

# Draw Path

Draws path on Graphics.

## Instruction

Draw vector shapes and styled text using a custom path, then transform and draw it again with rotation and translation.

## Usings

```csharp
using Aurigma.GraphicsMill.Drawing;
```

## Code Snippet

```csharp
var createPath = (Graphics graphics) =>
{
    var path = new Path();

    var font = graphics.CreateFont("Arial", "Bold", 40f);

    var text = new PlainText("GraphicsMill", font)
    {
        Alignment = TextAlignment.Center,
    };

    var blackBox = text.GetBlackBox(graphics.FontRegistry, graphics.DpiX, graphics.DpiY);
    text.Position = new System.Drawing.PointF(blackBox.Width, blackBox.Height * 2.3f);

    path.DrawEllipse(0, 0, blackBox.Width * 2, blackBox.Height * 4);
    path.DrawText(text, graphics.FontRegistry, graphics.DpiX, graphics.DpiY);

    return path;
};

using (var bitmap = new Bitmap(640, 480, PixelFormat.Format24bppRgb, RgbColor.White))
using (var graphics = bitmap.GetGraphics())
{
    var path = createPath(graphics);

    graphics.DrawPath(new Pen(RgbColor.Red, 2f), path);

    // Translate coordinates and rotate
    var matrix = new System.Drawing.Drawing2D.Matrix();
    matrix.Translate(bitmap.Width / 3, bitmap.Height / 3);
    matrix.Rotate(30);
    graphics.Transform = matrix;

    graphics.DrawPath(new Pen(RgbColor.Green, 2f), path);

    bitmap.Save("DrawPath.png");
}
```

## Explanation

The code:

- Creates a vector path containing an ellipse and centered text.
- Draws the path in red on a blank image.
- Applies a transformation matrix to translate and rotate the path.
- Draws the transformed path in green.
- Saves the final result to an output file.

## Tags

- [Bitmap](<https://www.graphicsmill.com/samples/tags/bitmap_md>): Working with images via the Bitmap API
- [Drawing](<https://www.graphicsmill.com/samples/tags/drawing_md>): Drawing vector shapes and text
- [Text](<https://www.graphicsmill.com/samples/tags/text_md>): Rendering and formatting text

## Output

- [DrawPath.png](<https://www.graphicsmill.com/samples/Drawing/compiled/Debug/DrawPath_png>) (preview)

## Used APIs

- [Aurigma.GraphicsMill.Bitmap.GetGraphics](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Bitmap_GetGraphics.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Graphics.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.CreateFont(String,String,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_CreateFont_3_2557116e.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DpiX](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Graphics_DpiX.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DpiY](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Graphics_DpiY.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.DrawPath(Pen,Path)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Graphics_DrawPath_2_77634c23.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.FontRegistry](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Graphics_FontRegistry.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Graphics.Transform](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_Graphics_Transform.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Path](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Path.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Path.DrawEllipse(Single,Single,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Path_DrawEllipse_4_37f6c741.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Path.DrawText(Text,FontRegistry,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Path_DrawText_4_520c231e.htm.md>)
- [Aurigma.GraphicsMill.Drawing.Pen](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_Pen.htm.md>)
- [Aurigma.GraphicsMill.Drawing.PlainText](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_PlainText.htm.md>)
- [Aurigma.GraphicsMill.Drawing.PlainText.Alignment](<https://www.graphicsmill.com/docs/gm/P_Aurigma_GraphicsMill_Drawing_PlainText_Alignment.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.GetBlackBox(FontRegistry,Single,Single)](<https://www.graphicsmill.com/docs/gm/M_Aurigma_GraphicsMill_Drawing_Text_GetBlackBox_3_185e8a92.htm.md>)
- [Aurigma.GraphicsMill.Drawing.TextAlignment](<https://www.graphicsmill.com/docs/gm/T_Aurigma_GraphicsMill_Drawing_TextAlignment.htm.md>)
