aboutsummaryrefslogtreecommitdiff
path: root/src/Utils.ts
diff options
context:
space:
mode:
authorHannah <hannah_chow@brown.edu>2020-02-11 06:34:19 -0500
committerHannah <hannah_chow@brown.edu>2020-02-11 06:34:19 -0500
commitb60154479add51f826afaeff074cf43a6b416831 (patch)
tree723f7f1356b1c3dcf5c409347b125d5a577b538f /src/Utils.ts
parent74ca8ac01e32faa8adab54ddfd806fe46cda03ec (diff)
parentdc6453e27375a1b3d614a74b7fd1d83695f130d7 (diff)
merge
Diffstat (limited to 'src/Utils.ts')
-rw-r--r--src/Utils.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/Utils.ts b/src/Utils.ts
index 04fe6750b..4deac9035 100644
--- a/src/Utils.ts
+++ b/src/Utils.ts
@@ -48,7 +48,7 @@ export namespace Utils {
}
export async function getApiKey(target: string): Promise<string> {
- const response = await fetch(prepend(`environment/${target.toUpperCase()}`));
+ const response = await fetch(prepend(`/environment/${target.toUpperCase()}`));
return response.text();
}
@@ -328,8 +328,8 @@ export function timenow() {
return now.toLocaleDateString() + ' ' + h + ':' + m + ' ' + ampm;
}
-export function aggregateBounds(boundsList: { x: number, y: number, width: number, height: number }[]) {
- return boundsList.reduce((bounds, b) => {
+export function aggregateBounds(boundsList: { x: number, y: number, width: number, height: number }[], xpad: number, ypad: number) {
+ const bounds = boundsList.reduce((bounds, b) => {
const [sptX, sptY] = [b.x, b.y];
const [bptX, bptY] = [sptX + b.width, sptY + b.height];
return {
@@ -337,6 +337,7 @@ export function aggregateBounds(boundsList: { x: number, y: number, width: numbe
r: Math.max(bptX, bounds.r), b: Math.max(bptY, bounds.b)
};
}, { x: Number.MAX_VALUE, y: Number.MAX_VALUE, r: -Number.MAX_VALUE, b: -Number.MAX_VALUE });
+ return { x: bounds.x !== Number.MAX_VALUE ? bounds.x - xpad : bounds.x, y: bounds.y !== Number.MAX_VALUE ? bounds.y - ypad : bounds.y, r: bounds.r !== -Number.MAX_VALUE ? bounds.r + xpad : bounds.r, b: bounds.b !== -Number.MAX_VALUE ? bounds.b + ypad : bounds.b };
}
export function intersectRect(r1: { left: number, top: number, width: number, height: number },
r2: { left: number, top: number, width: number, height: number }) {