aboutsummaryrefslogtreecommitdiff
path: root/src/lib/stores/canvas.js
blob: ed0a5d73f8a95cd5c53e03bdc4c21f5b6c7d18fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { browser } from '$app/environment';
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 };
});