# RenderingContext Canvas.getContext(string contextType, Object contextAttributes)
Gets the drawing context of a canvas object.
# Parameters
# string contextType
The context type.
Valid values of contextType
Value | Description | Minimum Version |
---|---|---|
2d | 2D drawing context | |
webgl | WebGL drawing context |
# Object contextAttributes
The WebGL context property, which is valid only when contextType is WebGL.
Attribute | Type | Default | Required | Description |
---|---|---|---|---|
antialias | boolean | false | No | Indicates whether to enable antialiasing |
preserveDrawingBuffer | boolean | false | No | Indicates whether to preserve drawing buffer when drawing is finished |
antialiasSamples | number | 2 | No | Number of antialiasing samples. Minimum value is 2, and the maximum value is subject to the system limit. This is only available on iOS. |
# Return Values
# RenderingContext
The drawing context.