Skip to content

ellipsePath

The path of the ellipse that fills a box, as SVG path data: two half-turn arcs. A square box gives a circle.

Available since v3.1.10

import { ellipsePath } from '@helpers4/geometry';
// or, from the all-in-one package (same code, one install):
import { ellipsePath } from 'helpers4/geometry';
ellipsePath(box: Rect): string
ParameterTypeDescription
boxRectThe bounding box of the ellipse

string — The path data, closed

Two half-turn arcs; a square box gives a circle.

ellipsePath({ x: 0, y: 0, width: 10, height: 6 }) // => 'M0 3 A5 3 0 0 1 10 3 A5 3 0 0 1 0 3 Z'

An axis-aligned rectangle: its top-left corner and its size. Width and height are expected to be non-negative.

interface Rect {
  height: number;
  width: number;
  x: number;
  y: number;
}

View source on GitHub