Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
Rotating Circles
with Canvas2D
css
@import url("https://fonts.googleapis.com/css?family=Lato"); html { height: 100%; } body { margin: 0; font-family: 'Lato', sans-serif; background-color: #eeebe8; } .flex-wrap { width: 100vw; height: 100vh; display: flex; align-items: center; justify-content: center; } .flex-wrap__in { width: 420px; display: flex; flex-wrap: wrap; justify-content: center; } .pen-title { width: 100%; line-height: 1; margin-top: 0; margin-bottom: 0; color: #6e6862; font-size: 3rem; font-weight: 400; text-align: center; letter-spacing: .05em; } .pen-excerpt { width: 100%; color: #3c3732; text-align: center; letter-spacing: .2em; } canvas { width: 100px; height: 100px; margin: 20px; }
JavaScript
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var RotatingCircle = function () { function RotatingCircle(canvas, opts) { _classCallCheck(this, RotatingCircle); this.ctx = canvas.getContext('2d'); this.size = Math.min(canvas.clientWidth, canvas.clientHeight); this.radius = opts.radius; this.lineWidth = opts.lineWidth; this.strokeStyle = opts.strokeStyle; this.degreeStart = opts.degreeStart; this.degreeEnd = opts.degreeEnd; this.stepStart = opts.stepStart; this.stepEnd = opts.stepEnd; } _createClass(RotatingCircle, [{ key: 'render', value: function render() { this.degreeStart = this.degreeStart + this.stepStart; this.degreeEnd = this.degreeEnd + this.stepEnd; if (this.degreeStart - 360 > this.degreeEnd) { this.degreeStart -= 720; } this.ctx.clearRect(0, 0, this.size, this.size); this.ctx.lineWidth = this.lineWidth; this.ctx.beginPath(); this.ctx.strokeStyle = this.strokeStyle; this.ctx.arc(this.size / 2, this.size / 2, this.radius - this.lineWidth / 2, (this.degreeStart < this.degreeEnd ? this.degreeStart : this.degreeEnd) * Math.PI / 180, (this.degreeStart < this.degreeEnd ? this.degreeEnd : this.degreeStart) * Math.PI / 180, false); this.ctx.stroke(); } }]); return RotatingCircle; }(); var circles = [new RotatingCircle(document.querySelector('.js-rotate-01'), { radius: 24, lineWidth: 12, strokeStyle: '#587fa5', degreeStart: -90, degreeEnd: 270, stepStart: 4, stepEnd: 3 }), new RotatingCircle(document.querySelector('.js-rotate-02'), { radius: 40, lineWidth: 8, strokeStyle: '#7fa4d3', degreeStart: -90, degreeEnd: 270, stepStart: 6, stepEnd: 3 }), new RotatingCircle(document.querySelector('.js-rotate-03'), { radius: 50, lineWidth: 3, strokeStyle: '#aacaf1', degreeStart: -90, degreeEnd: 270, stepStart: 12, stepEnd: 9 }), new RotatingCircle(document.querySelector('.js-rotate-04'), { radius: 28, lineWidth: 18, strokeStyle: '#a5586c', degreeStart: -90, degreeEnd: 270, stepStart: 2, stepEnd: 1 }), new RotatingCircle(document.querySelector('.js-rotate-05'), { radius: 40, lineWidth: 8, strokeStyle: '#d37f87', degreeStart: -90, degreeEnd: 180, stepStart: 8, stepEnd: 2 }), new RotatingCircle(document.querySelector('.js-rotate-06'), { radius: 50, lineWidth: 3, strokeStyle: '#f1aab1', degreeStart: -90, degreeEnd: 270, stepStart: 14, stepEnd: 2 })]; var renderLoop = function renderLoop() { circles.map(function (circle) { circle.render(); }); requestAnimationFrame(function () { renderLoop(); }); }; renderLoop();
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>Canvas加载动画-jq22.com</title> <script src="https://www.jq22.com/jquery/jquery-1.10.2.js"></script> <style>
</style> </head> <body>
<script>
</script>
</body> </html>
2012-2021 jQuery插件库版权所有
jquery插件
|
jq22工具库
|
网页技术
|
广告合作
|
在线反馈
|
版权声明
沪ICP备13043785号-1
浙公网安备 33041102000314号