电子雨代码-html

电子雨代码

动画效果展示

代码

javascript 复制代码
<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <title>Code</title>

    <style>
        body {

            margin: 0;

            overflow: hidden;

        }
    </style>

</head>

<body>

    <canvas id="myCanvas"></canvas>

    <script>

        const width = document.getElementById("myCanvas").width = screen.availWidth;

        const height = document.getElementById("myCanvas").height = screen.availHeight;

        const ctx = document.getElementById("myCanvas").getContext("2d");

        const arr = Array(Math.ceil(width / 10)).fill(0);

        const str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split("");

        function rain() {

            ctx.fillStyle = "rgba(0,0,0,0.05)";

            ctx.fillRect(0, 0, width, height);

            ctx.fillStyle = "#0f0";

            arr.forEach(function (value, index) {

                ctx.fillText(str[Math.floor(Math.random() * str.length)], index * 10, value + 10);

                arr[index] = value >= height || value > 8888 * Math.random() ? 0 : value + 10;

            });

        }

        setInterval(rain, 30);

    </script>

</body>

</html>
相关推荐
问今域中3 分钟前
Vue的computed用法解析
前端·javascript·vue.js
扶苏100234 分钟前
详解Vue3的provide和inject
前端·javascript·vue.js
武帝为此1 小时前
【Shell 函数库介绍】
前端·chrome
yuki_uix2 小时前
GraphQL 重塑:从 API 语言到 AI 时代的"逻辑神经系统"
前端·graphql
奋斗吧程序媛2 小时前
Vue3初体验(2)
前端·javascript·vue.js
css趣多多2 小时前
vue3的ref响应式,取值的时候自动补全value的设置,以及两种修改方式
前端
学习3人组2 小时前
Win11 使用 Proxifier 强制本地流量通过 Fiddler Classic 代理指南
前端·测试工具·fiddler
超绝大帅哥2 小时前
vue2vue3响应式
前端
Hhang2 小时前
Pageindex -- 新一代的文档智能检索
前端·人工智能
恋猫de小郭2 小时前
Claude Code 已经 100% 自己写代码,为什么 Anthropic 还有上百个工程职位空缺?
前端·人工智能·ai编程