使用HTML5 Canvas进行静态/噪音动画

Dee*_*eyi 6 html css

所以我刚刚在Awwwards探索了一大堆新的网站.其中一个特别引起我注意的是这个.我刚刚做了一些基本到中间的CSS东西.我想知道这些家伙是如何得到他们的字体的噪音/干扰?我完全无能为力.试过检查代码,无法理解.

我知道我不能很快建立整个事物,但我喜欢嘈杂背景的想法.

我该怎么办?任何指针将不胜感激:)

umm*_*sla 8

这是Lucas Bebber的Glitch SVG效果.

这是 original and working demo

这是 code snippets

body {
  background: black;
  font-family: 'Varela', sans-serif;
}
.glitch {
  color: white;
  font-size: 100px;
  position: relative;
  width: 400px;
  margin: 0 auto;
}
@keyframes noise-anim {
  $steps: 20;
  @for $i from 0 through $steps {
    # {
      percentage($i*(1/$steps))
    }
    {
      clip: rect(random(100)+px, 9999px, random(100)+px, 0);
    }
  }
}
.glitch:after {
  content: attr(data-text);
  position: absolute;
  left: 2px;
  text-shadow: -1px 0 red;
  top: 0;
  color: white;
  background: black;
  overflow: hidden;
  clip: rect(0, 900px, 0, 0);
  animation: noise-anim 2s infinite linear alternate-reverse;
}
@keyframes noise-anim-2 {
  $steps: 20;
  @for $i from 0 through $steps {
    # {
      percentage($i*(1/$steps))
    }
    {
      clip: rect(random(100)+px, 9999px, random(100)+px, 0);
    }
  }
}
.glitch:before {
  content: attr(data-text);
  position: absolute;
  left: -2px;
  text-shadow: 1px 0 blue;
  top: 0;
  color: white;
  background: black;
  overflow: hidden;
  clip: rect(0, 900px, 0, 0);
  animation: noise-anim-2 3s infinite linear alternate-reverse;
}
Run Code Online (Sandbox Code Playgroud)
<link href='http://fonts.googleapis.com/css?family=Varela' rel='stylesheet' type='text/css'>

<div class="glitch" data-text="GLITCH">GLITCH</div>
Run Code Online (Sandbox Code Playgroud)

  • 哇.这比我需要的更多.谢谢你.我只想要方向.人们如何通过投票来攻击你,这很有趣.我不了解某种社区政策吗?我觉得这个问题符合正确的利益. (3认同)
  • 我想,有些开发人员只是脾气暴躁 (3认同)