X-Git-Url: https://git.r.bdr.sh/rbdr/canvas/blobdiff_plain/2df937df1372359babd123d1361e702a1a4b8168..c55cffecda48be785d89721dc8c8f04c99270b2d:/src/routes/index.svelte

diff --git a/src/routes/index.svelte b/src/routes/index.svelte
index 2943d23..411b81f 100644
--- a/src/routes/index.svelte
+++ b/src/routes/index.svelte
@@ -3,12 +3,13 @@
   import Background from '$lib/components/background.svelte';
   import Palette from '$lib/components/palette.svelte';
   import Hud from '$lib/components/hud.svelte';
+  import Widget from '$lib/components/widget.svelte';
   import { modulo } from '$lib/math';
+  import { widgets } from '$lib/stores/widgets';
+  import { canvas } from '$lib/stores/canvas';
 
   import { coordinateLength, maxSize } from '$lib/config';
 
-  $: x = 0;
-  $: y = 0;
   $: shouldShowPalette = false;
 
   let dragging = false;
@@ -18,10 +19,11 @@
     if (dragging) {
       let deltaX = event.x - dragging.x;
       let deltaY = event.y - dragging.y;
-      x = modulo(x - deltaX, maxSize);
-      y = modulo(y - deltaY, maxSize);
+      let x = modulo($canvas.x - deltaX, maxSize);
+      let y = modulo($canvas.y - deltaY, maxSize);
       dragging.x = event.x;
       dragging.y = event.y;
+      canvas.set({ x, y })
     }
   }
 
@@ -56,15 +58,21 @@
   on:contextmenu={showPalette}
   on:mousedown={startDragging}
   on:mouseup={stopDragging}
-  on:mousemove={moveCanvas}>
+  on:mousemove={moveCanvas}
 >
-  <Sensor x={x} y={y} />
-  <Background x={x} y={y} />
-  <Hud x={x} y={y} />
+  <Sensor />
+  <Background />
+  <Hud />
 
   {#if shouldShowPalette }
     <Palette/>
   {/if}
+
+  {#if $widgets}
+    {#each $widgets as widget}
+      <Widget widget={widget}/>
+    {/each}
+  {/if}
 </div>
 
 <style>
