ImageSharp.Drawing

2D Polygon and text drawing extensions for ImageSharp.

Revolutionize your graphics with ImageSharp.Drawing, the ideal solution for dynamic design and development. It blends intuitive design with powerful functionality, making it perfect for developers seeking precision and ease. Embrace the art of simplicity with ImageSharp.Drawing

Install anywhere

ImageSharp.Drawing carries no native dependencies and can be installed anywhere that supports .NET 6+, ImageSharp.Drawing can be used in device, cloud, and embedded/IoT scenarios.

PM > Install-Package SixLabors.ImageSharp.Drawing

Powerfully Simple:
An API for Everyone

Experience the unmatched combination of power and simplicity with ImageSharp.Drawing. Engineered for peak developer experience, its API redefines ease of use, offering unparalleled flexibility and extensibility.

Master the art of drawing complex shapes effortlessly with our intuitive command suite. ImageSharp.Drawing is where simplicity meets sophistication, making advanced graphics accessible to all.

using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;

using Image image = new Image<Rgba32>(100, 100);
Star star = new(50, 50, 5, 20, 45);
PointF[] points = star.Points.ToArray();
Color[] colors =
{
    Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple,
    Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple
};

PathGradientBrush brush = new(points, colors, Color.White);

image.Mutate(x => x.Fill(brush));
image.Save("star.png");

Revolutionizing Text Graphics

With its cutting-edge text rendering, ImageSharp.Drawing leads the .NET ecosystem. Its mastery of bi-directional (BIDI) text seamlessly integrates diverse scripts, essential for global reach. The library boasts advanced rich text features like underlining, overlining, strikethrough, with custom brushes, elevating text styling to new heights. Its versatility shines with both vertical and horizontal text support, catering to any design need.

This makes it a transformative tool for high-impact visuals, ensuring crisp, clear typography across all platforms and resolutions.

using SixLabors.Fonts;
using SixLabors.Fonts.Unicode;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Drawing.Processing;

Font font = CreateFont("OpenSans-Regular.ttf", 36);
Font fallback = CreateFont("NotoSansKR-Regular.otf", 36);

const string text = "한국어 hangugeo";
RichTextOptions textOptions = new(font)
{
    FallbackFontFamilies = new[] { fallback.Family },
    LayoutMode = LayoutMode.VerticalLeftRight,
    TextRuns = new[]
    {
        new RichTextRun()
        {
            Start = 0,
            End = text.GetGraphemeCount(),
            TextDecorations = TextDecorations.Underline
        }
    }
};

FontRectangle bounds = TextMeasurer.MeasureSize(text, textOptions);
using Image<Rgba32> img = new((int)Math.Ceiling(bounds.Width), (int)Math.Ceiling(bounds.Height));
img.Mutate(x => x.Fill(Color.White).DrawText(textOptions, text, Brushes.Solid(Color.Black)));

img.Save("rich-text.png");