phaser/wip/vec2/Mask.js

46 lines
614 B
JavaScript
Raw Normal View History

2017-02-04 04:41:17 +00:00
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] ];
}