summaryrefslogtreecommitdiff
path: root/_includes/extensions/trianglify.html
diff options
context:
space:
mode:
Diffstat (limited to '_includes/extensions/trianglify.html')
-rw-r--r--_includes/extensions/trianglify.html23
1 files changed, 23 insertions, 0 deletions
diff --git a/_includes/extensions/trianglify.html b/_includes/extensions/trianglify.html
new file mode 100644
index 0000000..22003dc
--- /dev/null
+++ b/_includes/extensions/trianglify.html
@@ -0,0 +1,23 @@
+{% if include.selector %}
+ {% assign selector = include.selector %}
+{% endif %}
+
+{% if include.seed %}
+ {% assign seed = include.seed %}
+{% endif %}
+
+<script src="https://cdnjs.cloudflare.com/ajax/libs/trianglify/2.0.0/trianglify.min.js"></script>
+<script>
+ function setRandomBgImage(selector, seed) {
+ var element = document.querySelector(selector);
+ if (!element) return;
+ var pattern = Trianglify({
+ width: screen.width,
+ height: element.offsetHeight,
+ seed: seed
+ });
+ element.appendChild(pattern.canvas());
+ }
+
+ setRandomBgImage('{{ selector }}', '{{ seed }}');
+</script>