All files / utils/geometry lowerRightCoor.ts

100% Statements 2/2
100% Branches 0/0
100% Functions 1/1
100% Lines 2/2

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                    2x 22x          
import { Rectangle, Point } from "./interfaces";
 
/**
 * Get coordinates of a rectangle's lower right corner from its top points
 * and its lower left corner.
 *
 * @param  {object} A rectangle defined by two points (x1, y1) and (x2, y2).
 * @param  {object} A corner's coordinates (x, y).
 * @return {object} Coordinates of the corner (x, y).
 */
export default function lowerRightCoor(r: Rectangle, llc: Point): Point {
  return {
    x: llc.x - r.x1 + r.x2,
    y: llc.y - r.y1 + r.y2
  };
}