• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com专业计算机教程网站
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure
您的位置:首页 > 网页设计 >html5 > Canvas制作旋转太极的动画

Canvas制作旋转太极的动画

作者:匿名 字体:[增加 减小] 来源:互联网 时间:2018-12-03

本文主要包含Canvas,动画,太极等相关知识,匿名希望在学习及工作中可以帮助到您
这次给大家带来Canvas制作旋转太极的动画,Canvas制作旋转太极动画的注意事项有哪些,下面就是实战案例,一起来看一下。

前言

好久没动canvas了,今下午突然想回顾一下,就写了个旋转的太极,哈哈,蛮好玩的,在这里就将自己写的过程展示出来,旋转使用的css实现的,没有用canvas自己的,希望大佬们不要吐槽。

css

body{
    background: #ddd;
}
#canvas{
    position: absolute;
    left: 40%;
    top: 30%;
    -webkit-transform: translate(-50%,-50%);
    -moz-transform: translate(-50%,-50%);
    -ms-transform: translate(-50%,-50%);
    -o-transform: translate(-50%,-50%);
    transform: translate(-50%,-50%);
    -webkit-animation: testAnimate 3s linear infinite;
    -o-animation: testAnimate 3s linear infinite;
    animation: testAnimate 3s linear infinite;
}
@keyframes testAnimate {
    from {
        -webkit-transform: rotate(0);
        -moz-transform: rotate(0);
        -ms-transform: rotate(0);
        -o-transform: rotate(0);
        transform: rotate(0);
    }
    to {
        -webkit-transform: rotate(360deg);
        -moz-transform: rotate(360deg);
        -ms-transform: rotate(360deg);
        -o-transform: rotate(360deg);
        transform: rotate(360deg);
    }
}

html

<body>
    <canvas id="canvas" width="500" height="500"></canvas>
</body>

js

let ctx = document
    .getElementById("canvas")
    .getContext("2d");
// left-black-big
ctx.beginPath();
ctx.fillStyle = "#000";
ctx.arc(250,250,200,Math.PI/2,Math.PI*1.5,false);
ctx.closePath();
ctx.fill();
// right-white-big
ctx.beginPath();
ctx.fillStyle = "#fff";
ctx.arc(250,250,200,Math.PI/2,Math.PI*1.5,true);
ctx.closePath();
ctx.fill();
// top-black-middle
ctx.beginPath();
ctx.fillStyle = "#000";
ctx.arc(250,150,100,Math.PI/2,Math.PI*1.5,true);
ctx.closePath();
ctx.fill();
// bottom-white-middle
ctx.beginPath();
ctx.fillStyle = "#fff";
ctx.arc(250,350,100,Math.PI/2,Math.PI*1.5,false);
ctx.closePath();
ctx.fill();
// top-white-small
ctx.beginPath();
ctx.fillStyle = "#fff";
ctx.arc(250,150,25,0,Math.PI*2);
ctx.closePath();
ctx.fill();
// bottom-black-small
ctx.beginPath();
ctx.fillStyle = "#000";
ctx.arc(250,350,25,0,Math.PI*2);
ctx.closePath();
ctx.fill();

效果

相信看了本文案例你已经掌握了方法,更多精彩请关注微课江湖其它相关文章!

推荐阅读:

H5中APP监听返回事件处理

h5实现多图片预览上传及点击可拖拽控件

以上就是Canvas制作旋转太极的动画的详细内容,更多请关注微课江湖其它相关文章!

您可能想查找下面的文章:

  • canvas与html5实现视频截图功能示例
  • 详解html5 canvas常用api总结(二)--绘图API
  • HTML5 Canvas玩转酷炫大波浪进度图效果实例(附demo)
  • 详解使用HTML5 Canvas创建动态粒子网格动画
  • 解决canvas转base64/jpeg时透明区域变成黑色背景的方法
  • 用html5的canvas和JavaScript创建一个绘图程序的简单实例
  • HTML5 canvas基本绘图之图形组合
  • HTML5 canvas基本绘图之文字渲染
  • HTML5 canvas基本绘图之绘制曲线
  • HTML5 canvas基本绘图之图形变换

相关文章

  • 2018-12-03HTML5中新标签和常用标签详解_html5教程技巧
  • 2018-12-03如何用HTML5的Canvas制作3D动画效果
  • 2018-12-03关于存储详的文章推荐
  • 2017-08-06详解移动端HTML5页面端去掉input输入框的白色背景和边框(兼容Android和ios)
  • 2018-12-03HTML5 VideoAPI,打造自己的Web视频播放器
  • 2018-12-03HTML5如何绘制动画?(代码实例)
  • 2018-12-03IOS和HTML5,Javascript之间的交互说明
  • 2017-08-06让IE下支持Html5的placeholder属性的插件
  • 2018-12-03canvas如何设置阴影?canvas设置阴影的方法
  • 2018-12-03HTML5 video 事件应用示例_html5教程技巧

文章分类

  • html/xhtml
  • html5
  • CSS
  • XML/XSLT
  • Dreamweaver教程
  • Frontpage教程
  • 心得技巧
  • bootstrap
  • vue
  • AngularJS
  • HBuilder教程
  • css3
  • 浏览器兼容
  • div/css
  • 网页编辑器
  • axure

最近更新的内容

    • HTML5开发中使用MVC模式
    • 用仿ActionScript的语法来编写html5——终篇
    • html5存储页面或应用程序的私有自定义数据的data-* 属性
    • 专注前端还是全栈?
    • HTML5 Canvas 起步(2) - 路径
    • HTML5+CSS3:3D展示商品信息示例
    • 为什么W3C要制定content-box盒子模型?IE5.5之前的IE盒子模型放在今天来看也是极好的啊
    • Android使WebView支持HTML5 Video全屏播放的方法分享(图)
    • html5基础标签(html5视频标签 html5新标签用法)
    • JS HTML5拖拽上传图片预览

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有