Function fromNumbers

Returns a rectangle from a series of numbers: x, y, width, height OR width, height

import { Rects } from "https://unpkg.com/ixfx/dist/geometry.js";
const r1 = Rects.fromNumbers(100, 200);
// {width: 100, height: 200}

const r2 = Rects.fromNumbers(10, 20, 100, 200);
// {x: 10, y: 20, width: 100, height: 200}

Use the spread operator (...) if the source is an array:

const r3 = Rects.fromNumbers(...[10, 20, 100, 200]);

Use toArray for the opposite conversion.

toArray

  • Returns a rectangle from width, height

    const r = Rects.fromNumbers(100, 200);
    // {width: 100, height: 200}

    Use toArray for the opposite conversion.

    Parameters

    • width: number
    • height: number

    Returns Rect

  • Returns a rectangle from x,y,width,height

    import { Rects } from "https://unpkg.com/ixfx/dist/geometry.js";
    const r = Rects.fromNumbers(10, 20, 100, 200);
    // {x: 10, y: 20, width: 100, height: 200}

    Use the spread operator (...) if the source is an array:

    const r3 = Rects.fromNumbers(...[10, 20, 100, 200]);
    

    Use toArray for the opposite conversion.

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number

    Returns RectPositioned