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

字符乱码特效

cjw1231年前 (2024-10-15)网站应用2300
<!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://www.cjw123.com/blog/?id=127

标签: htmlcss
分享给朋友:

相关文章

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

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

js实现第一次访问站时点击任何地方都先弹出一个广告页

<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <t...

彩色流转文字代码

<style>#nr { font-size: 15px; margin:  0; background:  -webkit-linear-gradient(left,#ffffff,#ff0000 6.2...

一个网站网页快照截图的接口

如果您的网站想展示某个网站的快照截图的话使用这个网页快照截图的接口确实比较方便网页快照截图接口使用https://s0.wp.com/mshots/v1/网址?w=宽度&h=高度示例https://s0.wp.com/mshots/v1/www.cjw123.com?w=1900&h...

纯CSS实现菜单炫酷点击展开收起效果

通过纯css3实现展开收缩的弹性动画菜单,可以应用于PC端或移动端页面中,非常实用效果也非常的炫酷,喜欢的码友们可以尝试一下,效果如下:完整代码如下:<!doctype html><html><head><meta charset=&qu...

摇摆的灯光

点击运行看演示效果!<!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">...

发表评论

访客

看不清,换一张

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