canvas基础动画示例

本文主要用最简单的例子,展示canvas动画效果是如何实现的

动画效果,是一个球绕着一点旋转

const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.translate(250, 250); var count = 2;
function animate() {
ctx.clearRect(0, 0, 900, 700); // 清除画布 ctx.beginPath();
ctx.rotate((Math.PI / 180) * count);
ctx.arc(50, 50, 10, 0, Math.PI * 2, true);
ctx.stroke();
window.requestAnimationFrame(animate);
} window.requestAnimationFrame(animate);

最新文章

  1. The Number Off of FFF
  2. 解决方法 test: database removal failed: ERROR: database "test" is being accessed by other users
  3. NGUI之渲染DrawCall的合并
  4. EF Code First教程-02 约定配置
  5. BZOJ 4551 树
  6. activemq重启
  7. 第1章 网络编程基础(3)——基本Socket通信
  8. Apache Mina开发手冊之四
  9. php根据IP获取IP所在城市
  10. PHP中的抽象类与抽象方法/静态属性和静态方法/PHP中的单利模式(单态模式)/串行化与反串行化(序列化与反序列化)/约束类型/魔术方法小结
  11. .NET Core 2.0 问题杂记
  12. feed.snapdo.com 病毒
  13. Oracle database link中查询会开启事务吗?
  14. 获取ArcMap窗口句柄,通过WinAPI获取工作空间中点击要素的系统桌面坐标实现窗体跟随
  15. easyui combogrid下拉表格的分页/按键/动态搜索
  16. 线程基础:多任务处理——MESI协议以及带来的问题:伪共享
  17. Java并发编程73道面试题及答案 —— 面试稳了
  18. 未能加载文件或程序集“Microsoft.Office.Interop.Excel
  19. XAMPP Apache + MariaDB + PHP + Perl
  20. Linux 安装Nginx(使用Mac远程访问)

热门文章

  1. python学习笔记(自定义库文件路径)
  2. 网络编程 单机最大tcp连接数
  3. [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'number primary key,
  4. OKR 说明
  5. C#接口作用
  6. link @import区别 src href的区别
  7. c++ o2 优化
  8. Faces人脸识别项目简介
  9. CentOS6.5系统服务
  10. 函数响应式编程RxJava