metanohi-misc-subsites/old-projects/canvas/pr.htm

43 lines
850 B
HTML
Raw Permalink Normal View History

2011-08-02 19:57:57 +02:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3c.org/1999/xhtml">
<head>
<title>Canvas picture rotating</title>
<style type='text/css'>
* {
margin:0;
padding:0;
}
canvas {
position:absolute;
top:50%;
left:50%;
margin-top:-200px;
margin-left:-320px;
border:1px solid #000;
}
</style>
<script type='text/javascript'>
function ani() {
ctx.rotate((Math.PI/180)*21)
ctx.drawImage(img,-150,-84)
setTimeout("ani()",40)
}
function load() {
img=new Image()
img.onload=function(){
ctx=document.getElementById('canvas').getContext('2d')
ctx.translate(320,200)
ani()
}
img.src="img/kr.jpg"
}
window.onload=load
</script>
</head>
<body>
<canvas id='canvas' width='640' height='400'></canvas>
</body>
</html>