Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
change
css
body,html { margin:0; width:100%; overflow:hidden; } canvas { width:100%; } .control { position:absolute; } .control input { border:0; margin:0; padding:15px; outline:none; text-align:center; } .control button { border:0; margin:0; padding:15px; outline:none; background:#333; color:#fff; } .control button:focus,.control button:hover { background:#222 }
JavaScript
/*jshint esversion:6*/ var can = document.createElement("canvas"); document.body.appendChild(can); var ctx = can.getContext('2d'); function resize(){ can.width = window.innerWidth; can.height = window.innerHeight; } const max_radius = 3; const min_radius = 1; const drag = 50; window.onresize = function(){ resize(); }; function cfill(){ ctx.fillStyle = "#000"; ctx.fillRect(0,0,can.width,can.height); ctx.fill(); } var mouse = { x:-1000, y:-1000 }; can.onmousemove = function(e){ mouse.x = e.clientX; mouse.y = e.clientY; }; can.ontouchmove = function(e){ mouse.x = e.touches[0].clientX; mouse.y = e.touches[0].clientY; }; resize(); cfill(); function distance(x,y,x1,y1){ return Math.sqrt( ( x1-x ) * ( x1-x ) + ( y1-y ) * ( y1-y ) ); } class Particle{ constructor(pos,target,vel,color,radius){ this.pos = pos; this.target = target; this.vel = vel; this.color = color; this.radius = radius; var arr = [-1,1]; this.direction = arr[~~(Math.random()*2)]*Math.random()/10; } set(type,value){ this[type] = value; } update(){ this.radius += this.direction; this.vel.x = (this.pos.x - this.target.x)/drag; this.vel.y = (this.pos.y - this.target.y)/drag; if(distance(this.pos.x,this.pos.y,mouse.x,mouse.y) < 50){ this.vel.x += this.vel.x - (this.pos.x - mouse.x)/15; this.vel.y += this.vel.y - (this.pos.y - mouse.y)/15; } if(this.radius >= max_radius){ this.direction *= -1; } if(this.radius <= 1){ this.direction *= -1; } this.pos.x -= this.vel.x; this.pos.y -= this.vel.y; } draw(){ ctx.beginPath(); ctx.fillStyle = this.color; ctx.arc(this.pos.x,this.pos.y,this.radius,0,Math.PI*2); ctx.fill(); } } var particles = []; var colors = ["#bf1337","#f3f1f3","#084c8d","#f2d108","#efd282"]; var bool = true; var current = 0,i; function changeText(text){ var current = 0,temp,radius,color; cfill(); ctx.fillStyle = "#fff"; ctx.font = "120px Times"; ctx.fillText(text,can.width*0.5-ctx.measureText(text).width*0.5,can.height*0.5+60); var data = ctx.getImageData(0,0,can.width,can.height).data; cfill(); for(i = 0;i < data.length;i += 8){ temp = {x:(i/4)%can.width,y:~~((i/4)/can.width)}; if(data[i] !== 0 && ~~(Math.random()*5) == 1/*(temp.x % (max_radius+1) === 0 && temp.y % (max_radius+1) === 0)*/){ if(data[i+4] !== 255 || data[i-4] !== 255 || data[i+can.width*4] !== 255 || data[i-can.width*4] !== 255){ if(current < particles.length){ particles[current].set("target",temp); }else{ radius = max_radius-Math.random()*min_radius; temp = {x:Math.random()*can.width,y:Math.random()*can.height}; if(bool){ temp = {x:(i/4)%can.width,y:~~((i/4)/can.width)}; } color = colors[~~(Math.random()*colors.length)]; var p = new Particle( temp, {x:(i/4)%can.width,y:~~((i/4)/can.width)},{x:0,y:0}, color, radius); particles.push(p); } ++current; } } } bool = false; particles.splice(current,particles.length-current); } function draw(){ cfill(); for(i = 0;i < particles.length;++i){ particles[i].update(); particles[i].draw(); } } changeText("www.jq22.com"); setInterval(draw,1);
粒子
时间
文字
hover
canvas
3d
游戏
音乐
火焰
水波
轮播图
鼠标跟随
动画
css
加载动画
导航
菜单
按钮
滑块
tab
弹出层
统计图
svg
×
Close
在线代码下载提示
开通在线代码永久免费下载,需支付20jQ币
开通后,在线代码模块中所有代码可终身免费下!
您已开通在线代码永久免费下载,关闭提示框后,点下载代码可直接下载!
您已经开通过在线代码永久免费下载
对不起,您的jQ币不足!可通过发布资源 或
直接充值获取jQ币
取消
开通下载
<!doctype html> <html> <head> <meta charset="utf-8"> <title>液态粒子字体-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号