<script type="text/javascript"> |
02 |
var c1 = document.getElementById("c1"); |
03 |
ctx = c1.getContext("2d"), |
04 |
image = document.createElement("IMG"); |
05 |
image.onload = function() { |
06 |
c1.width = image.height; |
07 |
c1.height = image.width; |
08 |
ctx.translate(0, image.width); |
09 |
ctx.rotate(270*Math.PI/180); |
10 |
ctx.drawImage(image, 0, 0); |
11 |
} |
12 |
image.src = "http://img1.cache.netease.com/img09/logo/logo_v1.gif"; |
13 |
</script> |
IE应该用滤镜实现同样的效果。
rotate()这个函数接收的是弧度值。角度乘以0.017(2π/360)可以转变为弧度。