Form
canvasobject.getContext(context)
Parameters
parameter |
description |
context |
specifies the context. In the case of 2D context, specifies the "2D". a 3D context is unsupported at this time (as of November 2005). |
Explanation
The getContext gets the 2D context for the canvasobject.
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=shift_jis">
<title>Sample</title>
<script type="text/javascript"><!--
function drawPoint()
{
canvasObj = document.getElementById("imgCanvas");
conObj = canvasObj.getContext("2d");
conObj.fillStyle = "rgba(255,0,0,1)";
conObj.fillRect(50,20,200,30);
}
// --></script> </head>
<body onload="drawPoint()">
<h1>Sample</h1>
<canvas id="imgCanvas" width="320" height="240" style="border:1px black solid"></canvas>
</body>
</html>