NEWS

[JAVSCRIPT] Source code Matrix Rain trên Website

[JAVSCRIPT] Source code Matrix Rain trên Website
Đăng bởi: Thảo Meo - Lượt xem: 3214 20:13:33, 09/08/2021THIẾT KẾ WEB

Xin chào các bạn, bài viết hôm nay mình sẽ chia sẻ đến các bạn source code matrix rain bằng Javascript để chạy trên Website.

[Javascript] Source code Matrix Rain

Dưới đây, là video demo script

Source code js:

<!DOCTYPE html>
<html>
<head>
    <title>Matrix Rain Javascript</title>
</head>

<body>
    <canvas id="canvas"></canvas>
    <style type="text/css">
body{margin: 0; padding: 0; overflow: hidden;}
</style>
<script type="text/javascript">
var canvas = document.getElementById('canvas');
        var ctx = canvas.getContext('2d');


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

        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>

Thanks for watching!

DOWNLOAD SOURCE

Tags: matrix rain jsmatrix rain javascript

THÔNG TIN TÁC GIẢ

BÀI VIẾT LIÊN QUAN

[JAVSCRIPT] Source code Matrix Rain trên Website
Đăng bởi: Thảo Meo - Lượt xem: 3214 20:13:33, 09/08/2021THIẾT KẾ WEB

Đăng ký kênh Youtube

CÁC BÀI CÙNG CHỦ ĐỀ

.