Skip to main content

ImmediateDrawingContext Class

Definition​

Namespace:Avalonia.Media
Assembly:Avalonia.Base
Package:Avalonia
public class ImmediateDrawingContext

Inheritance: object -> ImmediateDrawingContext

Implements: IOptionalFeatureProvider, IDisposable

Methods​

NameDescription
DisposeDisposes of any resources held by the Avalonia.Media.DrawingContext.
DrawBitmap (2 overloads)Draws an bitmap.
DrawEllipseDraws an ellipse with the specified Brush and Pen.
DrawGlyphRunDraws a glyph run.
DrawLineDraws a line.
DrawRectangle (2 overloads)Draws a rectangle with the specified Brush and Pen.
FillRectangleDraws a filled rectangle.
PushClip (2 overloads)Pushes a clip rectangle.
PushOpacityPushes an opacity value.
PushOpacityMaskPushes an opacity mask.
PushPostTransformPushes a matrix post-transformation.
PushPreTransformPushes a matrix pre-transformation.
PushSetTransformSets the current matrix transformation.
PushTransformContainerPushes a new transform context.
TryGetFeatureNo summary available.

Dispose Method​

Disposes of any resources held by the Avalonia.Media.DrawingContext.

public void Dispose()

DrawBitmap overloads​

DrawBitmap Method​

Draws an bitmap.

public void DrawBitmap(Avalonia.Media.Imaging.Bitmap source, Avalonia.Rect rect)
Parameters​

source Avalonia.Media.Imaging.Bitmap

The bitmap.

rect Avalonia.Rect

The rect in the output to draw to.

DrawBitmap Method​

Draws an image.

public void DrawBitmap(Avalonia.Media.Imaging.Bitmap source, Avalonia.Rect sourceRect, Avalonia.Rect destRect)
Parameters​

source Avalonia.Media.Imaging.Bitmap

The bitmap.

sourceRect Avalonia.Rect

The rect in the image to draw.

destRect Avalonia.Rect

The rect in the output to draw to.

DrawEllipse Method​

Draws an ellipse with the specified Brush and Pen.

public void DrawEllipse(Avalonia.Media.IImmutableBrush brush, Avalonia.Media.Immutable.ImmutablePen pen, Avalonia.Point center, double radiusX, double radiusY)

Parameters​

brush Avalonia.Media.IImmutableBrush

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

pen Avalonia.Media.Immutable.ImmutablePen

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

center Avalonia.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 Method​

Draws a glyph run.

public void DrawGlyphRun(Avalonia.Media.IImmutableBrush foreground, Avalonia.Media.IImmutableGlyphRunReference glyphRun)

Parameters​

foreground Avalonia.Media.IImmutableBrush

The foreground brush.

glyphRun Avalonia.Media.IImmutableGlyphRunReference

The glyph run.

DrawLine Method​

Draws a line.

public void DrawLine(Avalonia.Media.Immutable.ImmutablePen pen, Avalonia.Point p1, Avalonia.Point p2)

Parameters​

pen Avalonia.Media.Immutable.ImmutablePen

The stroke pen.

p1 Avalonia.Point

The first point of the line.

p2 Avalonia.Point

The second point of the line.

DrawRectangle overloads​

DrawRectangle Method​

Draws a rectangle with the specified Brush and Pen.

public void DrawRectangle(Avalonia.Media.IImmutableBrush brush, Avalonia.Media.Immutable.ImmutablePen pen, Avalonia.Rect rect, double radiusX, double radiusY, Avalonia.Media.BoxShadows boxShadows)
Parameters​

brush Avalonia.Media.IImmutableBrush

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

pen Avalonia.Media.Immutable.ImmutablePen

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

rect Avalonia.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 Avalonia.Media.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 Method​

Draws the outline of a rectangle.

public void DrawRectangle(Avalonia.Media.Immutable.ImmutablePen pen, Avalonia.Rect rect, float cornerRadius)
Parameters​

pen Avalonia.Media.Immutable.ImmutablePen

The pen.

rect Avalonia.Rect

The rectangle bounds.

cornerRadius float

The corner radius.

FillRectangle Method​

Draws a filled rectangle.

public void FillRectangle(Avalonia.Media.IImmutableBrush brush, Avalonia.Rect rect, float cornerRadius)

Parameters​

brush Avalonia.Media.IImmutableBrush

The brush.

rect Avalonia.Rect

The rectangle bounds.

cornerRadius float

The corner radius.

PushClip overloads​

PushClip Method​

Pushes a clip rectangle.

public Avalonia.Media.ImmediateDrawingContext.PushedState PushClip(Avalonia.Rect clip)
Parameters​

clip Avalonia.Rect

The clip rectangle.

Returns​

Avalonia.Media.ImmediateDrawingContext.PushedState

A disposable used to undo the clip rectangle.

PushClip Method​

public Avalonia.Media.ImmediateDrawingContext.PushedState PushClip(Avalonia.RoundedRect clip)
Parameters​

clip Avalonia.RoundedRect

Returns​

Avalonia.Media.ImmediateDrawingContext.PushedState

PushOpacity Method​

Pushes an opacity value.

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

Parameters​

opacity double

The opacity.

bounds Avalonia.Rect

The bounds.

Returns​

Avalonia.Media.ImmediateDrawingContext.PushedState

A disposable used to undo the opacity.

PushOpacityMask Method​

Pushes an opacity mask.

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

Parameters​

mask Avalonia.Media.IImmutableBrush

The opacity mask.

bounds Avalonia.Rect

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

Returns​

Avalonia.Media.ImmediateDrawingContext.PushedState

A disposable to undo the opacity mask.

PushPostTransform Method​

Pushes a matrix post-transformation.

public Avalonia.Media.ImmediateDrawingContext.PushedState PushPostTransform(Avalonia.Matrix matrix)

Parameters​

matrix Avalonia.Matrix

The matrix

Returns​

Avalonia.Media.ImmediateDrawingContext.PushedState

A disposable used to undo the transformation.

PushPreTransform Method​

Pushes a matrix pre-transformation.

public Avalonia.Media.ImmediateDrawingContext.PushedState PushPreTransform(Avalonia.Matrix matrix)

Parameters​

matrix Avalonia.Matrix

The matrix

Returns​

Avalonia.Media.ImmediateDrawingContext.PushedState

A disposable used to undo the transformation.

PushSetTransform Method​

Sets the current matrix transformation.

public Avalonia.Media.ImmediateDrawingContext.PushedState PushSetTransform(Avalonia.Matrix matrix)

Parameters​

matrix Avalonia.Matrix

The matrix

Returns​

Avalonia.Media.ImmediateDrawingContext.PushedState

A disposable used to undo the transformation.

PushTransformContainer Method​

Pushes a new transform context.

public Avalonia.Media.ImmediateDrawingContext.PushedState PushTransformContainer()

Returns​

Avalonia.Media.ImmediateDrawingContext.PushedState

A disposable used to undo the transformation.

TryGetFeature Method​

public object TryGetFeature(Type type)

Parameters​

type Type

Returns​

object

Properties​

NameDescription
CurrentTransformGets the current transform of the drawing context.
PlatformImplNo summary available.

CurrentTransform Property​

Gets the current transform of the drawing context.

public Avalonia.Matrix CurrentTransform { get; set; }

PlatformImpl Property​

public Avalonia.Platform.IDrawingContextImpl PlatformImpl { get; set; }