Table of Contents

Interface IDrawingContextImpl

Namespace
Avalonia.Platform
Assembly
Avalonia.Base.dll

Defines the interface through which drawing occurs.

[Unstable]
public interface IDrawingContextImpl : IDisposable
Inherited Members
Extension Methods

Properties

Transform

Gets or sets the current transform of the drawing context.

Matrix Transform { get; set; }

Property Value

Matrix

Methods

Clear(Color)

Clears the render target to the specified color.

void Clear(Color color)

Parameters

color Color

The color.

CreateLayer(PixelSize)

Creates a new IRenderTargetBitmapImpl that can be used as a render layer for the current render target.

IDrawingContextLayerImpl CreateLayer(PixelSize size)

Parameters

size PixelSize

The size of the layer in DIPs.

Returns

IDrawingContextLayerImpl

An IRenderTargetBitmapImpl

Remarks

Depending on the rendering backend used, a layer created via this method may be more performant than a standard render target bitmap. In particular the Direct2D backend has to do a format conversion each time a standard render target bitmap is rendered, but a layer created via this method has no such overhead.

DrawBitmap(IBitmapImpl, IBrush, Rect, Rect)

Draws a bitmap image.

void DrawBitmap(IBitmapImpl source, IBrush opacityMask, Rect opacityMaskRect, Rect destRect)

Parameters

source IBitmapImpl

The bitmap image.

opacityMask IBrush

The opacity mask to draw with.

opacityMaskRect Rect

The destination rect for the opacity mask.

destRect Rect

The rect in the output to draw to.

DrawBitmap(IBitmapImpl, double, Rect, Rect)

Draws a bitmap image.

void DrawBitmap(IBitmapImpl source, double opacity, Rect sourceRect, Rect destRect)

Parameters

source IBitmapImpl

The bitmap image.

opacity double

The opacity to draw with.

sourceRect Rect

The rect in the image to draw.

destRect Rect

The rect in the output to draw to.

DrawEllipse(IBrush?, IPen?, Rect)

Draws an ellipse with the specified Brush and Pen.

void DrawEllipse(IBrush? brush, IPen? pen, Rect rect)

Parameters

brush IBrush

The brush used to fill the ellipse, or null for no fill.

pen IPen

The pen used to stroke the ellipse, or null for no stroke.

rect Rect

The ellipse bounds.

Remarks

The brush and the pen can both be null. If the brush is null, then no fill is performed. If the pen is null, then no stoke is performed. If both the pen and the brush are null, then the drawing is not visible.

DrawGeometry(IBrush?, IPen?, IGeometryImpl)

Draws a geometry.

void DrawGeometry(IBrush? brush, IPen? pen, IGeometryImpl geometry)

Parameters

brush IBrush

The fill brush.

pen IPen

The stroke pen.

geometry IGeometryImpl

The geometry.

DrawGlyphRun(IBrush?, IGlyphRunImpl)

Draws a glyph run.

void DrawGlyphRun(IBrush? foreground, IGlyphRunImpl glyphRun)

Parameters

foreground IBrush

The foreground.

glyphRun IGlyphRunImpl

The glyph run.

DrawLine(IPen?, Point, Point)

Draws a line.

void DrawLine(IPen? pen, Point p1, Point p2)

Parameters

pen IPen

The stroke pen.

p1 Point

The first point of the line.

p2 Point

The second point of the line.

DrawRectangle(IBrush?, IPen?, RoundedRect, BoxShadows)

Draws a rectangle with the specified Brush and Pen.

void DrawRectangle(IBrush? brush, IPen? pen, RoundedRect rect, BoxShadows boxShadows = default)

Parameters

brush IBrush

The brush used to fill the rectangle, or null for no fill.

pen IPen

The pen used to stroke the rectangle, or null for no stroke.

rect RoundedRect

The rectangle bounds.

boxShadows BoxShadows

Box shadow effect parameters

Remarks

The brush and the pen can both be null. If the brush is null, then no fill is performed. If the pen is null, then no stoke is performed. If both the pen and the brush are null, then the drawing is not visible.

DrawRegion(IBrush?, IPen?, IPlatformRenderInterfaceRegion)

Draws the specified region with the specified Brush and Pen.

void DrawRegion(IBrush? brush, IPen? pen, IPlatformRenderInterfaceRegion region)

Parameters

brush IBrush

The brush used to fill the rectangle, or null for no fill.

pen IPen

The pen used to stroke the rectangle, or null for no stroke.

region IPlatformRenderInterfaceRegion

The region to draw.

Remarks

The brush and the pen can both be null. If the brush is null, then no fill is performed. If the pen is null, then no stoke is performed. If both the pen and the brush are null, then the drawing is not visible.

GetFeature(Type)

Attempts to get an optional feature from the drawing context implementation.

object? GetFeature(Type t)

Parameters

t Type

Returns

object

PopClip()

Pops the latest pushed clip rectangle.

void PopClip()

PopGeometryClip()

Pops the latest pushed geometry clip.

void PopGeometryClip()

PopLayer()

Pops the latest pushed intermediate surface layer.

void PopLayer()

PopOpacity()

Pops the latest pushed opacity value.

void PopOpacity()

PopOpacityMask()

Pops the latest pushed opacity mask.

void PopOpacityMask()

PopRenderOptions()

Pops the latest render options.

void PopRenderOptions()

PushClip(IPlatformRenderInterfaceRegion)

Pushes a clip region.

void PushClip(IPlatformRenderInterfaceRegion region)

Parameters

region IPlatformRenderInterfaceRegion

The clip region

PushClip(Rect)

Pushes a clip rectangle.

void PushClip(Rect clip)

Parameters

clip Rect

The clip rectangle.

PushClip(RoundedRect)

Pushes a clip rounded rectangle.

void PushClip(RoundedRect clip)

Parameters

clip RoundedRect

The clip rounded rectangle

PushGeometryClip(IGeometryImpl)

Pushes a clip geometry.

void PushGeometryClip(IGeometryImpl clip)

Parameters

clip IGeometryImpl

The clip geometry.

PushLayer(Rect)

Enforces rendering to happen on an intermediate surface

void PushLayer(Rect bounds)

Parameters

bounds Rect

PushOpacity(double, Rect?)

Pushes an opacity value.

void PushOpacity(double opacity, Rect? bounds)

Parameters

opacity double

The opacity.

bounds Rect?

where to apply the opacity.

PushOpacityMask(IBrush, Rect)

Pushes an opacity mask.

void PushOpacityMask(IBrush mask, Rect bounds)

Parameters

mask IBrush
bounds Rect

PushRenderOptions(RenderOptions)

Pushes render options.

void PushRenderOptions(RenderOptions renderOptions)

Parameters

renderOptions RenderOptions

The render options.