zoukankan      html  css  js  c++  java
  • 黑客帝国效果

    <!DOCTYPE html>
    <html>
    <head>
    <title>黑客帝国效果</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;

    // var texts = 'бвгдеёжзийклмнопрстуфхцчшщъыьэюя'.split('');
    var texts = '10'.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.99){
    drops[i] = 0;
    }

    drops[i]++;
    }
    }

    setInterval(draw, 30);
    </script>
    </body>

  • 相关阅读:
    疑问:关于strcmp()以及此指针表现形式*(char * *)a
    后置操作符
    php学习笔记(一)
    windows php环境配置
    关于wifi破解那点事
    C++使用大漠插件及截图
    跨平台网络编程
    reinterpret_cast, static_cast , dynamic_cast ,const_cast 的总结
    初识按键精灵
    python 程序打包-----py2exe
  • 原文地址:https://www.cnblogs.com/php12-cn/p/8472013.html
Copyright © 2011-2022 走看看