summaryrefslogtreecommitdiff
path: root/_includes/extensions/geopattern.html
diff options
context:
space:
mode:
authorJeffrey Tse <jeffreytse.mail@gmail.com>2019-09-11 12:19:34 +0800
committerJeffrey Tse <jeffreytse.mail@gmail.com>2019-09-11 12:21:17 +0800
commit61eae5c5f9881cab29712f6e696085baa977e1f9 (patch)
treebb301b58b94fee5dcefbdfae8f0c8fc13ee5bd21 /_includes/extensions/geopattern.html
parentcd3a8163dd997d0a7c4d320816651efa8f7dce60 (diff)
release: v1.0.0
Diffstat (limited to '_includes/extensions/geopattern.html')
-rw-r--r--_includes/extensions/geopattern.html21
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>
+