Class CanvasRenderingContext2D
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The CanvasRenderingContext2D interface, part of the Canvas API, provides the 2D rendering context for the drawing surface of a canvas element.
It is used for drawing shapes, text, images, and other objects.
[Value("CanvasRenderingContext2D")]
public class CanvasRenderingContext2D
- Inheritance
-
CanvasRenderingContext2D
- Inherited Members
Remarks
The interface's properties and methods are described in the reference section of this page.
The Canvas tutorial has more explanation, examples, and resources, as well.
For OffscreenCanvas, there is an equivalent interface that provides the rendering context.
The offscreen rendering context inherits most of the same properties and methods as the CanvasRenderingContext2D and is described in more detail in the OffscreenCanvasRenderingContext2D reference page.
Constructors
CanvasRenderingContext2D()
public CanvasRenderingContext2D()
Properties
Canvas
The CanvasRenderingContext2D.canvas property, part of the
Canvas API, is a read-only reference to the
HTMLCanvasElement object that is associated with a given context. It
might be null if there is no associated canvas element.
[Value("canvas")]
public HTMLCanvasElement Canvas { get; }
Property Value
- HTMLCanvasElement
A HTMLCanvasElement object.
Remarks
-CanvasRenderingContext2D interface
-Canvas API
Methods
GetContextAttributes()
The CanvasRenderingContext2D.getContextAttributes() method returns an object that contains attributes used by the context.
[Value("getContextAttributes")]
public CanvasRenderingContext2DSettings GetContextAttributes()
Returns
- CanvasRenderingContext2DSettings
A
CanvasRenderingContext2DSettingsobject that contains the actual context parameters.
It has the following members:
Remarks
Note that context attributes may be requested when creating the context with HTMLCanvasElement.getContext(), but the attributes that are actually supported and used may differ.
-HTMLCanvasElement.getContext()
-WebGLRenderingContext.getContextAttributes()