Skip to content

Instantly share code, notes, and snippets.

@oparisblue
Last active April 2, 2020 07:47
Show Gist options
  • Save oparisblue/c49a61dd61aaea1962929c004a52b179 to your computer and use it in GitHub Desktop.
Save oparisblue/c49a61dd61aaea1962929c004a52b179 to your computer and use it in GitHub Desktop.
StackOverflow's "Ultra Dark" floodlight effect implementation
:root {
--cursorX:50vw;
--cursorY:50vh;
}
body.theme-ultradark:after {
content: '';
position: fixed;
display: block;
border-radius: 100%;
top: calc(var(--cursorY) - 100px);
left: calc(var(--cursorX) - 100px);
background-color: transparent;
width: 200px;
height: 200px;
backdrop-filter: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='flashlight'%3E%3CfeFlood result='floodFill' x='0' y='0' width='200' height='200' flood-color='white' flood-opacity='1' /%3E%3CfeBlend in='floodFill' in2='SourceGraphic' mode='overlay' /%3E%3C/filter%3E%3C/svg%3E#flashlight") brightness(500%) saturate(200%);
pointer-events: none;
z-index: 9999999999999;
}
if (document.body.classList.contains('theme-ultradark')) {
document.addEventListener('mousemove', e => {
window.requestAnimationFrame(() => {
const X = e.clientX;
const Y = e.clientY;
document.documentElement.style.setProperty('--cursorX', X + 'px');
document.documentElement.style.setProperty('--cursorY', Y + 'px');
});
});
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment