Skip to content

Instantly share code, notes, and snippets.

Last active July 25, 2018 18:41
  • Star 3 You must be signed in to star a gist
  • Fork 7 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
SVG feGaussianBlur
license: gpl-3.0

A demonstration of SVG's Gaussian blur filter effect: the svg:feGaussianBlur element.

Image source: GitHub's octodex.

<!DOCTYPE html>
<meta charset="utf-8">
body {
position: relative;
width: 960px;
height: 500px;
input {
position: absolute;
bottom: 20px;
right: 20px;
width: 200px;
<script src="//"></script>
var svg ="body").append("svg")
.attr("width", 960)
.attr("height", 500);
var filter = svg.append("defs")
.attr("id", "blur")
.attr("stdDeviation", 5);"body").append("input")
.attr("type", "range")
.attr("min", 0)
.attr("max", 100)
.attr("value", 25)
.on("change", blur);
var image = new Image;
image.src = "octocat.jpg";
image.onload = load;
function load() {
.attr("xlink:href", this.src)
.attr("width", "100%")
.attr("height", "100%")
.attr("filter", "url(#blur)");
function blur() {
filter.attr("stdDeviation", this.value / 5);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment