blob: e0cc115784ded4c673a3fe74ca208ee4bc5ce814 (
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/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}
});
|