phaser/wip/vec2/Mask.js
2018-01-09 22:12:16 +00:00

45 lines
614 B
JavaScript

export function equal (a, b, precision = 1e-6) {
return (
Math.abs(a[0] - b[0]) <= precision &&
Math.abs(a[1] - b[1]) <= precision
);
}
export function less (a, b) {
return [ a[0] < b[0], a[1] < b[1] ];
}
export function greater (a, b) {
return [ a[0] > b[0], a[1] > b[1] ];
}
export function greaterEq (a, b) {
return [ a[0] >= b[0], a[1] >= b[1] ];
}
export function not (a) {
return [ !a[0], !a[1] ];
}
export function or (a, b) {
return [ a[0] || b[0], a[1] || b[1] ];
}
export function and (a, b) {
return [ a[0] && b[0], a[1] && b[1] ];
}