Toggle navigation
在线编辑器
在线代码
文本比较
jQuery下载
前端库
在线手册
登录/注册
下载代码
html
css
js
分享到微信朋友圈
X
html
css
body{ background: #000;overflow: hidden }
JavaScript
var txt = "jq22.com"; var txtH = 100; var font = "sans-serif"; var bg = "#000"; var rayColor1 = "#e0f7fa"; var rayColor2 = "#18ffff"; var fade = 1000; var canvas = document.getElementById("canvas"); var ctx = canvas.getContext("2d"); var cw = canvas.width = window.innerWidth; var ch = canvas.height = window.innerHeight; var w2 = cw/2; var h2 = ch/2; var pi = Math.PI; var pi2 = pi*.5; var txtCanvas = document.createElement("canvas"); var txtCtx = txtCanvas.getContext("2d"); txtCtx.font = txtH + "px " + font; txtCtx.textBaseline = "middle"; var txtW = Math.floor(txtCtx.measureText(txt).width); txtCanvas.width = txtW; txtCanvas.height = txtH*1.5; var gradient = ctx.createRadialGradient(w2, h2, 0, w2, h2, txtW); gradient.addColorStop(0, rayColor2); gradient.addColorStop(1, rayColor1); ctx.strokeStyle = gradient; txtCtx.fillStyle = gradient; txtCtx.font = txtH + "px " + font; txtCtx.textBaseline = "middle"; txtCtx.fillText(txt,0,txtH*.5); //dirty adjust for descends txtH *= 1.5; var bufferCanvas = document.createElement("canvas"); bufferCanvas.width = txtW; bufferCanvas.height = txtH; var buffer = bufferCanvas.getContext("2d"); //text start position var sx = (cw-txtW)*0.5 var sy = (ch-txtH)*0.5 ////generate data var rays = []; var txtData = txtCtx.getImageData(0,0,txtW,txtH); for (var i = 0; i < txtData.data.length; i+=4) { var ii = i/4; var row = Math.floor(ii/txtW) var col = ii%txtW var alpha = txtData.data[i+3] if(alpha !== 0){ var c = "rgba(" c += [txtData.data[i],txtData.data[i+1],txtData.data[i+2], alpha/255 ] c += ")"; rays.push(new Ray(Math.floor(ii/txtW), ii%txtW, c)); } } var current = 1; //start animation tick(); function tick() { ctx.clearRect(0,0,cw,ch) ctx.drawImage(bufferCanvas, 0, 0, current, txtH, sx, sy, current, txtH) ctx.save() ctx.globalAlpha = .07; ctx.globalCompositeOperation = "lighter"; if(drawRays(current)){ current++; current = Math.min(current, txtW) window.requestAnimationFrame(tick) }else{ fadeOut() } ctx.restore() } function fadeOut(){ ctx.clearRect(0,0,cw,ch) ctx.globalAlpha *= .95; ctx.drawImage(bufferCanvas, 0, 0, current, txtH, sx, sy, current, txtH) if(ctx.globalAlpha > .01){ window.requestAnimationFrame(fadeOut) }else{ window.setTimeout(restart, 500) } } function restart(){ for(var i = 0; i < rays.length; i++){ rays[i].reset() } ctx.globalAlpha = 1 buffer.clearRect(0,0,txtW,txtH) current = 1; tick(); } function drawRays(c){ var count = 0; ctx.beginPath() for(var i = 0; i < rays.length; i++){ var ray = rays[i]; if(ray.col < c){ count += ray.draw() } } ctx.stroke() return count !== rays.length; } function filterRays(r){ return Boolean(r); } function Ray(row, col, f){ this.col = col; this.row = row; var xp = sx + col; var yp = sy + row; var fill = f; var ath = (txtH/1.5) var a = pi2 * (this.row - ath*.5) / ath; if(a === 0){ a = (Math.random() - .5) * pi2; } var da = .02 * Math.sign(a); da += (Math.random() - .5) * .005; var l = 0; var dl = Math.random()*2 + 2; var buffered = false; this.reset = function(){ a = pi2 * (this.row - ath*.5) / ath; if(a === 0){ a = -pi2*.5; } l = 0; buffered = false } this.draw = function(){ if(l < 0){ if(!buffered){ buffer.fillStyle = fill; buffer.fillRect(this.col, this.row, 1, 1); buffered = true } return 1; }else{ ctx.moveTo(xp, yp) ctx.lineTo(xp + Math.cos(a) * l, yp + Math.sin(a) * l); a += da; l += Math.cos(a)*dl; return 0; } } }
粒子
时间
文字
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号