电子雨代码-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>
相关推荐
IT_陈寒4 分钟前
Redis的SETNX并发问题让我加了三天班
前端·人工智能·后端
demo007x19 分钟前
Docling 文档转换以及技术架构分析
前端·后端·程序员
京东云开发者1 小时前
京东市民服务又“上新”!这次是黑龙江“龙易办”
前端
袋鱼不重2 小时前
我的神奇同事,AI 用多了居然写了个 Open In Codex
前端·后端·ai编程
Fireworks2 小时前
深入vue3源码解读 -- 1、响应式的基础概念
前端
程序员黑豆2 小时前
JDK 下载安装与配置详细教程
java·前端·ai编程
hunterandroid2 小时前
文件存储:内部存储与外部存储
前端
NorBugs3 小时前
飞机大战 Low 版 (Made in AI)
前端
angerdream3 小时前
Android手把手编写儿童手机远程监控App之agentweb如何实现全屏
前端
星栈3 小时前
10 分钟跑起第一个 Dioxus 应用:`dx` CLI、`rsx!` 和热更新好不好用
前端·rust·前端框架