Skip to content

Instantly share code, notes, and snippets.

@DarkWiiPlayer
Created February 1, 2021 09:22
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 DarkWiiPlayer/bb82379d71740c8d73c67771c4f33f34 to your computer and use it in GitHub Desktop.
Save DarkWiiPlayer/bb82379d71740c8d73c67771c4f33f34 to your computer and use it in GitHub Desktop.
A somewhat nicer frosted glass effect using SVG filters
let template = document.createElement("template")
template.innerHTML = `
<svg>
<defs>
<filter id="zoom">
<feTurbulence type="turbulence" baseFrequency="0.05" numOctaves="2" />
<feGaussianBlur in="distorted" stdDeviation="2" result="turbulence" />
<feDisplacementMap in2="turbulence" in="SourceGraphic" scale="10" xChannelSelector="R" yChannelSelector="G" result="distorted"/>
<feGaussianBlur in="distorted" stdDeviation="2" />
<feColorMatrix type="matrix" values="
.98 0 0 0 0
0 1 0 0 0
.02 .02 1 0 0
0 0 0 1 0" />
</filter>
</defs>
</svg>
<div style="position: fixed; left: 0rem; top: 0rem; bottom: 0rem; right: 0rem; pointer-events: none; z-index: 99; backdrop-filter: url(#zoom)"></div>
`
document
.querySelector("body")
.appendChild(template.content.cloneNode(true))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment