RenderingContext OffscreenCanvas.getContext(string contextType)

查看 llm.txt

基础库 2.7.0 开始支持,低版本需做兼容处理。

小程序插件:支持,需要小程序基础库版本不低于 2.16.1

相关文档: 画布指南、canvas 组件介绍

功能描述

该方法返回 OffscreenCanvas 的绘图上下文

参数

string contextType

绘图上下文类型,需要与 createOffscreenCanvas 时传入的 type 一致

contextType 的合法值

值 说明 最低版本
webgl webgl类型上下文
2d 2d类型上下文 2.16.1

返回值

RenderingContext

注意不允许混用 webgl 和 2d 绘图上下文,传入的 contextType 必须要与 wx.createOffscreenCanvas 传入的 type 类型一致。