HTML5 畫布中的 getContext 是什麼?
Canvas 元素有一個叫 getContext 的 DOM 方法,用於獲取渲染上下文及其繪圖功能。此函式帶一個引數,即 2d 的上下文型別。
以下是獲取所需上下文並檢查你的瀏覽器是否支援 <canvas> 元素的程式碼
var canvas = document.getElementById("mycanvas");
if (canvas.getContext){
var ctx = canvas.getContext('2d');
// drawing code here
} else {
// canvas-unsupported code here
}
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP