Returns the center of a rectangle as a Geometry.Point. If the rectangle lacks a position and origin parameter is not provided, 0,0 is used instead.

import { Rects } from "https://unpkg.com/ixfx/dist/geometry.js";

const p = Rects.center({x:10, y:20, width:100, height:50});
const p2 = Rects.center({width: 100, height: 50}); // Assumes 0,0 for rect x,y
  • Parameters

    • rect: Rect | RectPositioned

      Rectangle

    • Optionalorigin: Point

      Optional origin. Overrides rect position if available. If no position is available 0,0 is used by default.

    Returns Point