# RenderingContext Canvas.getContext(string contextType, Object contextAttributes)

# 功能描述

获取画布对象的绘图上下文

# 参数

# string contextType

上下文类型

contextType 的合法值

说明
2d2d 绘图上下文
webglwebgl 绘图上下文
webgl2webgl2 绘图上下文

# Object contextAttributes

webgl 上下文属性,仅当 contextType 为 webgl 时有效

属性类型默认值必填说明
antialiasbooleanfalse表示是否抗锯齿
preserveDrawingBufferbooleanfalse表示是否绘图完成后是否保留绘图缓冲区
antialiasSamplesnumber2抗锯齿样本数。最小值为 2,最大不超过系统限制数量,仅 iOS 支持
alphanumberfalse是否开启透明通道,仅当 contextType 为 webgl 时有效。(开启后,配合tap.createVideo({underGameView: true}) 即可在video组件之上渲染主屏画布)

# 返回值

# RenderingContext

绘图上下文