CanvasRenderingContext2DBase Class
The members shared by the 2D rendering contexts of the canvases (https://html.spec.whatwg.org/multipage/canvas.html#2dcontext): CanvasRenderingContext2D (canvas.getContext("2d")) and OffscreenCanvasRenderingContext2D.
public abstract class CanvasRenderingContext2DBaseRemarks
The library implements the state, the paths, the styles, the text layout (with the managed font reader and text shaping) and the drawing model of the canvas (https://html.spec.whatwg.org/multipage/canvas.html#drawing-model); each drawing operation is a small display list (the clip region, the shadow, the compositing operator and the filters, then the shape in the coordinates of the current transformation matrix), rasterized on the bitmap of the canvas by the rendering backend (BrowsingContextOptions.RenderingBackend). Without a backend there is no context: getContext("2d") returns null.
The paths and the text are stored as the specification describes them: the current default path in the coordinates of the canvas (its points are transformed when they are added), a Path2D in the coordinates where it is drawn.
See also
Properties
| Name | Description |
|---|---|
| Direction | Gets or sets the direction of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-direction). |
| FillStyle | Gets or sets the style of the fills (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fillstyle): a CSS color (serialized when it is read), a CanvasGradient or a CanvasPattern. The strings that are not colors are ignored. |
| Filter | Gets or sets the filter of the drawing operations (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-filter): none or a list of CSS filter functions (the lengths are resolved against the current font), or a CanvasFilter (a proposal, https://github.com/whatwg/html/issues/5621); the strings that are not filters and null are ignored. The references to SVG filter elements (url()) are resolved in the document of the canvas element (an OffscreenCanvas does not filter its drawings with them). |
| Font | Gets or sets the font (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-font): a value of the CSS font shorthand (the relative values are resolved against the font of the canvas element, or 10px sans-serif), serialized with its size in px and without line height. The values that cannot be parsed are ignored. Setting the font resets CanvasRenderingContext2DBase.FontStretch and CanvasRenderingContext2DBase.FontVariantCaps to the values of the shorthand (as in the browsers, CanvasRenderingContext2DBase.FontKerning is kept). |
| FontKerning | Gets or sets the kerning of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontkerning). |
| FontStretch | Gets or sets the width of the font (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontstretch). |
| FontVariantCaps | Gets or sets the capitals of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontvariantcaps): the OpenType features of the capitals (the small capitals are not synthesized). |
| GlobalAlpha | Gets or sets the alpha applied to the drawing operations (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-globalalpha): the values outside of [0, 1] are ignored. |
| GlobalCompositeOperation | Gets or sets the compositing operator or the blend mode of the drawing operations (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-globalcompositeoperation): a value of <blend-mode> or of the Porter-Duff operators of Compositing and Blending; the other values are ignored. |
| ImageSmoothingEnabled | Gets or sets whether the images are smoothed when they are scaled (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-imagesmoothingenabled). |
| ImageSmoothingQuality | Gets or sets the quality of the image smoothing (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-imagesmoothingquality). |
| Lang | Gets or sets the language of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-lang): a BCP 47 language tag, or inherit. |
| LetterSpacing | Gets or sets the spacing between the letters (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-letterspacing): a CSS length (the font-relative lengths are resolved against the current font when the text is drawn); other values are ignored. |
| LineCap | Gets or sets the shape of the ends of the lines (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linecap). |
| LineDashOffset | Gets or sets the phase of the dash list (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linedashoffset): non-finite values are ignored. |
| LineJoin | Gets or sets the shape of the corners of the lines (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linejoin). |
| LineWidth | Gets or sets the width of the lines (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linewidth): zero, negative and non-finite values are ignored. |
| MiterLimit | Gets or sets the miter limit ratio (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-miterlimit): zero, negative and non-finite values are ignored. |
| ShadowBlur | Gets or sets the blur of the shadows (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowblur): the negative values are ignored. |
| ShadowColor | Gets or sets the color of the shadows (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowcolor): the strings that are not colors are ignored. |
| ShadowOffsetX | Gets or sets the horizontal offset of the shadows (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowoffsetx). |
| ShadowOffsetY | Gets or sets the vertical offset of the shadows (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowoffsety). |
| StrokeStyle | Gets or sets the style of the strokes (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-strokestyle): a CSS color (serialized when it is read), a CanvasGradient or a CanvasPattern. The strings that are not colors are ignored. |
| TextAlign | Gets or sets the alignment of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textalign). |
| TextBaseline | Gets or sets the baseline of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textbaseline). |
| TextRendering | Gets or sets the rendering hint of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textrendering): optimizeSpeed disables the kerning, as text-rendering. |
| WordSpacing | Gets or sets the spacing between the words (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-wordspacing): a CSS length (the font-relative lengths are resolved against the current font when the text is drawn); other values are ignored. |
Direction
CanvasRenderingContext2DBase.Text.csGets or sets the direction of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-direction).
public CanvasDirection Direction { get; set; }FillStyle
CanvasRenderingContext2DBase.csGets or sets the style of the fills (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fillstyle): a CSS color (serialized when it is read), a CanvasGradient or a CanvasPattern. The strings that are not colors are ignored.
public object FillStyle { get; set; }Property value
See also
Gets or sets the filter of the drawing operations (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-filter): none or a list of CSS filter functions (the lengths are resolved against the current font), or a CanvasFilter (a proposal, https://github.com/whatwg/html/issues/5621); the strings that are not filters and null are ignored. The references to SVG filter elements (url()) are resolved in the document of the canvas element (an OffscreenCanvas does not filter its drawings with them).
public object Filter { get; set; }Gets or sets the font (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-font): a value of the CSS font shorthand (the relative values are resolved against the font of the canvas element, or 10px sans-serif), serialized with its size in px and without line height. The values that cannot be parsed are ignored. Setting the font resets CanvasRenderingContext2DBase.FontStretch and CanvasRenderingContext2DBase.FontVariantCaps to the values of the shorthand (as in the browsers, CanvasRenderingContext2DBase.FontKerning is kept).
public string Font { get; set; }FontKerning
CanvasRenderingContext2DBase.Text.csGets or sets the kerning of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontkerning).
public CanvasFontKerning FontKerning { get; set; }FontStretch
CanvasRenderingContext2DBase.Text.csGets or sets the width of the font (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontstretch).
public CanvasFontStretch FontStretch { get; set; }FontVariantCaps
CanvasRenderingContext2DBase.Text.csGets or sets the capitals of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fontvariantcaps): the OpenType features of the capitals (the small capitals are not synthesized).
public CanvasFontVariantCaps FontVariantCaps { get; set; }GlobalAlpha
CanvasRenderingContext2DBase.csGets or sets the alpha applied to the drawing operations (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-globalalpha): the values outside of [0, 1] are ignored.
public double GlobalAlpha { get; set; }Property value
See also
GlobalCompositeOperation
CanvasRenderingContext2DBase.csGets or sets the compositing operator or the blend mode of the drawing operations (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-globalcompositeoperation): a value of <blend-mode> or of the Porter-Duff operators of Compositing and Blending; the other values are ignored.
public string GlobalCompositeOperation { get; set; }ImageSmoothingEnabled
CanvasRenderingContext2DBase.csGets or sets whether the images are smoothed when they are scaled (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-imagesmoothingenabled).
public bool ImageSmoothingEnabled { get; set; }ImageSmoothingQuality
CanvasRenderingContext2DBase.csGets or sets the quality of the image smoothing (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-imagesmoothingquality).
public ImageSmoothingQuality ImageSmoothingQuality { get; set; }Gets or sets the language of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-lang): a BCP 47 language tag, or inherit.
public string Lang { get; set; }LetterSpacing
CanvasRenderingContext2DBase.Text.csGets or sets the spacing between the letters (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-letterspacing): a CSS length (the font-relative lengths are resolved against the current font when the text is drawn); other values are ignored.
public string LetterSpacing { get; set; }Property value
See also
Gets or sets the shape of the ends of the lines (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linecap).
public CanvasLineCap LineCap { get; set; }Property value
See also
LineDashOffset
CanvasRenderingContext2DBase.csGets or sets the phase of the dash list (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linedashoffset): non-finite values are ignored.
public double LineDashOffset { get; set; }Property value
See also
LineJoin
CanvasRenderingContext2DBase.csGets or sets the shape of the corners of the lines (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linejoin).
public CanvasLineJoin LineJoin { get; set; }Property value
See also
LineWidth
CanvasRenderingContext2DBase.csGets or sets the width of the lines (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-linewidth): zero, negative and non-finite values are ignored.
public double LineWidth { get; set; }Property value
See also
MiterLimit
CanvasRenderingContext2DBase.csGets or sets the miter limit ratio (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-miterlimit): zero, negative and non-finite values are ignored.
public double MiterLimit { get; set; }Property value
See also
ShadowBlur
CanvasRenderingContext2DBase.csGets or sets the blur of the shadows (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowblur): the negative values are ignored.
public double ShadowBlur { get; set; }Property value
See also
ShadowColor
CanvasRenderingContext2DBase.csGets or sets the color of the shadows (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowcolor): the strings that are not colors are ignored.
public string ShadowColor { get; set; }Property value
See also
ShadowOffsetX
CanvasRenderingContext2DBase.csGets or sets the horizontal offset of the shadows (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowoffsetx).
public double ShadowOffsetX { get; set; }Property value
See also
ShadowOffsetY
CanvasRenderingContext2DBase.csGets or sets the vertical offset of the shadows (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-shadowoffsety).
public double ShadowOffsetY { get; set; }Property value
See also
StrokeStyle
CanvasRenderingContext2DBase.csGets or sets the style of the strokes (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-strokestyle): a CSS color (serialized when it is read), a CanvasGradient or a CanvasPattern. The strings that are not colors are ignored.
public object StrokeStyle { get; set; }Property value
See also
TextAlign
CanvasRenderingContext2DBase.Text.csGets or sets the alignment of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textalign).
public CanvasTextAlign TextAlign { get; set; }TextBaseline
CanvasRenderingContext2DBase.Text.csGets or sets the baseline of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textbaseline).
public CanvasTextBaseline TextBaseline { get; set; }TextRendering
CanvasRenderingContext2DBase.Text.csGets or sets the rendering hint of the texts (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-textrendering): optimizeSpeed disables the kerning, as text-rendering.
public CanvasTextRendering TextRendering { get; set; }WordSpacing
CanvasRenderingContext2DBase.Text.csGets or sets the spacing between the words (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-wordspacing): a CSS length (the font-relative lengths are resolved against the current font when the text is drawn); other values are ignored.
public string WordSpacing { get; set; }Property value
See also
Methods
| Name | Description |
|---|---|
| Arc(double, double, double, double, double, bool) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-arc |
| ArcTo(double, double, double, double, double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-arcto |
| BeginLayer(BeginLayerOptions?) | Saves the drawing state on the stack and starts a layer (https://github.com/whatwg/html/pull/9537): the following drawing operations are drawn into a transparent layer, which CanvasRenderingContext2DBase.EndLayer draws on the canvas as one image. In the layer, the global alpha, the compositing operator, the shadows, the filter and the clip region are reset; they apply to the layer when it is drawn. The transformation matrix is not reset. |
| BeginPath() | Empties the current default path (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-beginpath). |
| BezierCurveTo(double, double, double, double, double, double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-beziercurveto |
| ClearRect(double, double, double, double) | Clears a rectangle to transparent black (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-clearrect): the clip region and the current transformation matrix apply, the shadows, the global alpha, the compositing and the filters do not. |
| Clip(CanvasFillRule) | Intersects the clip region with the current default path (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-clip). |
| Clip(Path2D, CanvasFillRule) | Intersects the clip region with a path (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-clip). |
| ClosePath() | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-closepath |
| CreateConicGradient(double, double, double) | Creates a conic gradient around (x, y) (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createconicgradient). |
| CreateImageData(ImageData) | Creates a transparent black image data of the size and color space of another one (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createimagedata-imagedata). |
| CreateImageData(int, int, ImageDataSettings?) | Creates a transparent black image data (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createimagedata). |
| CreateLinearGradient(double, double, double, double) | Creates a linear gradient from (x0, y0) to (x1, y1) (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createlineargradient). |
| CreatePattern(object?, string) | Creates a pattern of an image (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createpattern), or returns null when the image cannot be drawn (not fully decodable). |
| CreateRadialGradient(double, double, double, double, double, double) | Creates a radial gradient between two circles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createradialgradient). |
| DrawElementImage(object?, double, double, DrawElementImageOptions?) | Draws the last snapshot of a drawable element of the canvas at its default size (see HtmlCanvasElement.GetElementImageDefaultSize), and sets its canvas transform to where it is drawn (unless DrawElementImageOptions.PreserveElementGeometry is true). |
| DrawElementImage(object?, double, double, double, double, DrawElementImageOptions?) | Draws the last snapshot of a drawable element of the canvas scaled to a rectangle (see CanvasRenderingContext2DBase.DrawElementImage). |
| DrawElementImage(object?, double, double, double, double, double, double, DrawElementImageOptions?) | Draws a rectangle of the last snapshot of a drawable element of the canvas at its size (see CanvasRenderingContext2DBase.DrawElementImage). The source rectangle is in the coordinates of the image (the pixels of the bitmap of the canvas), and can extend beyond the border box of the element (its ink overflow). |
| DrawElementImage(object?, double, double, double, double, double, double, double, double, DrawElementImageOptions?) | Draws a rectangle of the last snapshot of a drawable element of the canvas scaled to a rectangle (see CanvasRenderingContext2DBase.DrawElementImage). |
| DrawFocusIfNeeded(Element) | Draws a focus ring around the current default path when the element is focused and is a descendant of the canvas (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawfocusifneeded). |
| DrawFocusIfNeeded(Path2D, Element) | Draws a focus ring around a path when the element is focused and is a descendant of the canvas (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawfocusifneeded). |
| DrawImage(object?, double, double) | Draws an image at its natural size (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawimage). |
| DrawImage(object?, double, double, double, double) | Draws an image scaled to a rectangle (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawimage). |
| DrawImage(object?, double, double, double, double, double, double, double, double) | Draws a rectangle of an image scaled to a rectangle (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawimage). |
| Ellipse(double, double, double, double, double, double, double, bool) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ellipse |
| EndLayer() | Restores the drawing state saved by CanvasRenderingContext2DBase.BeginLayer and draws the layer on the canvas (or on the parent layer) with the global alpha, the compositing operator, the shadow, the filter and the clip region of this state. |
| Fill(CanvasFillRule) | Fills the current default path with the fill style (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fill). |
| Fill(Path2D, CanvasFillRule) | Fills a path with the fill style (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fill). |
| FillGlyphRun(CanvasGlyphRun, double, double) | Fills a glyph run of a shaped text with the fill style, the alignment point of the shaped text at (x, y). |
| FillGlyphRuns(IReadOnlyList<CanvasGlyphRun>, double, double) | Fills glyph runs of shaped texts with the fill style, the alignment point of each shaped text at (x, y). |
| FillRect(double, double, double, double) | Fills a rectangle with the fill style (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fillrect). |
| FillText(string, double, double, double?) | Fills a text at a point with the fill style (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-filltext). |
| FillTextCluster(TextCluster, double, double, TextClusterOptions?) | Fills a cluster of a measured text (https://github.com/whatwg/html/pull/11000) with the fill style: the glyphs of the cluster, with the font and the text styles of the measurement, are drawn with their alignment point at (x + TextCluster.X, y + TextCluster.Y). Drawing all the clusters of a text at the same point draws the text as CanvasRenderingContext2DBase.FillText at that point. |
| GetContextAttributes() | Returns the settings of the context (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getcontextattributes). |
| GetImageData(int, int, int, int, ImageDataSettings?) | Returns the pixels of a rectangle of the bitmap (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getimagedata): not premultiplied, in the requested color space; the pixels outside of the bitmap are transparent black. |
| GetLineDash() | Returns a copy of the dash list (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getlinedash). |
| GetTransform() | Returns a copy of the current transformation matrix (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-gettransform). |
| IsContextLost() | Whether the context is lost (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-iscontextlost): never. |
| IsPointInPath(Path2D, double, double, CanvasFillRule) | Returns whether a point (in the coordinates of the canvas, not transformed) is inside a path transformed by the current transformation matrix. |
| IsPointInPath(double, double, CanvasFillRule) | Returns whether a point (in the coordinates of the canvas, not transformed) is inside the current default path (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ispointinpath); the points of the path are inside. |
| IsPointInStroke(Path2D, double, double) | Returns whether a point (in the coordinates of the canvas, not transformed) is inside the stroke of a path with the line styles. |
| IsPointInStroke(double, double) | Returns whether a point (in the coordinates of the canvas, not transformed) is inside the stroke of the current default path with the line styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ispointinstroke). |
| LineTo(double, double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-lineto |
| MeasureText(string) | Measures a text with the current font and text styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-measuretext). |
| MoveTo(double, double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-moveto |
| PutImageData(ImageData, int, int) | Replaces the pixels of the bitmap with the pixels of an image data (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-putimagedata). |
| PutImageData(ImageData, int, int, int, int, int, int) | Replaces the pixels of the bitmap with the pixels of a dirty rectangle of an image data (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-putimagedata): the pixels are not composited, and the current transformation matrix, the clip region, the global alpha and the shadows do not apply. |
| QuadraticCurveTo(double, double, double, double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-quadraticcurveto |
| Rect(double, double, double, double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-rect |
| Reset() | Resets the context to its default state (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-reset): the bitmap is cleared, the drawing state and its stack, and the current default path are reset, and the open layers are discarded. |
| ResetTransform() | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-resettransform |
| Restore() | Pops the drawing state from the stack (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-restore); does nothing when the stack is empty. |
| Rotate(double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-rotate: a clockwise rotation by an angle in radians. |
| RoundRect(double, double, double, double, object?) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-roundrect |
| Save() | Pushes a copy of the drawing state on the stack (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-save). |
| Scale(double, double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-scale |
| SetLineDash(IReadOnlyList<double>) | Sets the dash list of the lines (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-setlinedash): a list with a negative or non-finite value is ignored, a list with an odd number of values is repeated. |
| SetTransform(DomMatrix2DInit?) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-settransform-matrix |
| SetTransform(double, double, double, double, double, double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-settransform |
| ShapeText(string) | Shapes a text with the current font and text styles: the returned CanvasShapedText gives its glyph runs and clusters, drawn later by CanvasRenderingContext2DBase.FillGlyphRuns and CanvasRenderingContext2DBase.StrokeGlyphRuns with the font, the text styles, the direction, the alignment and the baseline of the context at this time. |
| Stroke() | Strokes the current default path with the stroke style and the line styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-stroke). |
| Stroke(Path2D) | Strokes a path with the stroke style and the line styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-stroke). |
| StrokeGlyphRun(CanvasGlyphRun, double, double) | Strokes a glyph run of a shaped text with the stroke style and the line styles, the alignment point of the shaped text at (x, y). |
| StrokeGlyphRuns(IReadOnlyList<CanvasGlyphRun>, double, double) | Strokes glyph runs of shaped texts with the stroke style and the line styles, the alignment point of each shaped text at (x, y). |
| StrokeRect(double, double, double, double) | Strokes the outline of a rectangle with the stroke style and the line styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-strokerect). |
| StrokeText(string, double, double, double?) | Strokes a text at a point with the stroke style and the line styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-stroketext). |
| StrokeTextCluster(TextCluster, double, double, TextClusterOptions?) | Strokes a cluster of a measured text (https://github.com/whatwg/html/pull/11000) with the stroke style and the line styles: see CanvasRenderingContext2DBase.FillTextCluster. |
| Transform(double, double, double, double, double, double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-transform |
| Translate(double, double) | https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-translate |
Arc(double, double, double, double, double, bool)
CanvasRenderingContext2DBase.csArcTo(double, double, double, double, double)
CanvasRenderingContext2DBase.cshttps://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-arcto
BeginLayer(BeginLayerOptions?)
CanvasRenderingContext2DBase.Layers.cs- Experimental (WEBPLATEXP0017)
Saves the drawing state on the stack and starts a layer (https://github.com/whatwg/html/pull/9537): the following drawing operations are drawn into a transparent layer, which CanvasRenderingContext2DBase.EndLayer draws on the canvas as one image. In the layer, the global alpha, the compositing operator, the shadows, the filter and the clip region are reset; they apply to the layer when it is drawn. The transformation matrix is not reset.
[Experimental("WEBPLATEXP0017", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void BeginLayer(BeginLayerOptions? options = null)Parameters
optionsBeginLayerOptions?- The options of the layer: its
filter, a CSS filter or aCanvasFilter(or the description of one) applied to the layer before the filter of the state, in the coordinates of the current transformation matrix.
Exceptions
TypeErrorException- The filter is the description of a
CanvasFilterthat is not valid: the layer is not opened.
Remarks
While a layer is open, the pixels of the canvas cannot be read (getImageData(), toDataURL(), drawImage() of the canvas...): these methods throw an InvalidStateError. The canvas displays the pixels drawn before the layer was opened.
See also
BeginPath()
CanvasRenderingContext2DBase.csEmpties the current default path (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-beginpath).
public void BeginPath()BezierCurveTo(double, double, double, double, double, double)
CanvasRenderingContext2DBase.cshttps://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-beziercurveto
ClearRect(double, double, double, double)
CanvasRenderingContext2DBase.csClears a rectangle to transparent black (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-clearrect): the clip region and the current transformation matrix apply, the shadows, the global alpha, the compositing and the filters do not.
Parameters
See also
Clip overloads
Clip(CanvasFillRule)
CanvasRenderingContext2DBase.csIntersects the clip region with the current default path (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-clip).
public void Clip(CanvasFillRule fillRule = CanvasFillRule.NonZero)Clip(Path2D, CanvasFillRule)
CanvasRenderingContext2DBase.csIntersects the clip region with a path (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-clip).
public void Clip(Path2D path, CanvasFillRule fillRule = CanvasFillRule.NonZero)ClosePath()
CanvasRenderingContext2DBase.cshttps://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-closepath
public void ClosePath()CreateConicGradient(double, double, double)
CanvasRenderingContext2DBase.csCreates a conic gradient around (x, y) (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createconicgradient).
public CanvasGradient CreateConicGradient(double startAngle, double x, double y)CreateImageData overloads
CreateImageData(ImageData)
CanvasRenderingContext2DBase.Images.csCreates a transparent black image data of the size and color space of another one (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createimagedata-imagedata).
CreateImageData(int, int, ImageDataSettings?)
CanvasRenderingContext2DBase.Images.csCreates a transparent black image data (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createimagedata).
public ImageData CreateImageData(int sw, int sh, ImageDataSettings? settings = null)Parameters
swint- The width (its absolute value is used).
shint- The height (its absolute value is used).
settingsImageDataSettings?- The color space (the color space of the canvas by default) and the format of the pixels.
Returns
Exceptions
DomException- An
IndexSizeErrorwhen the width or the height is zero.
See also
CreateLinearGradient(double, double, double, double)
CanvasRenderingContext2DBase.csCreates a linear gradient from (x0, y0) to (x1, y1) (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createlineargradient).
public CanvasGradient CreateLinearGradient(double x0, double y0, double x1, double y1)CreatePattern(object?, string)
CanvasRenderingContext2DBase.Images.csCreates a pattern of an image (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createpattern), or returns null when the image cannot be drawn (not fully decodable).
public CanvasPattern? CreatePattern(object? image, string repetition)Parameters
imageobject?- An
img,svg:image,videoorcanvaselement, anImageBitmap, anOffscreenCanvasor aCssImageValue(the image of a URL fetched for the styles of the document). repetitionstringrepeat(or the empty string),repeat-x,repeat-yorno-repeat.
Returns
Exceptions
DomException- An
InvalidStateErrorwhen the image is broken, or a canvas or a bitmap without pixels; aSyntaxErrorwhen the repetition is invalid.
See also
CreateRadialGradient(double, double, double, double, double, double)
CanvasRenderingContext2DBase.csCreates a radial gradient between two circles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-createradialgradient).
public CanvasGradient CreateRadialGradient(double x0, double y0, double r0, double x1, double y1, double r1)Parameters
Returns
Exceptions
TypeErrorException- An argument is not finite.
DomException- An
IndexSizeErrorwhen a radius is negative.
See also
DrawElementImage overloads
DrawElementImage(object?, double, double, DrawElementImageOptions?)
CanvasRenderingContext2DBase.ElementImages.cs- Experimental (WEBPLATEXP0023)
Draws the last snapshot of a drawable element of the canvas at its default size (see HtmlCanvasElement.GetElementImageDefaultSize), and sets its canvas transform to where it is drawn (unless DrawElementImageOptions.PreserveElementGeometry is true).
[Experimental("WEBPLATEXP0023", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void DrawElementImage(object? element, double dx, double dy, DrawElementImageOptions? options = null)Parameters
elementobject?- A drawable element of the canvas, or an
ElementImageof the canvas. dxdouble- The x coordinate of the destination.
dydouble- The y coordinate of the destination.
optionsDrawElementImageOptions?- The options.
Exceptions
DomException- An
InvalidStateErrorwhen the element is not a drawable element of the canvas, it has no snapshot, or the image is closed.
See also
DrawElementImage(object?, double, double, double, double, DrawElementImageOptions?)
CanvasRenderingContext2DBase.ElementImages.cs- Experimental (WEBPLATEXP0023)
Draws the last snapshot of a drawable element of the canvas scaled to a rectangle (see CanvasRenderingContext2DBase.DrawElementImage).
[Experimental("WEBPLATEXP0023", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void DrawElementImage(object? element, double dx, double dy, double dwidth, double dheight, DrawElementImageOptions? options = null)Parameters
elementobject?- A drawable element of the canvas, or an
ElementImageof the canvas. dxdouble- The x coordinate of the destination.
dydouble- The y coordinate of the destination.
dwidthdouble- The width of the destination.
dheightdouble- The height of the destination.
optionsDrawElementImageOptions?- The options.
Exceptions
DomException- An
InvalidStateErrorwhen the element is not a drawable element of the canvas, it has no snapshot, or the image is closed.
See also
DrawElementImage(object?, double, double, double, double, double, double, DrawElementImageOptions?)
CanvasRenderingContext2DBase.ElementImages.cs- Experimental (WEBPLATEXP0023)
Draws a rectangle of the last snapshot of a drawable element of the canvas at its size (see CanvasRenderingContext2DBase.DrawElementImage). The source rectangle is in the coordinates of the image (the pixels of the bitmap of the canvas), and can extend beyond the border box of the element (its ink overflow).
[Experimental("WEBPLATEXP0023", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void DrawElementImage(object? element, double sx, double sy, double swidth, double sheight, double dx, double dy, DrawElementImageOptions? options = null)Parameters
elementobject?- A drawable element of the canvas, or an
ElementImageof the canvas. sxdouble- The x coordinate of the source rectangle.
sydouble- The y coordinate of the source rectangle.
swidthdouble- The width of the source rectangle.
sheightdouble- The height of the source rectangle.
dxdouble- The x coordinate of the destination.
dydouble- The y coordinate of the destination.
optionsDrawElementImageOptions?- The options.
Exceptions
DomException- An
InvalidStateErrorwhen the element is not a drawable element of the canvas, it has no snapshot, or the image is closed.
See also
DrawElementImage(object?, double, double, double, double, double, double, double, double, DrawElementImageOptions?)
CanvasRenderingContext2DBase.ElementImages.cs- Experimental (WEBPLATEXP0023)
Draws a rectangle of the last snapshot of a drawable element of the canvas scaled to a rectangle (see CanvasRenderingContext2DBase.DrawElementImage).
[Experimental("WEBPLATEXP0023", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void DrawElementImage(object? element, double sx, double sy, double swidth, double sheight, double dx, double dy, double dwidth, double dheight, DrawElementImageOptions? options = null)Parameters
elementobject?- A drawable element of the canvas, or an
ElementImageof the canvas. sxdouble- The x coordinate of the source rectangle.
sydouble- The y coordinate of the source rectangle.
swidthdouble- The width of the source rectangle.
sheightdouble- The height of the source rectangle.
dxdouble- The x coordinate of the destination.
dydouble- The y coordinate of the destination.
dwidthdouble- The width of the destination.
dheightdouble- The height of the destination.
optionsDrawElementImageOptions?- The options.
Exceptions
DomException- An
InvalidStateErrorwhen the element is not a drawable element of the canvas, it has no snapshot, or the image is closed.
See also
DrawFocusIfNeeded overloads
DrawFocusIfNeeded(Element)
CanvasRenderingContext2DBase.csDraws a focus ring around the current default path when the element is focused and is a descendant of the canvas (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawfocusifneeded).
DrawFocusIfNeeded(Path2D, Element)
CanvasRenderingContext2DBase.csDraws a focus ring around a path when the element is focused and is a descendant of the canvas (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawfocusifneeded).
Parameters
See also
DrawImage overloads
DrawImage(object?, double, double)
CanvasRenderingContext2DBase.Images.csDraws an image at its natural size (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawimage).
Parameters
imageobject?- An
img,svg:image,videoorcanvaselement, anImageBitmap, anOffscreenCanvasor aCssImageValue(the image of a URL fetched for the styles of the document). dxdouble- The x coordinate of the destination.
dydouble- The y coordinate of the destination.
Exceptions
DomException- An
InvalidStateErrorwhen the image is broken, or a canvas or a bitmap without pixels.
See also
DrawImage(object?, double, double, double, double)
CanvasRenderingContext2DBase.Images.csDraws an image scaled to a rectangle (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawimage).
Parameters
imageobject?- An
img,svg:image,videoorcanvaselement, anImageBitmap, anOffscreenCanvasor aCssImageValue(the image of a URL fetched for the styles of the document). dxdouble- The x coordinate of the destination.
dydouble- The y coordinate of the destination.
dwdouble- The width of the destination.
dhdouble- The height of the destination.
Exceptions
DomException- An
InvalidStateErrorwhen the image is broken, or a canvas or a bitmap without pixels.
See also
DrawImage(object?, double, double, double, double, double, double, double, double)
CanvasRenderingContext2DBase.Images.csDraws a rectangle of an image scaled to a rectangle (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-drawimage).
public void DrawImage(object? image, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh)Parameters
imageobject?- An
img,svg:image,videoorcanvaselement, anImageBitmap, anOffscreenCanvasor aCssImageValue(the image of a URL fetched for the styles of the document). sxdouble- The x coordinate of the source rectangle, in image pixels.
sydouble- The y coordinate of the source rectangle, in image pixels.
swdouble- The width of the source rectangle.
shdouble- The height of the source rectangle.
dxdouble- The x coordinate of the destination.
dydouble- The y coordinate of the destination.
dwdouble- The width of the destination.
dhdouble- The height of the destination.
Exceptions
DomException- An
InvalidStateErrorwhen the image is broken, or a canvas or a bitmap without pixels.
See also
Ellipse(double, double, double, double, double, double, double, bool)
CanvasRenderingContext2DBase.cshttps://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ellipse
public void Ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle, double endAngle, bool counterclockwise = false)EndLayer()
CanvasRenderingContext2DBase.Layers.cs- Experimental (WEBPLATEXP0017)
Restores the drawing state saved by CanvasRenderingContext2DBase.BeginLayer and draws the layer on the canvas (or on the parent layer) with the global alpha, the compositing operator, the shadow, the filter and the clip region of this state.
[Experimental("WEBPLATEXP0017", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void EndLayer()Exceptions
DomException- An
InvalidStateErrorwhen the last state of the stack was not pushed byCanvasRenderingContext2DBase.BeginLayer(no layer is open, or aCanvasRenderingContext2DBase.Saveis not restored).
See also
Fill overloads
Fill(CanvasFillRule)
CanvasRenderingContext2DBase.csFills the current default path with the fill style (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fill).
public void Fill(CanvasFillRule fillRule = CanvasFillRule.NonZero)Fill(Path2D, CanvasFillRule)
CanvasRenderingContext2DBase.csFills a path with the fill style (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-fill).
public void Fill(Path2D path, CanvasFillRule fillRule = CanvasFillRule.NonZero)FillGlyphRun(CanvasGlyphRun, double, double)
CanvasRenderingContext2DBase.TextClusters.cs- Experimental (WEBPLATEXP0025)
Fills a glyph run of a shaped text with the fill style, the alignment point of the shaped text at (x, y).
[Experimental("WEBPLATEXP0025", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void FillGlyphRun(CanvasGlyphRun glyphRun, double x, double y)Parameters
glyphRunCanvasGlyphRun- The glyph run, returned by
CanvasShapedText.GlyphRunsorCanvasShapedText.GlyphClusters. xdouble- The x coordinate of the alignment point of the shaped text.
ydouble- The y coordinate of the baseline of the shaped text.
See also
FillGlyphRuns(IReadOnlyList<CanvasGlyphRun>, double, double)
CanvasRenderingContext2DBase.TextClusters.cs- Experimental (WEBPLATEXP0025)
Fills glyph runs of shaped texts with the fill style, the alignment point of each shaped text at (x, y).
[Experimental("WEBPLATEXP0025", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void FillGlyphRuns(IReadOnlyList<CanvasGlyphRun> glyphRuns, double x, double y)Parameters
glyphRunsIReadOnlyList<CanvasGlyphRun>- The glyph runs, returned by
CanvasShapedText.GlyphRunsorCanvasShapedText.GlyphClusters. xdouble- The x coordinate of the alignment point of the shaped texts.
ydouble- The y coordinate of the baseline of the shaped texts.
See also
FillRect(double, double, double, double)
CanvasRenderingContext2DBase.csFillText(string, double, double, double?)
CanvasRenderingContext2DBase.Text.csFills a text at a point with the fill style (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-filltext).
FillTextCluster(TextCluster, double, double, TextClusterOptions?)
CanvasRenderingContext2DBase.TextClusters.cs- Experimental (WEBPLATEXP0024)
Fills a cluster of a measured text (https://github.com/whatwg/html/pull/11000) with the fill style: the glyphs of the cluster, with the font and the text styles of the measurement, are drawn with their alignment point at (x + TextCluster.X, y + TextCluster.Y). Drawing all the clusters of a text at the same point draws the text as CanvasRenderingContext2DBase.FillText at that point.
[Experimental("WEBPLATEXP0024", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void FillTextCluster(TextCluster textCluster, double x, double y, TextClusterOptions? options = null)Parameters
textClusterTextCluster- The cluster, returned by
TextMetrics.GetTextClusters. xdouble- The x coordinate the position of the cluster is relative to.
ydouble- The y coordinate the position of the cluster is relative to.
optionsTextClusterOptions?- The alignment, the baseline and the position (
x,y) that replace the ones of the cluster.
See also
GetContextAttributes()
CanvasRenderingContext2DBase.csReturns the settings of the context (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getcontextattributes).
public CanvasRenderingContext2DSettings GetContextAttributes()GetImageData(int, int, int, int, ImageDataSettings?)
CanvasRenderingContext2DBase.Images.csReturns the pixels of a rectangle of the bitmap (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getimagedata): not premultiplied, in the requested color space; the pixels outside of the bitmap are transparent black.
Parameters
sxintsyintswintshintsettingsImageDataSettings?
Returns
Exceptions
DomException- An
IndexSizeErrorwhen the width or the height is zero, aSecurityErrorwhen the canvas is not origin-clean.
See also
GetLineDash()
CanvasRenderingContext2DBase.csReturns a copy of the dash list (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-getlinedash).
public IReadOnlyList<double> GetLineDash()GetTransform()
CanvasRenderingContext2DBase.csReturns a copy of the current transformation matrix (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-gettransform).
public DomMatrix GetTransform()IsContextLost()
CanvasRenderingContext2DBase.csWhether the context is lost (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-iscontextlost): never.
public bool IsContextLost()IsPointInPath overloads
IsPointInPath(Path2D, double, double, CanvasFillRule)
CanvasRenderingContext2DBase.csReturns whether a point (in the coordinates of the canvas, not transformed) is inside a path transformed by the current transformation matrix.
public bool IsPointInPath(Path2D path, double x, double y, CanvasFillRule fillRule = CanvasFillRule.NonZero)IsPointInPath(double, double, CanvasFillRule)
CanvasRenderingContext2DBase.csReturns whether a point (in the coordinates of the canvas, not transformed) is inside the current default path (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ispointinpath); the points of the path are inside.
public bool IsPointInPath(double x, double y, CanvasFillRule fillRule = CanvasFillRule.NonZero)IsPointInStroke overloads
IsPointInStroke(Path2D, double, double)
CanvasRenderingContext2DBase.csReturns whether a point (in the coordinates of the canvas, not transformed) is inside the stroke of a path with the line styles.
Parameters
Returns
See also
IsPointInStroke(double, double)
CanvasRenderingContext2DBase.csReturns whether a point (in the coordinates of the canvas, not transformed) is inside the stroke of the current default path with the line styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-ispointinstroke).
Parameters
Returns
See also
LineTo(double, double)
CanvasRenderingContext2DBase.csMeasureText(string)
CanvasRenderingContext2DBase.Text.csMeasures a text with the current font and text styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-measuretext).
public TextMetrics MeasureText(string text)MoveTo(double, double)
CanvasRenderingContext2DBase.csPutImageData overloads
PutImageData(ImageData, int, int)
CanvasRenderingContext2DBase.Images.csReplaces the pixels of the bitmap with the pixels of an image data (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-putimagedata).
Parameters
Exceptions
DomException- An
InvalidStateErrorwhen the buffer of the image data is detached.
See also
PutImageData(ImageData, int, int, int, int, int, int)
CanvasRenderingContext2DBase.Images.csReplaces the pixels of the bitmap with the pixels of a dirty rectangle of an image data (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-putimagedata): the pixels are not composited, and the current transformation matrix, the clip region, the global alpha and the shadows do not apply.
public void PutImageData(ImageData imageData, int dx, int dy, int dirtyX, int dirtyY, int dirtyWidth, int dirtyHeight)Parameters
Exceptions
DomException- An
InvalidStateErrorwhen the buffer of the image data is detached.
See also
QuadraticCurveTo(double, double, double, double)
CanvasRenderingContext2DBase.csRect(double, double, double, double)
CanvasRenderingContext2DBase.csResets the context to its default state (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-reset): the bitmap is cleared, the drawing state and its stack, and the current default path are reset, and the open layers are discarded.
public void Reset()ResetTransform()
CanvasRenderingContext2DBase.cshttps://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-resettransform
public void ResetTransform()Restore()
CanvasRenderingContext2DBase.csPops the drawing state from the stack (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-restore); does nothing when the stack is empty.
public void Restore()Exceptions
DomException- An
InvalidStateErrorwhen the last state of the stack was pushed byCanvasRenderingContext2DBase.BeginLayer.
See also
Rotate(double)
CanvasRenderingContext2DBase.cshttps://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-rotate: a clockwise rotation by an angle in radians.
RoundRect(double, double, double, double, object?)
CanvasRenderingContext2DBase.cshttps://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-roundrect
Parameters
xdouble- The x coordinate of the rectangle.
ydouble- The y coordinate of the rectangle.
wdouble- The width of the rectangle.
hdouble- The height of the rectangle.
radiiobject?- A radius (a number or a
DomPointInit), or a list of 1 to 4 radii.
Exceptions
RangeErrorException- The number of radii is not between 1 and 4, or a radius is negative.
See also
Pushes a copy of the drawing state on the stack (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-save).
public void Save()Scale(double, double)
CanvasRenderingContext2DBase.csSetLineDash(IReadOnlyList<double>)
CanvasRenderingContext2DBase.csSets the dash list of the lines (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-setlinedash): a list with a negative or non-finite value is ignored, a list with an odd number of values is repeated.
public void SetLineDash(IReadOnlyList<double> segments)SetTransform overloads
SetTransform(DomMatrix2DInit?)
CanvasRenderingContext2DBase.cshttps://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-settransform-matrix
public void SetTransform(DomMatrix2DInit? transform = null)Parameters
transformDomMatrix2DInit?
Exceptions
TypeErrorException- The members of the dictionary are inconsistent.
See also
SetTransform(double, double, double, double, double, double)
CanvasRenderingContext2DBase.cshttps://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-settransform
ShapeText(string)
CanvasRenderingContext2DBase.TextClusters.cs- Experimental (WEBPLATEXP0025)
Shapes a text with the current font and text styles: the returned CanvasShapedText gives its glyph runs and clusters, drawn later by CanvasRenderingContext2DBase.FillGlyphRuns and CanvasRenderingContext2DBase.StrokeGlyphRuns with the font, the text styles, the direction, the alignment and the baseline of the context at this time.
[Experimental("WEBPLATEXP0025", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public CanvasShapedText ShapeText(string text)Stroke overloads
Stroke()
CanvasRenderingContext2DBase.csStrokes the current default path with the stroke style and the line styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-stroke).
public void Stroke()Stroke(Path2D)
CanvasRenderingContext2DBase.csStrokes a path with the stroke style and the line styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-stroke).
StrokeGlyphRun(CanvasGlyphRun, double, double)
CanvasRenderingContext2DBase.TextClusters.cs- Experimental (WEBPLATEXP0025)
Strokes a glyph run of a shaped text with the stroke style and the line styles, the alignment point of the shaped text at (x, y).
[Experimental("WEBPLATEXP0025", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void StrokeGlyphRun(CanvasGlyphRun glyphRun, double x, double y)Parameters
glyphRunCanvasGlyphRun- The glyph run, returned by
CanvasShapedText.GlyphRunsorCanvasShapedText.GlyphClusters. xdouble- The x coordinate of the alignment point of the shaped text.
ydouble- The y coordinate of the baseline of the shaped text.
See also
StrokeGlyphRuns(IReadOnlyList<CanvasGlyphRun>, double, double)
CanvasRenderingContext2DBase.TextClusters.cs- Experimental (WEBPLATEXP0025)
Strokes glyph runs of shaped texts with the stroke style and the line styles, the alignment point of each shaped text at (x, y).
[Experimental("WEBPLATEXP0025", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void StrokeGlyphRuns(IReadOnlyList<CanvasGlyphRun> glyphRuns, double x, double y)Parameters
glyphRunsIReadOnlyList<CanvasGlyphRun>- The glyph runs, returned by
CanvasShapedText.GlyphRunsorCanvasShapedText.GlyphClusters. xdouble- The x coordinate of the alignment point of the shaped texts.
ydouble- The y coordinate of the baseline of the shaped texts.
See also
StrokeRect(double, double, double, double)
CanvasRenderingContext2DBase.csStrokes the outline of a rectangle with the stroke style and the line styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-strokerect).
Parameters
See also
StrokeText(string, double, double, double?)
CanvasRenderingContext2DBase.Text.csStrokes a text at a point with the stroke style and the line styles (https://html.spec.whatwg.org/multipage/canvas.html#dom-context-2d-stroketext).
StrokeTextCluster(TextCluster, double, double, TextClusterOptions?)
CanvasRenderingContext2DBase.TextClusters.cs- Experimental (WEBPLATEXP0024)
Strokes a cluster of a measured text (https://github.com/whatwg/html/pull/11000) with the stroke style and the line styles: see CanvasRenderingContext2DBase.FillTextCluster.
[Experimental("WEBPLATEXP0024", UrlFormat = "https://github.com/meziantou/Meziantou.Framework/blob/main/src/Meziantou.Framework.WebPlatform/docs/experimental-apis.md#{0}")]
public void StrokeTextCluster(TextCluster textCluster, double x, double y, TextClusterOptions? options = null)Parameters
textClusterTextCluster- The cluster, returned by
TextMetrics.GetTextClusters. xdouble- The x coordinate the position of the cluster is relative to.
ydouble- The y coordinate the position of the cluster is relative to.
optionsTextClusterOptions?- The alignment, the baseline and the position (
x,y) that replace the ones of the cluster.