Skip to content

Instantly share code, notes, and snippets.

@pstuffa
Last active May 22, 2018 17:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pstuffa/d2368185d3687c529c9cd748c9b11e5f to your computer and use it in GitHub Desktop.
Save pstuffa/d2368185d3687c529c9cd748c9b11e5f to your computer and use it in GitHub Desktop.
Visual Snow
license: mit

Testing out using svg noise filters to recreate the symptons of visual snow

<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
body {
padding: 0px;
margin: 0px
}
</style>
</head>
<body>
<script>
var margin = {top: 0, right: 0, bottom: 0, left: 0},
width = window.innerWidth - margin.left - margin.right,
height = window.innerHeight - margin.top - margin.bottom;
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg.append("rect")
.attr("width", width/2)
.attr("height", height)
.style("fill","#000");
svg.append("rect")
.style("filter", "url(#spect)")
.attr("width", width/2.2)
.attr("height", height)
.style("fill","none")
.style("opacity", .5);
svg.append("rect")
.style("filter", "url(#spect)")
.attr("width", width)
.attr("height", height)
.style("fill","none")
.style("opacity", .5);
var defs = svg.append("defs");
var filter = defs.append("filter").attr("id","spect");
var turbulence = filter.append("feTurbulence")
.attr("baseFrequency",1)
.attr("numOctaves",1)
.attr("seed", 1);
var i = 1;
d3.interval(function() {
i++;
turbulence.transition()
.attr("seed",i)
}, 100)
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment