UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

29 lines (22 loc) 486 B
import AABB2 from "./aabb/AABB2.js"; /** * * @param {Rectangle} rect * @returns {AABB2} */ export function rectangle_to_aabb(rect) { const position = rect.position; const x0 = position.x; const y0 = position.y; const size = rect.size; let x1 = x0; let y1 = y0; // sanitize bounds if (size.x > 0) { x1 += size.x; } if (size.y > 0) { y1 += size.y; } return new AABB2(x0, y0, x1, y1); }