当前位置:首页 > 网站应用 > 正文内容

字符乱码特效

cjw1231年前 (2024-10-15)网站应用2190
<!DOCTYPE html>
<html>
 <head>
  <meta charset="utf-8">
        <title>字符乱码特效</title>
 </head>
 <style>
  * {
   margin: 0;
   padding: 0;
  }

  body {
   overflow: hidden;
  }
 </style>
 <body>
  <canvas id="canvas" width="1280" height="1024"> 您的浏览器不支持canvas标签,请您更换浏览器 </canvas>
 </body>
 <script>
  var canvas = document.getElementById("canvas");
  var can = canvas.getContext("2d");
  var s = window.screen;
  var w = canvas.width = s.width;
  var h = canvas.height = s.height;

  can.fillStyle = color2();

  var words = Array(256).join("1").split("");

  setInterval(draw, 50);

  function draw() {
   can.fillStyle = 'rgba(0,0,0,0.05)';
   can.fillRect(0, 0, w, h);
   can.fillStyle = color2();
   words.map(function(y, n) {
    text = String.fromCharCode(Math.ceil(65 + Math.random() * 57));
    x = n * 10;
    can.fillText(text, x, y)
    words[n] = (y > 758 + Math.random() * 484 ? 0 : y + 10);
   });
  }

  function color1() {
   var colors = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd', 'e', 'f'];
   var color = "";
   for (var i = 0; i < 6; i++) {
    var n = Math.ceil(Math.random() * 15);
    color += "" + colors[n];
   }
   return '#' + color;
  }

  function color2() {
   var color = Math.ceil(Math.random() * 16777215).toString(16);
   while (color.length < 6) {
    color = '0' + color;
   }
   return '#' + color;
  }

  function color3() {
   return "#" + (function(color) {
    return new Array(7 - color.length).join("0") + color;
   })((Math.random() * 0x1000000 << 0).toString(16))
  }
 </script>
</html>


扫描二维码推送至手机访问。

版权声明:本文由追求完美发布,如需转载请注明出处。

本文链接:https://cjw123.com/blog/?id=127

标签: htmlcss
分享给朋友:

相关文章

html meta标签屏蔽搜索引擎的用法

html页面中的 meta 标签可以用来识别搜索引擎的蜘蛛类型,可以规定meta标签所在的html页面是否被蜘蛛抓取,下面是这个meta标签的用法,大家可以借鉴一下。搜索引擎的 meta 标签的解析下面是meta标签对搜索引擎的解析<meta name='robot...

纸张撕裂动画效果,网站错误404页源码

一款挺好看的404页源码,可以改成自己想要的提示页<html>    <head>    <meta charset="UTF-8"> &nbs...

css li超出自动隐藏代码

<style>  <!--  li {      width:200px;      white-space:nowrap;  &n...

js弹出居中窗口特效

<html> <head> <title>弹出窗口效果</title> <style> .black_overlay{display:none;position:absolute;top:0%;left:0%;width:100%;...

漂亮弹窗公告代码

<html xmlns="http://www.w3.org/1999/xhtml"> <head>   <meta http-equiv="Content-Type" con...

打字机效果的带超链接的新闻标题

<html> <head> <title>打字效果的带链接的新闻标题</title> <meta http-equiv="Content-Type" content="text/html;&...

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。