前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >cssjshtml 黑客帝国背景 javascript

cssjshtml 黑客帝国背景 javascript

作者头像
葫芦
发布2019-04-17 16:02:01
9750
发布2019-04-17 16:02:01
举报
文章被收录于专栏:葫芦葫芦

效果:

黑客帝国数字背景js

代码语言:javascript
复制
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>hk</title>
</head>
<body>
<canvas id='d1' height="1080" width="1920"
        style="position:fixed;z-index:-2;filter: alpha(opacity:50);opacity: 0.5"></canvas>
<script>
    var canvas = document.getElementById('d1');
    var ctx = canvas.getContext('2d');


    canvas.height = window.innerHeight;
    canvas.width = window.innerWidth;

    var texts = '0123456789'.split('');

    var fontSize = 16;
    var columns = canvas.width / fontSize;
    var drops = [];
    for (var x = 0; x < columns; x++) {
        drops[x] = 1;
    }

    function draw() {
        ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
        ctx.fillRect(0, 0, canvas.width, canvas.height);

        ctx.fillStyle = '#0F0';
        ctx.font = fontSize + 'px arial';
        for (var i = 0; i < drops.length; i++) {
            var text = texts[Math.floor(Math.random() * texts.length)];
            ctx.fillText(text, i * fontSize, drops[i] * fontSize);

            if (drops[i] * fontSize > canvas.height || Math.random() > 0.95) {
                drops[i] = 0;
            }

            drops[i]++;
        }
    }

    setInterval(draw, 33);
</script>
</body>
</html>

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2017/01/19 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 效果:
  • 黑客帝国数字背景js
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档