restore

書式

コンテキスト.restore()

属性

パラメータ 内 容
なし なし

対応

Safari 2, Firefox 1.5, Opera 9

説明

キャンバスの座標系を復元します。直前のsave()での状態に戻ります。

サンプルコード [実行]

<!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");
imgObj = new Image(120,80);
imgObj.src = "photo.jpg";
x = Math.random() * 200;
y = Math.random() * 160;
r = Math.random() * 360;
conObj.rotate(r * Math.PI / 180);
conObj.drawImage(imgObj,x,y);
}
// --></script> </head>
<body onload="setInterval('drawPoint()',100)">
<h1>Sample</h1>
<canvas id="imgCanvas" width="320" height="240" style="border:1px black solid"></canvas>
<img src="photo.jpg" style="visibility:hidden">
</body>
</html>