diff options
| author | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-07-07 23:14:18 +0200 |
|---|---|---|
| committer | Ruben Beltran del Rio <ruben@unlimited.pizza> | 2022-07-07 23:14:18 +0200 |
| commit | d7cea96940ddeb764c7343e05526f611863019d8 (patch) | |
| tree | 7258a9ee7321153363ea6e23c092291f5f0dc4d4 /src/routes | |
| parent | c30e688113e317ff6aca8a63f16b202cbfff3820 (diff) | |
Partially render the boxes
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/index.svelte | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/routes/index.svelte b/src/routes/index.svelte index 06c2357..411b81f 100644 --- a/src/routes/index.svelte +++ b/src/routes/index.svelte @@ -3,13 +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; @@ -19,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 }) } } @@ -59,15 +60,19 @@ on:mouseup={stopDragging} 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} - <p>{JSON.stringify($widgets)}</p> + {#if $widgets} + {#each $widgets as widget} + <Widget widget={widget}/> + {/each} + {/if} </div> <style> |