X-Git-Url: https://git.r.bdr.sh/rbdr/canvas/blobdiff_plain/3717f7fbf9ec110b51fe002cdced5d73ebd6136b..c30e688113e317ff6aca8a63f16b202cbfff3820:/src/routes/index.svelte?ds=sidebyside

diff --git a/src/routes/index.svelte b/src/routes/index.svelte
index 7d5a3ff..06c2357 100644
--- a/src/routes/index.svelte
+++ b/src/routes/index.svelte
@@ -1,12 +1,12 @@
 <script>
-
-  import { browser } from '$app/env';
+  import Sensor from '$lib/components/sensor.svelte';
   import Background from '$lib/components/background.svelte';
   import Palette from '$lib/components/palette.svelte';
   import Hud from '$lib/components/hud.svelte';
+  import { modulo } from '$lib/math';
+  import { widgets } from '$lib/stores/widgets';
 
-  const kCoordinateLength = 6;
-  const kMaxSize = Math.pow(16, kCoordinateLength);
+  import { coordinateLength, maxSize } from '$lib/config';
 
   $: x = 0;
   $: y = 0;
@@ -14,17 +14,13 @@
 
   let dragging = false;
 
-  const modulo = function modulo (number, base) {
-    return ((number % base) + base) % base
-  };
-
   const moveCanvas = function moveCanvas(event) {
 
     if (dragging) {
       let deltaX = event.x - dragging.x;
       let deltaY = event.y - dragging.y;
-      x = modulo(x - deltaX, kMaxSize);
-      y = modulo(y - deltaY, kMaxSize);
+      x = modulo(x - deltaX, maxSize);
+      y = modulo(y - deltaY, maxSize);
       dragging.x = event.x;
       dragging.y = event.y;
     }
@@ -61,14 +57,17 @@
   on:contextmenu={showPalette}
   on:mousedown={startDragging}
   on:mouseup={stopDragging}
-  on:mousemove={moveCanvas}>
+  on:mousemove={moveCanvas}
 >
-  <Background x={x} y={y}/>
+  <Sensor x={x} y={y} />
+  <Background x={x} y={y} />
   <Hud x={x} y={y} />
 
   {#if shouldShowPalette }
     <Palette/>
   {/if}
+
+  <p>{JSON.stringify($widgets)}</p>
 </div>
 
 <style>
