Table of Contents

Class ImmediateDrawingContext

Namespace
Avalonia.Media
Assembly
Avalonia.Base.dll
public sealed class ImmediateDrawingContext : IDisposable, IOptionalFeatureProvider
Inheritance
ImmediateDrawingContext
Implements
Inherited Members
Extension Methods

Properties

CurrentTransform

Gets the current transform of the drawing context.

public Matrix CurrentTransform { get; }

Property Value

Matrix

PlatformImpl

public IDrawingContextImpl PlatformImpl { get; }

Property Value

IDrawingContextImpl

Methods

Dispose()

Disposes of any resources held by the DrawingContext.

public void Dispose()

DrawBitmap(Bitmap, Rect)

Draws an bitmap.

public void DrawBitmap(Bitmap source, Rect rect)

Parameters

source Bitmap

The bitmap.

rect Rect

The rect in the output to draw to.

DrawBitmap(Bitmap, Rect, Rect)

Draws an image.

public void DrawBitmap(Bitmap source, Rect sourceRect, Rect destRect)

Parameters

source Bitmap

The bitmap.

sourceRect Rect

The rect in the image to draw.

destRect Rect

The rect in the output to draw to.

DrawEllipse(IImmutableBrush?, ImmutablePen?, Point, double, double)

Draws an ellipse with the specified Brush and Pen.

public void DrawEllipse(IImmutableBrush? brush, ImmutablePen? pen, Point center, double radiusX, double radiusY)

Parameters

brush IImmutableBrush

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

pen ImmutablePen

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

center Point

The location of the center of the ellipse.

radiusX double

The horizontal radius of the ellipse.

radiusY double

The vertical radius of the ellipse.

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.

DrawGlyphRun(IImmutableBrush, IImmutableGlyphRunReference)

Draws a glyph run.

public void DrawGlyphRun(IImmutableBrush foreground, IImmutableGlyphRunReference glyphRun)

Parameters

foreground IImmutableBrush

The foreground brush.

glyphRun IImmutableGlyphRunReference

The glyph run.

DrawLine(ImmutablePen, Point, Point)

Draws a line.

public void DrawLine(ImmutablePen pen, Point p1, Point p2)

Parameters

pen ImmutablePen

The stroke pen.

p1 Point

The first point of the line.

p2 Point

The second point of the line.

DrawRectangle(IImmutableBrush?, ImmutablePen?, Rect, double, double, BoxShadows)

Draws a rectangle with the specified Brush and Pen.

public void DrawRectangle(IImmutableBrush? brush, ImmutablePen? pen, Rect rect, double radiusX = 0, double radiusY = 0, BoxShadows boxShadows = default)

Parameters

brush IImmutableBrush

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

pen ImmutablePen

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

rect Rect

The rectangle bounds.

radiusX double

The radius in the X dimension of the rounded corners. This value will be clamped to the range of 0 to Width/2

radiusY double

The radius in the Y dimension of the rounded corners. This value will be clamped to the range of 0 to Height/2

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.

DrawRectangle(ImmutablePen, Rect, float)

Draws the outline of a rectangle.

public void DrawRectangle(ImmutablePen pen, Rect rect, float cornerRadius = 0)

Parameters

pen ImmutablePen

The pen.

rect Rect

The rectangle bounds.

cornerRadius float

The corner radius.

FillRectangle(IImmutableBrush, Rect, float)

Draws a filled rectangle.

public void FillRectangle(IImmutableBrush brush, Rect rect, float cornerRadius = 0)

Parameters

brush IImmutableBrush

The brush.

rect Rect

The rectangle bounds.

cornerRadius float

The corner radius.

PushClip(Rect)

Pushes a clip rectangle.

public ImmediateDrawingContext.PushedState PushClip(Rect clip)

Parameters

clip Rect

The clip rectangle.

Returns

ImmediateDrawingContext.PushedState

A disposable used to undo the clip rectangle.

PushClip(RoundedRect)

public ImmediateDrawingContext.PushedState PushClip(RoundedRect clip)

Parameters

clip RoundedRect

Returns

ImmediateDrawingContext.PushedState

PushOpacity(double, Rect)

Pushes an opacity value.

public ImmediateDrawingContext.PushedState PushOpacity(double opacity, Rect bounds)

Parameters

opacity double

The opacity.

bounds Rect

The bounds.

Returns

ImmediateDrawingContext.PushedState

A disposable used to undo the opacity.

PushOpacityMask(IImmutableBrush, Rect)

Pushes an opacity mask.

public ImmediateDrawingContext.PushedState PushOpacityMask(IImmutableBrush mask, Rect bounds)

Parameters

mask IImmutableBrush

The opacity mask.

bounds Rect

The size of the brush's target area. TODO: Are we sure this is needed?

Returns

ImmediateDrawingContext.PushedState

A disposable to undo the opacity mask.

PushPostTransform(Matrix)

Pushes a matrix post-transformation.

public ImmediateDrawingContext.PushedState PushPostTransform(Matrix matrix)

Parameters

matrix Matrix

The matrix

Returns

ImmediateDrawingContext.PushedState

A disposable used to undo the transformation.

PushPreTransform(Matrix)

Pushes a matrix pre-transformation.

public ImmediateDrawingContext.PushedState PushPreTransform(Matrix matrix)

Parameters

matrix Matrix

The matrix

Returns

ImmediateDrawingContext.PushedState

A disposable used to undo the transformation.

PushSetTransform(Matrix)

Sets the current matrix transformation.

public ImmediateDrawingContext.PushedState PushSetTransform(Matrix matrix)

Parameters

matrix Matrix

The matrix

Returns

ImmediateDrawingContext.PushedState

A disposable used to undo the transformation.

PushTransformContainer()

Pushes a new transform context.

public ImmediateDrawingContext.PushedState PushTransformContainer()

Returns

ImmediateDrawingContext.PushedState

A disposable used to undo the transformation.

TryGetFeature(Type)

Queries for an optional feature.

public object? TryGetFeature(Type type)

Parameters

type Type

Returns

object