From d7cea96940ddeb764c7343e05526f611863019d8 Mon Sep 17 00:00:00 2001 From: Ruben Beltran del Rio Date: Thu, 7 Jul 2022 23:14:18 +0200 Subject: Partially render the boxes --- src/lib/stores/canvas.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/lib/stores/canvas.js (limited to 'src/lib/stores/canvas.js') diff --git a/src/lib/stores/canvas.js b/src/lib/stores/canvas.js new file mode 100644 index 0000000..e0cc115 --- /dev/null +++ b/src/lib/stores/canvas.js @@ -0,0 +1,24 @@ +import { browser } from '$app/env'; +import { derived, writable } from 'svelte/store'; + +export const canvas = writable({x: 0, y: 0}); + +export const topLeft = derived(canvas, ($canvas) => { + if (browser) { + return { + x: $canvas.x - window.screen.width/2, + y: $canvas.y - window.screen.height/2 + }; + } + return {x: 0, y: 0} +}); + +export const bottomRight = derived(canvas, ($canvas) => { + if (browser) { + return { + x: $canvas.x + window.screen.width/2, + y: $canvas.y + window.screen.height/2 + }; + } + return {x: 0, y: 0} +}); -- cgit