aboutsummaryrefslogtreecommitdiff
path: root/src/lib/components/minimap.svelte
diff options
context:
space:
mode:
authorRuben Beltran del Rio <ruben@unlimited.pizza>2023-01-24 13:07:20 +0100
committerRuben Beltran del Rio <ruben@unlimited.pizza>2023-01-24 13:07:50 +0100
commite4e4b5202bf0039127f591941fddc1ff5ca09897 (patch)
tree0c6ad5b8784002ab2d05a14ece3d0b56fee1383f /src/lib/components/minimap.svelte
parentc55cffecda48be785d89721dc8c8f04c99270b2d (diff)
Update project, improve sensor/render logic
Diffstat (limited to 'src/lib/components/minimap.svelte')
-rw-r--r--src/lib/components/minimap.svelte54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/lib/components/minimap.svelte b/src/lib/components/minimap.svelte
new file mode 100644
index 0000000..cfee685
--- /dev/null
+++ b/src/lib/components/minimap.svelte
@@ -0,0 +1,54 @@
+<script>
+ import { coordinateLength } from '$lib/config';
+ import { sensor } from '$lib/stores/widgets';
+ import { maxSize } from '$lib/config';
+
+ const isActive = function isActive($s, x, y) {
+ const isXActive = $s.left > x * maxSize && $s.left < (x + 1) * maxSize;
+ const isYActive = $s.top > y * maxSize && $s.top < (y + 1) * maxSize;
+ return isXActive || isYActive;
+ }
+</script>
+
+<div class="minimap">
+ <table>
+ <tr>
+ <td class="{isActive($sensor, -1,-1) ? 'active' : ''}"></td>
+ <td class="{isActive($sensor, 0,-1) ? 'active' : ''}"></td>
+ <td class="{isActive($sensor, 1,-1) ? 'active' : ''}"></td>
+ </tr>
+ <tr>
+ <td class="{isActive($sensor, -1,0) ? 'active' : ''}"></td>
+ <td class="{isActive($sensor, 0,0) ? 'active' : ''}"></td>
+ <td class="{isActive($sensor, 1,0) ? 'active' : ''}"></td>
+ </tr>
+ <tr>
+ <td class="{isActive($sensor, -1,1) ? 'active' : ''}"></td>
+ <td class="{isActive($sensor, 0,1) ? 'active' : ''}"></td>
+ <td class="{isActive($sensor, 1,1) ? 'active' : ''}"></td>
+ </tr>
+ </table>
+</div>
+
+<style>
+ .minimap {
+ background-color: #fff;
+ padding: 4px;
+ position: fixed;
+ top: 2px;
+ right: 2px;
+ font-smooth: never;
+ -webkit-font-smoothing : none;
+ }
+
+ td {
+ width: 10px;
+ height: 10px;
+ border: 1px solid black;
+ }
+
+ td.active {
+ background-color: magenta;
+ }
+</style>
+