当前位置: 首页 > news >正文

动易网站cms漳州城乡和建设局网站首页

动易网站cms,漳州城乡和建设局网站首页,wordpress去除版权,常德论坛网模仿下雨的特效#xff0c;雨点从空中随机飘落。 这个特效使用了H5的新特性Canvas。 效果演示 代码展示 body代码 !DOCTYPE html html langen head meta charsetUTF-8 titleH5 Canvas下雨特效/titl…模仿下雨的特效雨点从空中随机飘落。 这个特效使用了H5的新特性Canvas。 效果演示 代码展示 body代码 !DOCTYPE html html langen head meta charsetUTF-8 titleH5 Canvas下雨特效/titlelink relstylesheet hrefcss/style.css/head bodycanvas idrain/canvas/body script srcjs/script.js/script /html css样式代码 html,body{padding: 0px;margin: 0px;height: 100%;overflow: hidden;background: black;font-family: Gayathri, sans-serif; }#rain{position: absolute;left: 0px;top: 0px;user-select: none; }media only screen and (max-width: 600px) {.raindrop:nth-child(3) {display: none;} }js代码 var c document.getElementById(rain);c.width window.innerWidth; c.height window.innerHeight;var ctx c.getContext(2d);let rainDrops []; let elements document.getElementsByClassName(raindrop); let length 30; let speed 15;let angle 90 * Math.PI / 180; let angleSin Math.sin(angle); let angleCos Math.cos(angle);let spawnInterval setInterval(newDrop, 50);window.addEventListener(resize, onResize);document.addEventListener(visibilitychange, function() {if (document.hidden) {clearInterval(spawnInterval);} else {spawnInterval setInterval(newDrop, 50);} });function RainDrop(x, y, angle) {this.x x;this.y y;rainDrops.push(this); }function newDrop() {for (let x 0; x 50; x) {new RainDrop(Math.random() * c.width, -40 - 100 * Math.random(), angle);} }update();function update() {for (let x 0; x rainDrops.length; x) {let drop rainDrops[x];drop.x speed * angleCos;drop.y speed * angleSin;drop.endX drop.x length * angleCos;drop.endY drop.y length * angleSin;if (drop.y c.height) {rainDrops.splice(x, 1);x--;}}draw(); }function draw() {ctx.clearRect(0, 0, c.width, c.height);ctx.lineWidth 1;ctx.lineCap round;ctx.strokeStyle #0984e3;let gradient ctx.createLinearGradient(0, 0, 0, c.height);gradient.addColorStop(0, #00a8ff);gradient.addColorStop(0.6, #00a8ff);gradient.addColorStop(1, white);ctx.strokeStyle gradient;ctx.beginPath();for (let i 0; i rainDrops.length; i) {ctx.moveTo(Math.floor(rainDrops[i].x), Math.floor(rainDrops[i].y));ctx.lineTo(Math.floor(rainDrops[i].endX), Math.floor(rainDrops[i].endY));}ctx.stroke();clearRegions();window.requestAnimationFrame(update); }function onResize() {c.width window.innerWidth;c.height window.innerHeight; }function clearRegions() {ctx.globalCompositeOperation destination-out;for (let i 0; i elements.length; i) {let boundingBox elements[i].getBoundingClientRect();let yDistanceBottom c.height - boundingBox.bottom;let yDistanceTop c.height - boundingBox.top;let bottomLeftX boundingBox.left yDistanceBottom * Math.tan(Math.PI / 2 - angle);let bottomRightX boundingBox.right yDistanceBottom * Math.tan(Math.PI / 2 - angle);let bottomLeftX2 boundingBox.left yDistanceTop * Math.tan(Math.PI / 2 - angle);let bottomRightX2 boundingBox.right yDistanceTop * Math.tan(Math.PI / 2 - angle);ctx.beginPath();ctx.moveTo(boundingBox.left, boundingBox.bottom);ctx.lineTo(bottomLeftX, c.height);ctx.lineTo(bottomRightX, c.height);ctx.lineTo(boundingBox.right, boundingBox.bottom);ctx.closePath();ctx.fill();ctx.beginPath();ctx.moveTo(boundingBox.left, boundingBox.top);ctx.lineTo(bottomLeftX2, c.height);ctx.lineTo(bottomRightX2, c.height);ctx.lineTo(boundingBox.right, boundingBox.top);ctx.closePath();ctx.fill();}ctx.globalCompositeOperation source-over; }程序到此结束快实现属于我的雨滴特效吧
http://www.lebaoying.cn/news/5097.html

相关文章:

  • 安庆市网站建设wordpress ip设置
  • 苏州网站建设姜超手机扁平化网站模版
  • 温州专门做网站wordpress忘记密码
  • 温州优化网站模板之家
  • 别人给我们做的网站如何关闭怎么让自己的网站
  • 做企业网站需要购什么seo服务收费
  • 网站添加文章梅州市住房和城乡建设局网站
  • 帝国cms 调用网站名称少儿编程加盟店电话
  • 新圩做网站公司wordpress 加速乐
  • 如何学会建网站wordpress修改上传附件大小
  • 网站页面代码优化用iis搭建网站
  • 餐饮类网站模板wordpress评论框必填加星
  • 网站如何做超链接安康鼎盛网站建设
  • 优质的网站建设推广网站开发采集工具
  • asp.net网站建设论文网站建设陆金手指谷哥4
  • 网站备案ip接效果图做网站
  • windows2008 iis 网站wordpress 亲子主题
  • wordpress 前端展示移动网站怎么做优化
  • 网站图片广告代码上海市官网
  • 溧阳网站定制iapp源码
  • 提供域名申请的网站电子商务网站的建设与流程
  • 专业的网站建设托管wordpress跳转下载页面
  • 中廉建设网站网站空间怎么进
  • 付给招聘网站的费用怎么做分录仿 手机 网站模板html源码
  • 怎么做网站的思维导图网站二次开发模板
  • 网站建设报价单 文库婚纱摄影网站报价
  • 网站title设置福州外网站建设
  • 河西网站建设制作哈尔滨怎样快速建站
  • 建设招标项目常挂网站有哪些星宿网站建设
  • 备案号放网站下面居中做国外网站做什么内容