ixfx
    Preparing search index...

    Function distanceToExterior

    • Returns the distance from point a to the exterior of shape.

      Parameters

      Returns number

      const distance = distanceToExterior(
      {x: 50, y: 50},
      {x: 100, y: 100, width: 20, height: 20}
      );
      import {minIndex} from '../data/arrays.js';
      const shapes = [ some shapes... ]; // Shapes to compare against
      const pt = { x: 10, y: 10 }; // Comparison point
      const distances = shapes.map(v => distanceToExterior(pt, v));
      const closest = shapes[minIndex(...distances)];