1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > JS实现好看的鼠标跟随彩色气泡效果(code)

JS实现好看的鼠标跟随彩色气泡效果(code)

时间:2021-02-06 20:42:44

相关推荐

JS实现好看的鼠标跟随彩色气泡效果(code)

web前端|js教程

JS

web前端-js教程

下面本篇文章给大家介绍一下JS实现好看的鼠标跟随彩色气泡效果,文中示例代码介绍的非常详细

ionic2 项目源码下载,vscode终端无法粘贴,ubuntu 定位,tomcat指南.pdf,sqlite3更新数据通知,优秀网页设计联盟,如何查看数据库主机,网站备案的服务器租用,js音频插件下载,前端大数据展示框架设计,卸载爬虫,php 判断手机,蜘蛛侠seo,springboot拼音插件,html常见标签及用法,faq网站源码,在线手机端网页制作,wordpress国外模板安装,织梦后台出现垃圾文章,Html5 开发手机页面,php 流程管理系统,快站制作程序lzw

greenbrowser 源码,vscode 学习,ubuntu安装pam,zooker tomcat,arm sqlite应用,云服务器好吗,飞飞2.7采集插件,搭建框架属于前端,python爬虫网,php实现页面跳转,灰行业seo,仿韩国网站源码,图左右 滑动网页模板,仿简书 html 模板,php 页面上一次插入多条记录,基于java的驾校管理系统,网络调试助手源程序lzw

具体代码:

ionic拍照源码下载,在vscode中npm无效,Ubuntu客人账号,tomcat集群怎么设置,爬虫做坏事,php数据库语言,seo优化按天收费吗,wordpress制作小说网站模板下载,dede婚纱摄影模板三亚婚纱摄影源码整站lzw

*{ margin:0;padding:0; } body{overflow:hidden;} #canvas{ background-color:black; /*width:100%; height:100vh;*/ } var canvas = document.querySelector(#canvas);var ctx = canvas.getContext("2d");var starlist = [];function init(){ canvas.width = window.innerWidth; canvas.height = window.innerHeight;}init();window.onresize = init; canvas.addEventListener(mousemove,function(e){ starlist.push(new Star(e.offsetX,e.offsetY)); console.log(starlist)}) function random(min,max){ return Math.floor((max-min)*Math.random()+ min);} function Star(x,y){ this.x = x; this.y = y; this.vx = (Math.random()-0.5)*3; this.vy = (Math.random()-0.5)*3; this.color = gb(+random(0,256)+,+random(0,256)+,+random(0,256)+); this.a = 1; console.log(this.color); this.draw();}Star.prototype={ draw:function(){ ctx.beginPath(); ctx.fillStyle = this.color; ctx.globalCompositeOperation=lighter ctx.globalAlpha= this.a; ctx.arc(this.x,this.y,30,0,Math.PI*2,false); ctx.fill(); this.updata(); }, updata(){ this.x+=this.vx; this.y+=this.vy; this.a*=0.98; }}console.log(new Star(150,200));function render(){ ctx.clearRect(0,0,canvas.width,canvas.height) starlist.forEach((item,i)=>{ item.draw(); if(item.a<0.05){ starlist.splice(i,1); } }) requestAnimationFrame(render);}render();

更多jQuery、Javascript特效,推荐访问:js特效大全!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。