Source code

Revision control

Copy as Markdown

Other Tools

<!doctype html>
<script type="module">
import createPatternDataURL from './create-pattern-data-url.js';
const { patternSize, dataURL } = createPatternDataURL(); = `url("${dataURL}")`;
function setBackgroundPatternTo1DevicePixel() {
const oneDevicePixel = 1 / devicePixelRatio;
const patternPixels = oneDevicePixel * patternSize; = `${patternPixels}px ${patternPixels}px`;
// If we're viewed interactively and the user activates
// full-page-zoom, changes the page zoom level, or resizes
// the window, update the rendering to account for that:
window.addEventListener('resize', setBackgroundPatternTo1DevicePixel);