mirror of
https://github.com/Terncode/pixel.horse.git
synced 2026-09-24 21:55:52 +02:00
Revert codestyle changes (#40)
* Revert "7f7efbb94bab8574e42d942ad82d414e007b2970" Code style changes should probably be part of a PR
This commit is contained in:
+22
-22
@@ -2,49 +2,49 @@ import { Rect, Point } from './interfaces';
|
||||
import { intersect } from './utils';
|
||||
|
||||
export function rect(x: number, y: number, w: number, h: number): Rect {
|
||||
return { x, y, w, h };
|
||||
return { x, y, w, h };
|
||||
}
|
||||
|
||||
export function centerPoint(rect: Rect): Point {
|
||||
return { x: rect.x + rect.w / 2, y: rect.y + rect.h / 2 };
|
||||
return { x: rect.x + rect.w / 2, y: rect.y + rect.h / 2 };
|
||||
}
|
||||
|
||||
export function copyRect(dst: Rect, src: Rect) {
|
||||
dst.x = src.x;
|
||||
dst.y = src.y;
|
||||
dst.w = src.w;
|
||||
dst.h = src.h;
|
||||
dst.x = src.x;
|
||||
dst.y = src.y;
|
||||
dst.w = src.w;
|
||||
dst.h = src.h;
|
||||
}
|
||||
|
||||
export function withBorder({ x, y, w, h }: Rect, border: number) {
|
||||
return rect(x - border, y - border, w + border * 2, h + border * 2);
|
||||
return rect(x - border, y - border, w + border * 2, h + border * 2);
|
||||
}
|
||||
|
||||
export function withPadding({ x, y, w, h }: Rect, top: number, right: number, bottom: number, left: number) {
|
||||
return rect(x - top, y - left, w + left + right, h + top + bottom);
|
||||
return rect(x - top, y - left, w + left + right, h + top + bottom);
|
||||
}
|
||||
|
||||
export function rectsIntersect(a: Rect, b: Rect): boolean {
|
||||
return intersect(a.x, a.y, a.w, a.h, b.x, b.y, b.w, b.h);
|
||||
return intersect(a.x, a.y, a.w, a.h, b.x, b.y, b.w, b.h);
|
||||
}
|
||||
|
||||
export function addRect(a: Rect, b: Rect) {
|
||||
const x = Math.min(a.x, b.x);
|
||||
const y = Math.min(a.y, b.y);
|
||||
const x = Math.min(a.x, b.x);
|
||||
const y = Math.min(a.y, b.y);
|
||||
|
||||
a.w = Math.max(a.x + a.w, b.x + b.w) - x;
|
||||
a.h = Math.max(a.y + a.h, b.y + b.h) - y;
|
||||
a.x = x;
|
||||
a.y = y;
|
||||
a.w = Math.max(a.x + a.w, b.x + b.w) - x;
|
||||
a.h = Math.max(a.y + a.h, b.y + b.h) - y;
|
||||
a.x = x;
|
||||
a.y = y;
|
||||
}
|
||||
|
||||
export function addRects(a: Rect, b: Rect): Rect {
|
||||
const x = Math.min(a.x, b.x);
|
||||
const y = Math.min(a.y, b.y);
|
||||
const x = Math.min(a.x, b.x);
|
||||
const y = Math.min(a.y, b.y);
|
||||
|
||||
return {
|
||||
x, y,
|
||||
w: Math.max(a.x + a.w, b.x + b.w) - x,
|
||||
h: Math.max(a.y + a.h, b.y + b.h) - y,
|
||||
};
|
||||
return {
|
||||
x, y,
|
||||
w: Math.max(a.x + a.w, b.x + b.w) - x,
|
||||
h: Math.max(a.y + a.h, b.y + b.h) - y,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user