diff options
Diffstat (limited to '_includes/extensions/geopattern.html')
-rw-r--r-- | _includes/extensions/geopattern.html | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/_includes/extensions/geopattern.html b/_includes/extensions/geopattern.html new file mode 100644 index 0000000..3931533 --- /dev/null +++ b/_includes/extensions/geopattern.html @@ -0,0 +1,21 @@ +{% if include.selector %} + {% assign selector = include.selector %} +{% endif %} + +{% if include.seed %} + {% assign seed = include.seed %} +{% endif %} + +<script src="https://cdnjs.cloudflare.com/ajax/libs/geopattern/1.2.3/js/geopattern.min.js"></script> +<script> + function setRandomBgImage(selector, seed) { + var pattern = GeoPattern.generate(seed); + var element = document.querySelector(selector) + if (element) { + element.style.backgroundImage = pattern.toDataUrl(); + } + } + + setRandomBgImage('{{ selector }}', '{{ seed }}'); +</script> + |