小程序畫布獲取OffscreenCanvas的繪圖上下文OffscreenCanvas.getContext
RenderingContext OffscreenCanvas.getContext(string contextType)
該方法返回 OffscreenCanvas 的繪圖上下文
基礎庫 2.7.0 開始支持,低版本需做兼容處理。
小程序插件:支持,需要小程序基礎庫版本不低于 2.16.1
參數
string contextType
繪圖上下文類型,需要與 createOffscreenCanvas 時傳入的 type 一致
contextType 的合法值
值 說明 最低版本
webgl webgl類型上下文
2d 2d類型上下文 2.16.1
返回值
RenderingContext
注意不允許混用 webgl 和 2d 繪圖上下文,傳入的 contextType 必須要與 wx.createOffscreenCanvas 傳入的 type 類型一致。
計算機學習推薦