Table of Contents

Class DrawingContext

Namespace
Avalonia.Media
Assembly
Avalonia.Base.dll
public abstract class DrawingContext : IDisposable
Inheritance
DrawingContext
Implements
Inherited Members

Methods

Custom(ICustomDrawOperation)

Draws a custom drawing operation

public abstract void Custom(ICustomDrawOperation custom)

Parameters

custom ICustomDrawOperation

custom operation

Dispose()

public void Dispose()

DisposeCore()

protected abstract void DisposeCore()

DrawEllipse(IBrush?, IPen?, Point, double, double)

Draws an ellipse with the specified Brush and Pen.

public void DrawEllipse(IBrush? brush, IPen? pen, Point center, double radiusX, double radiusY)

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.

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.

DrawEllipse(IBrush?, IPen?, Rect)

Draws an ellipse with the specified Brush and Pen.

public 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 bounding rect.

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.

DrawEllipseCore(IBrush?, IPen?, Rect)

protected abstract void DrawEllipseCore(IBrush? brush, IPen? pen, Rect rect)

Parameters

brush IBrush
pen IPen
rect Rect

DrawGeometry(IBrush?, IPen?, Geometry)

Draws a geometry.

public void DrawGeometry(IBrush? brush, IPen? pen, Geometry geometry)

Parameters

brush IBrush

The fill brush.

pen IPen

The stroke pen.

geometry Geometry

The geometry.

DrawGeometry(IBrush?, IPen?, IGeometryImpl)

Draws a geometry.

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

Parameters

brush IBrush

The fill brush.

pen IPen

The stroke pen.

geometry IGeometryImpl

The geometry.

DrawGeometryCore(IBrush?, IPen?, IGeometryImpl)

protected abstract void DrawGeometryCore(IBrush? brush, IPen? pen, IGeometryImpl geometry)

Parameters

brush IBrush
pen IPen
geometry IGeometryImpl

DrawGlyphRun(IBrush?, GlyphRun)

Draws a glyph run.

public abstract void DrawGlyphRun(IBrush? foreground, GlyphRun glyphRun)

Parameters

foreground IBrush

The foreground brush.

glyphRun GlyphRun

The glyph run.

DrawImage(IImage, Rect)

Draws an image.

public virtual void DrawImage(IImage source, Rect rect)

Parameters

source IImage

The image.

rect Rect

The rect in the output to draw to.

DrawImage(IImage, Rect, Rect)

Draws an image.

public virtual void DrawImage(IImage source, Rect sourceRect, Rect destRect)

Parameters

source IImage

The image.

sourceRect Rect

The rect in the image to draw.

destRect Rect

The rect in the output to draw to.

DrawLine(IPen, Point, Point)

Draws a line.

public 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.

DrawLineCore(IPen, Point, Point)

protected abstract void DrawLineCore(IPen pen, Point p1, Point p2)

Parameters

pen IPen
p1 Point
p2 Point

DrawRectangle(IBrush?, IPen?, Rect, double, double, BoxShadows)

Draws a rectangle with the specified Brush and Pen.

public void DrawRectangle(IBrush? brush, IPen? pen, Rect rect, double radiusX = 0, double radiusY = 0, 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 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 stroke is performed. If both the pen and the brush are null, then the drawing is not visible.

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

Draws a rectangle with the specified Brush and Pen.

public void DrawRectangle(IBrush? brush, IPen? pen, RoundedRect rrect, 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.

rrect 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.

DrawRectangle(IPen, Rect, float)

Draws the outline of a rectangle.

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

Parameters

pen IPen

The pen.

rect Rect

The rectangle bounds.

cornerRadius float

The corner radius.

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

protected abstract void DrawRectangleCore(IBrush? brush, IPen? pen, RoundedRect rrect, BoxShadows boxShadows = default)

Parameters

brush IBrush
pen IPen
rrect RoundedRect
boxShadows BoxShadows

DrawText(FormattedText, Point)

Draws text.

public virtual void DrawText(FormattedText text, Point origin)

Parameters

text FormattedText

The text.

origin Point

The upper-left corner of the text.

FillRectangle(IBrush, Rect, float)

Draws a filled rectangle.

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

Parameters

brush IBrush

The brush.

rect Rect

The rectangle bounds.

cornerRadius float

The corner radius.

PopClipCore()

protected abstract void PopClipCore()

PopGeometryClipCore()

protected abstract void PopGeometryClipCore()

PopOpacityCore()

protected abstract void PopOpacityCore()

PopOpacityMaskCore()

protected abstract void PopOpacityMaskCore()

PopRenderOptionsCore()

protected abstract void PopRenderOptionsCore()

PopTransformCore()

protected abstract void PopTransformCore()

PushClip(Rect)

Pushes a clip rectangle.

public DrawingContext.PushedState PushClip(Rect clip)

Parameters

clip Rect

The clip rectangle.

Returns

DrawingContext.PushedState

A disposable used to undo the clip rectangle.

PushClip(RoundedRect)

Pushes a clip rectangle.

public DrawingContext.PushedState PushClip(RoundedRect clip)

Parameters

clip RoundedRect

The clip rectangle.

Returns

DrawingContext.PushedState

A disposable used to undo the clip rectangle.

PushClipCore(Rect)

protected abstract void PushClipCore(Rect rect)

Parameters

rect Rect

PushClipCore(RoundedRect)

protected abstract void PushClipCore(RoundedRect rect)

Parameters

rect RoundedRect

PushGeometryClip(Geometry)

Pushes a clip geometry.

public DrawingContext.PushedState PushGeometryClip(Geometry clip)

Parameters

clip Geometry

The clip geometry.

Returns

DrawingContext.PushedState

A disposable used to undo the clip geometry.

PushGeometryClipCore(Geometry)

protected abstract void PushGeometryClipCore(Geometry clip)

Parameters

clip Geometry

PushOpacity(double)

Pushes an opacity value.

public DrawingContext.PushedState PushOpacity(double opacity)

Parameters

opacity double

The opacity.

Returns

DrawingContext.PushedState

A disposable used to undo the opacity.

PushOpacityCore(double)

protected abstract void PushOpacityCore(double opacity)

Parameters

opacity double

PushOpacityMask(IBrush, Rect)

Pushes an opacity mask.

public DrawingContext.PushedState PushOpacityMask(IBrush mask, Rect bounds)

Parameters

mask IBrush

The opacity mask.

bounds Rect

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

Returns

DrawingContext.PushedState

A disposable to undo the opacity mask.

PushOpacityMaskCore(IBrush, Rect)

protected abstract void PushOpacityMaskCore(IBrush mask, Rect bounds)

Parameters

mask IBrush
bounds Rect

PushRenderOptions(RenderOptions)

Pushes render options.

public DrawingContext.PushedState PushRenderOptions(RenderOptions renderOptions)

Parameters

renderOptions RenderOptions

The render options.

Returns

DrawingContext.PushedState

A disposable to undo the render options.

PushRenderOptionsCore(RenderOptions)

protected abstract void PushRenderOptionsCore(RenderOptions renderOptions)

Parameters

renderOptions RenderOptions

PushTransform(Matrix)

Pushes a matrix transformation.

public DrawingContext.PushedState PushTransform(Matrix matrix)

Parameters

matrix Matrix

The matrix

Returns

DrawingContext.PushedState

A disposable used to undo the transformation.

PushTransformCore(Matrix)

protected abstract void PushTransformCore(Matrix matrix)

Parameters

matrix Matrix