IT技术博客大学习 共学习 共进步
全部 移动开发 后端 数据库 AI 算法 安全 DevOps 前端 设计 开发者

图片旋转的小例子

UED TEAM 2010-06-22 13:13:32 累计浏览 3,033 次
本机暂存
<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)可以转变为弧度。

同分类推荐文章

  1. translateZ() (2026-06-25 21:18:56)
  2. translateY() (2026-06-25 21:17:56)
  3. translateX() (2026-06-25 21:16:01)

查看更多 前端 文章 →

建议继续学习

  1. 纯CSS3打造七巧板 (累计阅读 3,140)