aboutsummaryrefslogtreecommitdiff
path: root/src/lib/components/hud.svelte
blob: f79658a46a695249e1a638ebc6ac6fa9022d21f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<script>
  import { coordinateLength } from '$lib/config';

  export let x;
  export let y;

  const kSeparatorRegex = /([0-9a-z]{2})/g;

  const formatCoordinate = function formatCoordinate(coordinate) {
    return coordinate
      .toString(16)
      .padStart(coordinateLength, 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>