Rendering graphics in AlterNET UI

AlterNET UI includes resolution-independent graphics features that use native rendering on Windows, macOS, and Linux.

It supports rendering graphic primitives such as text, images, and graphic shapes with different fonts and brushes.

This feature is implemented by platform-independent DrawingContext class, that has methods for rendering graphic primitives and applying transformations.

using Alternet.UI;

internal class CustomDrawnControl : Control
{
    protected override void OnPaint(PaintEventArgs e)
    {
        var context = e.DrawingContext;
        context.FillRectangle(brush, Handler.ClientRectangle);
        context.DrawRectangle(Pens.Gray, Handler.ClientRectangle);
        context.DrawText(text, DefaultFont, Brushes.Black, new PointF(10, 10));
        context.DrawImage(image, new PointF(0, 10 + 
                context.MeasureText(text, DefaultFont).Height));
    }
}

We looking at extending drawing context to support arbitrary shapes and matrix transformations.

Refer to this step-by-step tutorial for more details.

Previous
Previous

AlterNET UI Beta 2 - Layout system, dependency property, data binding, and more

Next
Next

Creating your first AlterNET UI Application