diff --git a/src/Graphics/src/Graphics/ICanvas.cs b/src/Graphics/src/Graphics/ICanvas.cs index ede7111d1f59..bc25bdacae45 100644 --- a/src/Graphics/src/Graphics/ICanvas.cs +++ b/src/Graphics/src/Graphics/ICanvas.cs @@ -3,54 +3,236 @@ namespace Microsoft.Maui.Graphics { + /// + /// Represents a platform-agnostic canvas on which 2D graphics can be drawn using types from the namespace. + /// public interface ICanvas { + /// + /// Gets or sets a value that represents the scaling factor to scale the UI by. + /// public float DisplayScale { get; set; } + + /// + /// Sets the width of the stroke used to draw an object's outline. + /// public float StrokeSize { set; } + + /// + /// Sets the limit of the miter length of line joins in an object. + /// public float MiterLimit { set; } + + /// + /// Sets the used to paint an object's outline. + /// public Color StrokeColor { set; } + + /// + /// Sets the shape at the start and end of a line. + /// public LineCap StrokeLineCap { set; } + + /// + /// Sets the type of join used at the vertices of a shape. + /// public LineJoin StrokeLineJoin { set; } + + /// + /// Sets the pattern of dashes and gaps that are used to outline an object. + /// public float[] StrokeDashPattern { set; } + + /// + /// Sets the distance within the dash pattern where a dash begins. + /// public float StrokeDashOffset { set; } + + /// + /// Sets the color used to paint an object's interior. + /// public Color FillColor { set; } + + /// + /// Sets the font color when drawing text. + /// public Color FontColor { set; } + + /// + /// Sets the font used when drawing text. + /// public IFont Font { set; } + + /// + /// Sets the size of the font used when drawing text. + /// public float FontSize { set; } + + /// + /// Sets the opacity of am object. + /// public float Alpha { set; } + + /// + /// Sets a value that indicates whether to use anti-aliasing is enabled. + /// public bool Antialias { set; } + + /// + /// Sets the blend mode, which determines what happens when an object is rendered on top of an existing object. + /// public BlendMode BlendMode { set; } + /// + /// Draws the specified onto the canvas. + /// + /// The path to be drawn. public void DrawPath(PathF path); + /// + /// Draws and fills the specified onto the canvas. + /// + /// The path to be drawn. + /// The fill algorithm to be used. public void FillPath(PathF path, WindingMode windingMode); + /// + /// Clips an object so that only the area outside the of a rectangle will be visible. + /// + /// Starting x coordinate of the rectangle. + /// Starting y coordinate of the rectangle. + /// Width of the rectangle. + /// Height of the rectangle. public void SubtractFromClip(float x, float y, float width, float height); + /// + /// Clips an object so that only the area outside of a object will be visible. + /// + /// The path used to clip the object + /// Fill algorithm used for the path. Default is . public void ClipPath(PathF path, WindingMode windingMode = WindingMode.NonZero); + /// + /// Clips an object so that only the area that's within the region of the rectangle will be visible. + /// + /// Starting x coordinate of the rectangle. + /// Starting y coordinate of the rectangle. + /// Width of the rectangle. + /// Height of the rectangle. public void ClipRectangle(float x, float y, float width, float height); + /// + /// Draws a line between two points onto the canvas. + /// + /// Starting x coordinate. + /// Starting y coordinate. + /// Ending x coordinate. + /// Ending x coordinate. public void DrawLine(float x1, float y1, float x2, float y2); + /// + /// Draws an arc onto the canvas. + /// + /// Starting x coordinate. + /// Starting y coordinate. + /// Width of the arc. + /// Height of the arc. + /// The angle from the x-axis to the start point of the arc. + /// The angle from the x-axis to the end point of the arc. + /// to draw the arc in a clockwise direction; to draw the arc counterclockwise. + /// to specify whether the end point of the arc will be connected to the start point; otherwise. public void DrawArc(float x, float y, float width, float height, float startAngle, float endAngle, bool clockwise, bool closed); + /// + /// Draws a filled arc onto the canvas. + /// + /// Starting x coordinate. + /// Starting y coordinate. + /// Width of the arc. + /// Height of the arc. + /// The angle from the x-axis to the start point of the arc. + /// The angle from the x-axis to the end point of the arc. + /// to draw the arc in a clockwise direction; to draw the arc counterclockwise. public void FillArc(float x, float y, float width, float height, float startAngle, float endAngle, bool clockwise); + /// + /// Draws a rectangle onto the canvas. + /// + /// Starting x coordinate. + /// Starting y coordinate. + /// Width of the rectangle. + /// Height of the rectangle. public void DrawRectangle(float x, float y, float width, float height); + /// + /// Draws a filled rectangle onto the canvas. + /// + /// Starting x coordinate. + /// Starting y coordinate. + /// Width of the rectangle. + /// Height of the rectangle. public void FillRectangle(float x, float y, float width, float height); + /// + /// Draws a rectangle with rounded corners onto the canvas. + /// + /// Starting x coordinate. + /// Starting y coordinate. + /// Width of the rectangle. + /// Height of the rectangle. + /// The radius used to round the corners of the rectangle. public void DrawRoundedRectangle(float x, float y, float width, float height, float cornerRadius); + /// + /// Draws a filled rectangle with rounded corners onto the canvas. + /// + /// Starting x coordinate. + /// Starting y coordinate. + /// Width of the rectangle. + /// Height of the rectangle. + /// The radius used to round the corners of the rectangle. public void FillRoundedRectangle(float x, float y, float width, float height, float cornerRadius); + /// + /// Draws an ellipse onto the canvas. + /// + /// Starting x coordinate. + /// Starting y coordinate. + /// Width of the ellipse. + /// Height of the ellipse. public void DrawEllipse(float x, float y, float width, float height); + /// + /// Draws a filled ellipse onto the canvas. + /// + /// Starting x coordinate. + /// Starting y coordinate. + /// Width of the ellipse. + /// Height of the ellipse. public void FillEllipse(float x, float y, float width, float height); + /// + /// Draws a text string onto the canvas. + /// + /// To draw attributed text, use instead. + /// Text to be displayed. + /// Starting x coordinate. + /// Starting y coordinate. + /// Horizontal alignment options to align the string. public void DrawString(string value, float x, float y, HorizontalAlignment horizontalAlignment); + /// + /// Draws a text string within a bounding box onto the canvas. + /// + /// Text to be displayed. + /// Starting x coordinate of the bounding box. + /// Starting y coordinate of the bounding box. + /// Width of the bounding box. + /// Height of the bounding box. + /// Horizontal alignment options to align the string within the bounding box. + /// Vertical alignment options to align the string within the bounding box. + /// Specifies whether text will be clipped in case it overflows the bounding box. Default is . + /// Spacing adjustment between lines. Default is 0. public void DrawString( string value, float x, @@ -62,6 +244,14 @@ public void DrawString( TextFlow textFlow = TextFlow.ClipBounds, float lineSpacingAdjustment = 0); + /// + /// Draws attributed text within a bounding box onto the canvas. + /// + /// Attributed text to be displayed. + /// Starting x coordinate of the bounding box. + /// Starting y coordinate of the bounding box. + /// Width of the bounding box. + /// Height of the bounding box. public void DrawText( IAttributedText value, float x, @@ -69,30 +259,102 @@ public void DrawText( float width, float height); + /// + /// Rotates a graphical object around a point. + /// + /// Rotation is clockwise for increasing angles. Negative angles and angles greater than 360 are allowed. + /// Rotation angle. + /// x coordinate of the rotation point. + /// y coordinate of the rotation point. public void Rotate(float degrees, float x, float y); + /// + /// Rotates a graphical object around the upper-left corner of the canvas (0,0). + /// + /// Rotation is clockwise for increasing angles. Negative angles and angles greater than 360 are allowed. public void Rotate(float degrees); + + /// + /// Changes the size of a graphical object by scaling it. + /// + /// Can cause starting coordinates to move when an object is made larger. + /// Value for horizontal scaling. + /// Value for vertical scaling. public void Scale(float sx, float sy); + /// + /// Shifts a graphical object in horizontal and vertical directions. + /// + /// Horizontal shift. Negative values move the object to the left, while positive values move it to the right. + /// Vertical shift. Negative values move the object down, while positive values move it up. public void Translate(float tx, float ty); + /// + /// Applies transformation specified by to a graphical object. + /// + /// Affine transformation matrix. public void ConcatenateTransform(Matrix3x2 transform); + /// + /// Saves the current graphics state. + /// public void SaveState(); + /// + /// Restores the graphics state to the most recently saved state. + /// + /// if the restore was succesful, otherwise. public bool RestoreState(); + /// + /// Resets the graphics state to its default values. + /// public void ResetState(); + /// + /// Adds a shadow to a graphical object. + /// + /// Represents the position of a light source that creates the shadow. + /// Amount of blur to apply to the shadow. + /// Color of the shadow. public void SetShadow(SizeF offset, float blur, Color color); + /// + /// Sets as the fill of a graphical object. + /// + /// Paint to set as fill + /// Rectangle to apply a gradient on if the supports it. public void SetFillPaint(Paint paint, RectF rectangle); + /// + /// Draws an image onto the canvas. + /// + /// Image to display + /// Top left corner x coordinate. + /// Top left corner y coordinate. + /// Width of the image. + /// Height of the image. public void DrawImage(IImage image, float x, float y, float width, float height); + /// + /// Calculates the area a string would occupy if drawn on the canvas. + /// + /// String to calculate the size on. + /// The string's font type. + /// The string's font size. + /// The area the string would occupy on the canvas. public SizeF GetStringSize(string value, IFont font, float fontSize); + /// + /// Calculates the area a string would occupy if drawn on the canvas. + /// + /// String to calculate the size on. + /// The string's font type. + /// The string's font size. + /// Horizontal alignment options for the string. + /// Vertical alignment options for the string. + /// The area the string would occupy on the canvas. public SizeF GetStringSize(string value, IFont font, float fontSize, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment); } }