From 3717f7fbf9ec110b51fe002cdced5d73ebd6136b Mon Sep 17 00:00:00 2001
From: Ruben Beltran del Rio <ruben@unlimited.pizza>
Date: Tue, 5 Jul 2022 19:11:31 +0200
Subject: Move things to components

---
 src/lib/components/hud.svelte | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 src/lib/components/hud.svelte

(limited to 'src/lib/components/hud.svelte')

diff --git a/src/lib/components/hud.svelte b/src/lib/components/hud.svelte
new file mode 100644
index 0000000..ce32e0d
--- /dev/null
+++ b/src/lib/components/hud.svelte
@@ -0,0 +1,30 @@
+<script>
+  export let x;
+  export let y;
+
+  const kCoordinateLength = 6;
+  const kSeparatorRegex = /([0-9a-z]{2})/g;
+
+  const formatCoordinate = function formatCoordinate(coordinate) {
+    return coordinate
+      .toString(16)
+      .padStart(kCoordinateLength, 0)
+      .replace(kSeparatorRegex, '$1 ');
+  }
+</script>
+
+<div class="hud">
+  { formatCoordinate(x) } × { formatCoordinate(y) }
+</div>
+
+<style>
+  .hud {
+    background-color: #fff;
+    padding: 4px;
+    position: fixed;
+    bottom: 2px;
+    right: 2px;
+    font-smooth: never;
+    -webkit-font-smoothing : none;
+  }
+</style>
-- 
cgit 

