A demonstration of SVG's Gaussian blur filter effect: the svg:feGaussianBlur element.
Image source: GitHub's octodex.
A demonstration of SVG's Gaussian blur filter effect: the svg:feGaussianBlur element.
Image source: GitHub's octodex.
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/> | |
| <title></title> | |
| <style type="text/css"> | |
| input { | |
| position: absolute; | |
| bottom: 20px; | |
| right: 20px; | |
| width: 200px; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?2.5.0"></script> | |
| <script type="text/javascript"> | |
| var svg = d3.select("body").append("svg:svg") | |
| .attr("width", 960) | |
| .attr("height", 500); | |
| var filter = svg.append("svg:defs") | |
| .append("svg:filter") | |
| .attr("id", "blur") | |
| .append("svg:feGaussianBlur") | |
| .attr("stdDeviation", 5); | |
| svg.append("svg:image") | |
| .attr("xlink:href", "http://octodex.github.com/images/original.jpg") | |
| .attr("width", "100%") | |
| .attr("height", "100%") | |
| .attr("filter", "url(#blur)"); | |
| d3.select("body").append("input") | |
| .attr("type", "range") | |
| .attr("min", 0) | |
| .attr("max", 100) | |
| .attr("value", 25) | |
| .on("change", blur); | |
| function blur() { | |
| filter.attr("stdDeviation", this.value / 5); | |
| } | |
| </script> | |
| </body> | |
| </html> |