diff options
Diffstat (limited to 'src/lib/components/hud.svelte')
| -rw-r--r-- | src/lib/components/hud.svelte | 30 |
1 files changed, 30 insertions, 0 deletions
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> |