一个超炫的Canvas背景,做网页背景挺好看

图片[1]-一个超炫的Canvas背景,做网页背景挺好看-轻刻年轮
预览页面的传送门:
LY-jilei

代码都在html里,(右键查看源代码即可得到啦)
这篇文章会有点水,哈哈哈哈~睡觉

想想还是贴个代码吧
js

document.addEventListener('touchmove', function (e) {
                e.preventDefault()
            })
            var c = document.getElementsByTagName('canvas')[0],
                x = c.getContext('2d'),
                pr = window.devicePixelRatio || 1,
                w = window.innerWidth,
                h = window.innerHeight,
                f = 90,
                q,
                m = Math,
                r = 0,
                u = m.PI*2,
                v = m.cos,
                z = m.random
            c.width = w*pr
            c.height = h*pr
            x.scale(pr, pr)
            x.globalAlpha = 0.6
            function i(){
                x.clearRect(0,0,w,h)
                q=[{x:0,y:h*.7+f},{x:0,y:h*.7-f}]
                while(q[1].xh||t<0) ? y(p) : t
            }
            document.onclick = i
            document.ontouchstart = i
            i()

css

canvas {
                position: absolute;
                top: 0;
                left: 0;
                z-index: 0;
                width: 100%;
                height: 100%;
                pointer-events: none;
            }
© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享
评论 共1条

请登录后发表评论