Share via


ICanvas Interface

Definition

Represents a platform-agnostic canvas on which 2D graphics can be drawn using types from the Microsoft.Maui.Graphics namespace.

public interface class ICanvas
public interface ICanvas
type ICanvas = interface
Public Interface ICanvas
Derived

Properties

Alpha

Sets the opacity of am object.

Antialias

Sets a value that indicates whether to use anti-aliasing is enabled.

BlendMode

Sets the blend mode, which determines what happens when an object is rendered on top of an existing object.

DisplayScale

Gets or sets a value that represents the scaling factor to scale the UI by.

FillColor

Sets the color used to paint an object's interior.

Font

Sets the font used when drawing text.

FontColor

Sets the font color when drawing text.

FontSize

Sets the size of the font used when drawing text.

MiterLimit

Sets the limit of the miter length of line joins in an object.

StrokeColor

Sets the Color used to paint an object's outline.

StrokeDashOffset

Sets the distance within the dash pattern where a dash begins.

StrokeDashPattern

Sets the pattern of dashes and gaps that are used to outline an object.

StrokeLineCap

Sets the shape at the start and end of a line.

StrokeLineJoin

Sets the type of join used at the vertices of a shape.

StrokeSize

Sets the width of the stroke used to draw an object's outline.

Methods

ClipPath(PathF, WindingMode)

Clips an object so that only the area that's within the region of a PathF object will be visible.

ClipRectangle(Single, Single, Single, Single)

Clips an object so that only the area that's within the region of the rectangle will be visible.

ConcatenateTransform(Matrix3x2)

Applies transformation specified by transform to a graphical object.

DrawArc(Single, Single, Single, Single, Single, Single, Boolean, Boolean)

Draws an arc onto the canvas.

DrawEllipse(Single, Single, Single, Single)

Draws an ellipse onto the canvas.

DrawImage(IImage, Single, Single, Single, Single)

Draws an image onto the canvas.

DrawLine(Single, Single, Single, Single)

Draws a line between two points onto the canvas.

DrawPath(PathF)

Draws the specified path onto the canvas.

DrawRectangle(Single, Single, Single, Single)

Draws a rectangle onto the canvas.

DrawRoundedRectangle(Single, Single, Single, Single, Single)

Draws a rectangle with rounded corners onto the canvas.

DrawString(String, Single, Single, HorizontalAlignment)

Draws a text string onto the canvas.

DrawString(String, Single, Single, Single, Single, HorizontalAlignment, VerticalAlignment, TextFlow, Single)

Draws a text string within a bounding box onto the canvas.

DrawText(IAttributedText, Single, Single, Single, Single)

Draws attributed text within a bounding box onto the canvas.

FillArc(Single, Single, Single, Single, Single, Single, Boolean)

Draws a filled arc onto the canvas.

FillEllipse(Single, Single, Single, Single)

Draws a filled ellipse onto the canvas.

FillPath(PathF, WindingMode)

Draws and fills the specified path onto the canvas.

FillRectangle(Single, Single, Single, Single)

Draws a filled rectangle onto the canvas.

FillRoundedRectangle(Single, Single, Single, Single, Single)

Draws a filled rectangle with rounded corners onto the canvas.

GetStringSize(String, IFont, Single, HorizontalAlignment, VerticalAlignment)

Calculates the area a string would occupy if drawn on the canvas.

GetStringSize(String, IFont, Single)

Calculates the area a string would occupy if drawn on the canvas.

ResetState()

Resets the graphics state to its default values.

RestoreState()

Restores the graphics state to the most recently saved state.

Rotate(Single, Single, Single)

Rotates a graphical object around a point.

Rotate(Single)

Rotates a graphical object around the upper-left corner of the canvas (0,0).

SaveState()

Saves the current graphics state.

Scale(Single, Single)

Changes the size of a graphical object by scaling it.

SetFillPaint(Paint, RectF)

Sets paint as the fill of a graphical object.

SetShadow(SizeF, Single, Color)

Adds a shadow to a graphical object.

SubtractFromClip(Single, Single, Single, Single)

Clips an object so that only the area outside the of a rectangle will be visible.

Translate(Single, Single)

Shifts a graphical object in horizontal and vertical directions.

Extension Methods

ClipPath(ICanvas, PathF, WindingMode)
ClipRectangle(ICanvas, Rect)
ClipRectangle(ICanvas, RectF)
DrawArc(ICanvas, Rect, Single, Single, Boolean, Boolean)

Draws the arc. This is a helper method to draw an arc when you have a rectangle already defined for the ellipse bounds.

DrawArc(ICanvas, RectF, Single, Single, Boolean, Boolean)

Draws the arc. This is a helper method to draw an arc when you have a rectangle already defined for the ellipse bounds.

DrawCircle(ICanvas, Point, Double)
DrawCircle(ICanvas, PointF, Single)
DrawCircle(ICanvas, Single, Single, Single)
DrawEllipse(ICanvas, Rect)
DrawEllipse(ICanvas, RectF)
DrawLine(ICanvas, PointF, PointF)
DrawPath(ICanvas, PathF)
DrawRectangle(ICanvas, Rect)
DrawRectangle(ICanvas, RectF)
DrawRoundedRectangle(ICanvas, Rect, Double, Double, Double, Double)
DrawRoundedRectangle(ICanvas, Rect, Double)
DrawRoundedRectangle(ICanvas, RectF, Single, Single, Single, Single)
DrawRoundedRectangle(ICanvas, RectF, Single, Single)
DrawRoundedRectangle(ICanvas, RectF, Single)
DrawRoundedRectangle(ICanvas, Single, Single, Single, Single, Single, Single, Single, Single)
DrawString(ICanvas, String, Rect, HorizontalAlignment, VerticalAlignment, TextFlow, Single)
DrawString(ICanvas, String, RectF, HorizontalAlignment, VerticalAlignment, TextFlow, Single)
EnableDefaultShadow(ICanvas, Single)

Enables the default shadow.

FillArc(ICanvas, Rect, Single, Single, Boolean)

Fills the arc. This is a helper method to fill an arc when you have a rectangle already defined for the ellipse bounds.

FillArc(ICanvas, RectF, Single, Single, Boolean)

Fills the arc. This is a helper method to fill an arc when you have a rectangle already defined for the ellipse bounds.

FillArc(ICanvas, Single, Single, Single, Single, Single, Single, Paint, Boolean)

Fills the arc with the specified paint. This is a helper method for when filling an arc with a gradient, so that you don't need to worry about calculating the gradient handle locations based on the rectangle size and location.

FillCircle(ICanvas, Point, Double)
FillCircle(ICanvas, PointF, Single)
FillCircle(ICanvas, Single, Single, Single)
FillEllipse(ICanvas, Rect)
FillEllipse(ICanvas, RectF)
FillPath(ICanvas, PathF, WindingMode)
FillPath(ICanvas, PathF)
FillRectangle(ICanvas, Rect)
FillRectangle(ICanvas, RectF)
FillRoundedRectangle(ICanvas, Rect, Double, Double, Double, Double)
FillRoundedRectangle(ICanvas, Rect, Double)
FillRoundedRectangle(ICanvas, RectF, Single, Single, Single, Single)
FillRoundedRectangle(ICanvas, RectF, Single, Single)
FillRoundedRectangle(ICanvas, RectF, Single)
FillRoundedRectangle(ICanvas, Single, Single, Single, Single, Single, Single, Single, Single)
ResetStroke(ICanvas)

Resets the stroke to the default settings:

  • Stroke Size: 1
  • Stroke Dash Pattern: None
  • Stroke Location: Center
  • Stroke Line Join: Miter
  • Stroke Line Cap: Butt
  • Stroke Brush: None
  • Stroke Color: Black
SetFillPaint(ICanvas, Paint, Point, Point)
SetFillPaint(ICanvas, Paint, PointF, PointF)
SetFillPaint(ICanvas, Paint, Rect)
SetFillPaint(ICanvas, Paint, RectF)
SetFillPattern(ICanvas, IPattern, Color)
SetFillPattern(ICanvas, IPattern)
SubtractFromClip(ICanvas, Rect)
SubtractFromClip(ICanvas, RectF)
SetFillImage(ICanvas, IImage)

Applies to