android气球上升的属性动画,html5 canvas告白气球上升背景动画特效
特效描述:html5 canvas 告白气球上升 背景动画特效。html5基于canvas绘制各种卡通气球上升动画、告白气球背景动画特效。
代码结构
1. 引入JS
2. HTML代码
Balloons
var extend = function extend(base) {
for (var _len = arguments.length, extensions = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
extensions[_key - 1] = arguments[_key];
}
return Object.assign.apply(Object, [{}, base].concat(extensions));
};
var parseColor = function parseColor(_ref) {
var h = _ref.h,
s = _ref.s,
l = _ref.l,
a = _ref.a;
return 'hsla(' + h + ',' + s + '%,' + l + '%,' + a + ')';
};
var Color = extend.bind(null, { h: 0, s: 100, l: 100, a: 1 });
var Vector = extend.bind(null, { x: 0, y: 0 });
var Particle = extend.bind(null, {
pos: Vector(),
vel: Vector(),
angle: 0,
speed: 0,
radius: 0,
rotation: 0,
color: Color()
});
var colors = [Color({ h: 20, s: 100, l: 50 }), Color({ h: 200, l: 50 }), Color({ h: 300, l: 50 }), Color({ h: 100, l: 40 })];
var animationLoop = function animationLoop(scope) {
if (scope.animation) {
scope.animation(animationLoop.bind(null, scope));
}
var ctx = scope.ctx;
var canvas = ctx.canvas;
var rc = rough.canvas(canvas);
ctx.clearRect(0, 0, canvas.width, canvas.height);
scope.particles.map(function (p, i) {
p.pos.y -= p.speed;
if (i % 2) {
p.pos.x = p.pos.x + Math.sin(p.angle) * .2;
} else {
p.pos.x = p.pos.x - Math.cos(p.angle) * .2;
}
p.angle += .01;
rc.circle(p.pos.x, p.pos.y, p.radius, {
fill: parseColor(p.color),
roughness: Math.random() * 1.5,
hachureGap: p.hachureGap,
hachureAngle: p.hachureAngle
});
rc.line(p.pos.x, p.pos.y + p.radius * 1.2, p.pos.x, p.pos.y + p.radius / 2, {
bowing: Math.random() * 3
});
if (p.pos.y + p.radius * 3 < 0) {
p.pos.y = canvas.height + p.radius * 3;
p.pos.x = Math.random() * (canvas.width - p.radius);
}
});
};
var scope = {
animation: requestAnimationFrame.bind(null),
ctx: document.createElement('canvas').getContext('2d'),
title: 'Brian Douglas',
rotation: 0,
particles: []
};
~function (scope) {
var canvas = scope.ctx.canvas;
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
document.body.appendChild(canvas);
var particleCount = 50;
while (particleCount--) {
scope.particles.push(Particle({
pos: {
x: Math.random() * canvas.width,
y: Math.random() * canvas.height
},
speed: Math.random() + .2,
radius: Math.random() * 60 + 20,
color: colors[Math.floor(Math.random() * colors.length)],
hachureAngle: Math.random() * 90,
hachureGap: Math.random() * 8 + 1
}));
}
animationLoop(scope);
}(scope);
if (!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
window.addEventListener('resize', function () {
scope.ctx.canvas.width = window.innerWidth;
scope.ctx.canvas.height = window.innerHeight;
});
}
android气球上升的属性动画,html5 canvas告白气球上升背景动画特效相关推荐
- 粒子背景php,html5+canvas圆形粒子移动背景动画特效
html5+canvas圆形粒子移动背景动画特效 this.update = function () { var lastPoint = { x: _this.x, y: _this.y }; // ...
- html飞机动画,html5 canvas纸飞机跟随鼠标飞行动画
这是一款效果很酷的html5 canvas纸飞机跟随鼠标飞行动画.插件中使用了paper.js来构建场景中的各种元素. HTML html结构只需要一个canvas,并给它一个id triangle- ...
- c语言烟花生日快乐图片,html5 canvas生日快乐文字烟花背景动画特效代码下载
特效描述:生日快乐 文字烟花 背景动画.html5基于canvas绘制酷炫的烟花动画,支持文字烟花适用于生日快乐主题网页动态背景特效. 代码结构 1. 引入JS 2. HTML代码 var canva ...
- html5钻石,html5 canvas发光的钻石背景动画特效
特效描述:html5canvas 发光的钻石 背景动画特效.html5 canvas three.js绘制闪烁的钻石背景动画,跟随鼠标移动改变形状效果. 代码结构 1. 引入JS 2. HTML代码 ...
- 五十个html js特效动画,html5 canvas酷炫的月食动画特效
特效描述:html5 canvas 月食动画特效.html5月食动画 代码结构 1. 引入JS 2. HTML代码 varying vec3 vNormal; void main() { vNorma ...
- 用html语言制作表白动画,HTML5 Canvas程序员经典爱情表白动画
JavaScript 语言: JaveScriptBabelCoffeeScript 确定 var $window = $(window), gardenCtx, gardenCanvas, $gar ...
- html5 canvas雨点打到窗玻璃动画
html5 canvas雨点打到窗玻璃动画 HTML5下雨效果 效果预览:http://hovertree.com/texiao/html5/4.htm 以下是代码: 1 <!doctype h ...
- HTML5+Canvas漂亮的3D烟花动画生日特效,节日特效,烟花
fireworks HTML5+Canvas漂亮的3D烟花动画生日特效,节日特效,烟花 https://github.com/louislivi/fireworks
- html圆点跟链接线,html5 canvas简洁的圆点线动画特效
特效描述:html5 canvas简洁的 圆点线动画特效.html5 canvas绘制简洁动画特效,圆点和线条连接的背景动画特效. 代码结构 1. HTML代码 在美国的研究 我们一起可以在学术界产生 ...
最新文章
- 第一家线下场景大数据平台Anchor-Point诞生
- 华南农业大学在Annual Review of Microbiology发表三篇综述文章
- 20165201 实验五 网络编程与安全
- mac使用被动ftp模式(pasv)_网络安全工程师与白帽子黑客教你:Kali Linux之使用Metasploit进行FTP服务扫描实战...
- 《OpenGL ES 3.x游戏开发(上卷)》一1.5 Android应用程序运行的机制
- android 广播 关闭对话框,Android 对话框、信息提示和菜单
- C++ Primer Plus 读书笔记(第8、9章)
- echart的x轴换行
- 模糊PID(自适应模糊PID、fuzzy PID)的基本原理及应用举例 by 研三笔记
- 计算机家庭网络共享,教大家家庭局域网如何共享
- GitLab 设置为中文版
- LR 的上传文件与下载文件
- 为响应国家号召1+X证书Web前端开发最新考试模拟题
- Shell脚本-NF、FS(OFS)、RS(ORS)、NR(FNR)
- win10更新后任务栏卡死解决方法
- 字典特征提取,文本特征提取。
- 前端攻城狮的自我修养1
- 百问网七天物联网课程学习笔记——单片机时钟
- 可私有化部署的物联网云平台----性能稳定可靠 ,低成本
- 工控服务器性能指标,5点弄懂工控机内存条
热门文章
- 很高兴加入 英文_小学生出国留学,但英文不好,日常对话该怎么做?
- python datetime模块timedelta_Python timedelta模块 时间增减用法
- AES算法细节及应用
- batch print pro_研之有效 | 高效编程之Batch批处理程序
- 用Pandas Index高效比对百万级别文本
- 怎么用计算机打吃鸡,用电脑也能玩“吃鸡手游”,屏幕大更容易找到对手的位置!...
- Java比较两个数字的大小
- SQL2014安装以后连接失败解决方案
- java mysql 工具类_Java SE 之 数据库操作工具类(DBUtil)设计
- 最新抖音卡直播广场,教你如何提高直播人气?