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

HTML5 Canvas实现烟花绽放特效_html5教程技巧

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

本文主要包含HTML5,Canvas,烟花绽放等相关知识,匿名希望在学习及工作中可以帮助到您
本文为大家带来了一款,免费而又安全环保的HTML5 Canvas实现的放烟花特效。

效果如下:

代码如下:

  1. >
  2. <html>
  3. <head>
  4. <title>Canvas 实现放烟花特效title>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width,height=device-height,inital-scale=1.0,maximum-scale=1.0,user-scalable=no">
  8. <style type="text/css">
  9. html,body{height:100%;margin:0;padding:0}
  10. ul,li{text-indent:0;text-decoration:none;margin:0;padding:0}
  11. img{border:0}
  12. body{background-color:#000;color:#999;font:100%/18px helvetica, arial, sans-serif}
  13. canvas{cursor:crosshair;display:block;left:0;position:absolute;top:0;z-index:20}
  14. #header img{width:100%; height:20%;}
  15. #bg img{width:100%; height:80%;}
  16. #header,#bg{position:fixed;left:0;right:0;z-index:10}
  17. #header{top:0}
  18. #bg{position:fixed;z-index:1;bottom:0}
  19. audio{position:fixed;display:none;bottom:0;left:0;right:0;width:100%;z-index:5}
  20. style>
  21. head>
  22. <body>
  23. <div id="bg">
  24. <img id="bgimg" src="http://img.ivsky.com/img/tupian/pre/201508/02/yuzhou_xingkong_yu_yueliang-006.jpg">
  25. div>
  26. <script src="http://cdn.bootcss.com/jquery/2.2.0/jquery.min.js">script>
  27. <script>
  28. $(function(){
  29. var Fireworks = function(){
  30. var self = this;
  31. // 产生烟花随机数
  32. var rand = function(rMi, rMa){
  33. //按位取反运算符
  34. return ~~((Math.random()*(rMa-rMi+1))+rMi);
  35. },hitTest = function(x1, y1, w1, h1, x2, y2, w2, h2){
  36. return !(x1 + w1 < x2 || x2 + w2 < x1 || y1 + h1 < y2 || y2 + h2 < y1);
  37. };
  38. //请求动画帧
  39. window.requestAnimFrame=function(){
  40. return window.requestAnimationFrame
  41. ||window.webkitRequestAnimationFrame
  42. ||window.mozRequestAnimationFrame
  43. ||window.oRequestAnimationFrame
  44. ||window.msRequestAnimationFrame
  45. ||function(callback){
  46. window.setTimeout(callback,1000/60);
  47. }
  48. }();
  49. self.init = function(){
  50. self.canvas = document.createElement('canvas');
  51. //canvas 全屏
  52. selfself.canvas.width = self.cw = $(window).innerWidth();
  53. selfself.canvas.height = self.ch = $(window).innerHeight();

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

  • HTML5知识点总结
  • HTML5的本地存储
  • HTML5本地存储之IndexedDB
  • Html5实现文件异步上传功能
  • Html5新标签datalist实现输入框与后台数据库数据的动态匹配
  • 详解HTML5 window.postMessage与跨域
  • HTML5拖放API实现拖放排序的实例代码
  • 解决html5中video标签无法播放mp4问题的办法
  • HTML5新特性 多线程(Worker SharedWorker)
  • Html5新增标签有哪些

相关文章

  • 2018-12-03h5输入框提示语 + 正常文本框提示语的实现方法
  • 2018-12-03HTML5高级编程之图形扭曲及其应用三(扩展篇)
  • 2018-12-03HTML5有哪些新特征_html5教程技巧
  • 2018-12-03教你如何塑造JavaScript牛逼形象
  • 2018-12-03HTML参考
  • 2018-12-03HTML5 MiranaVideo播放器 (代码开源) _html5教程技巧
  • 2017-08-06利用简洁的图片预加载组件提升html5移动页面的用户体验
  • 2018-12-03利用H5实现一个轮播器(触屏版)的实例教程
  • 2017-08-06html5构建触屏网站之touch事件介绍
  • 2017-08-06HTML5边玩边学(2)基础绘图实现方法

文章分类

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

最近更新的内容

    • Flash在苹果、微软、火狐的围剿下生存期还有几年?有没有完善的替代方案?
    • HTML5本地数据库基础操作详解
    • HTML5新增元素、标签总结
    • 详解HTML5头部meta标签的功能
    • HTML5游戏开发开源库件lufylegend1.4.1发布
    • HTML5制作基于模拟现实物理效果的游戏
    • HTML 5 应用的用户体验能达到本地应用那么好吗?
    • 带你认识HTML57个混合式移动开发框架
    • 如何使用html5与css3完成google涂鸦动画
    • HTML5新增的8类INPUT输入类型介绍_html5教程技巧

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

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