# Generated by detroit
# See https://github.com/bourbonut/detroit/tree/main/api_maker

from functools import partial
from operator import is_not

class Delaunay:
    def __init__(self, content="Delaunay"):
        self.content = content

    def __repr__(self):
        return self.content

    def __str__(self):
        return self.content

    def __call__(self, *args):
        arguments = ", ".join(map(repr, args))
        return f"{self}({arguments})"

    def from_(self, points=None, fx=None, fy=None, that=None):
        """
        Source · Returns the Delaunay triangulation for the given array or iterable of points.
        If fx and fy are not specified, then points is assumed to be an array of two-element
        arrays of numbers: [[x0, y0], [x1, y1], …].
        .. code:: javascript

            const delaunay = d3.Delaunay.from([[0, 0], [0, 1], [1, 0], [1, 1]]);

        Otherwise, fx and fy are functions that are invoked for each element in the points
        array in order, and must return the respective x and y coordinate for each point.
        .. code:: javascript

            const delaunay = d3.Delaunay.from([{x: 0, y: 0}, {x: 0, y: 1}, {x: 1, y: 0}, {x: 1, y: 1}], (d) => d.x, (d) => d.y);

        If that is specified, the functions fx and fy are invoked with that as this. (See
        Array.from for reference.)

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#Delaunay_from>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (points, fx, fy, that))))
        return Delaunay(content=f"{self.content}.from({arguments})")


    def points(self):
        """
        The coordinates of the points as an array [x0, y0, x1, y1, …].
        The halfedge indexes as an Int32Array [j0, j1, …]. For each index 0 ≤ i <
        halfedges.length, there is a halfedge from triangle vertex j = halfedges[i] to triangle
        vertex i. Equivalently, this means that triangle ⌊i / 3⌋ is adjacent to triangle ⌊j /
        3⌋. If j is negative, then triangle ⌊i / 3⌋ is an exterior triangle on the convex hull.
        For example, to render the internal edges of the Delaunay triangulation:
        .. code:: javascript

            const {points, halfedges, triangles} = delaunay;
            for (let i = 0, n = halfedges.length; i < n; ++i) {
              const j = halfedges[i];
              if (j < i) continue;
              const ti = triangles[i];
              const tj = triangles[j];
              context.moveTo(points[ti * 2], points[ti * 2 + 1]);
              context.lineTo(points[tj * 2], points[tj * 2 + 1]);
            }

        See also delaunay.render.
        An Int32Array of point indexes that form the convex hull in counterclockwise order. If
        the points are collinear, returns them ordered.
        See also delaunay.renderHull.
        The triangle vertex indexes as an Uint32Array [i0, j0, k0, i1, j1, k1, …]. Each
        contiguous triplet of indexes i, j, k forms a counterclockwise triangle. The
        coordinates of the triangle’s points can be found by going through delaunay.points. For
        example, to render triangle i:
        .. code:: javascript

            const {points, triangles} = delaunay;
            const t0 = triangles[i * 3 + 0];
            const t1 = triangles[i * 3 + 1];
            const t2 = triangles[i * 3 + 2];
            context.moveTo(points[t0 * 2], points[t0 * 2 + 1]);
            context.lineTo(points[t1 * 2], points[t1 * 2 + 1]);
            context.lineTo(points[t2 * 2], points[t2 * 2 + 1]);
            context.closePath();

        See also delaunay.renderTriangle.
        The incoming halfedge indexes as a Int32Array [e0, e1, e2, …]. For each point i,
        inedges[i] is the halfedge index e of an incoming halfedge. For coincident points, the
        halfedge index is -1; for points on the convex hull, the incoming halfedge is on the
        convex hull; for other points, the choice of incoming halfedge is arbitrary. The
        inedges table can be used to traverse the Delaunay triangulation; see also
        delaunay.neighbors.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_points>`_.
        """
        return Delaunay(content=f"{self.content}.points()")


    def halfedges(self):
        """
        The halfedge indexes as an Int32Array [j0, j1, …]. For each index 0 ≤ i <
        halfedges.length, there is a halfedge from triangle vertex j = halfedges[i] to triangle
        vertex i. Equivalently, this means that triangle ⌊i / 3⌋ is adjacent to triangle ⌊j /
        3⌋. If j is negative, then triangle ⌊i / 3⌋ is an exterior triangle on the convex hull.
        For example, to render the internal edges of the Delaunay triangulation:
        .. code:: javascript

            const {points, halfedges, triangles} = delaunay;
            for (let i = 0, n = halfedges.length; i < n; ++i) {
              const j = halfedges[i];
              if (j < i) continue;
              const ti = triangles[i];
              const tj = triangles[j];
              context.moveTo(points[ti * 2], points[ti * 2 + 1]);
              context.lineTo(points[tj * 2], points[tj * 2 + 1]);
            }

        See also delaunay.render.
        An Int32Array of point indexes that form the convex hull in counterclockwise order. If
        the points are collinear, returns them ordered.
        See also delaunay.renderHull.
        The triangle vertex indexes as an Uint32Array [i0, j0, k0, i1, j1, k1, …]. Each
        contiguous triplet of indexes i, j, k forms a counterclockwise triangle. The
        coordinates of the triangle’s points can be found by going through delaunay.points. For
        example, to render triangle i:
        .. code:: javascript

            const {points, triangles} = delaunay;
            const t0 = triangles[i * 3 + 0];
            const t1 = triangles[i * 3 + 1];
            const t2 = triangles[i * 3 + 2];
            context.moveTo(points[t0 * 2], points[t0 * 2 + 1]);
            context.lineTo(points[t1 * 2], points[t1 * 2 + 1]);
            context.lineTo(points[t2 * 2], points[t2 * 2 + 1]);
            context.closePath();

        See also delaunay.renderTriangle.
        The incoming halfedge indexes as a Int32Array [e0, e1, e2, …]. For each point i,
        inedges[i] is the halfedge index e of an incoming halfedge. For coincident points, the
        halfedge index is -1; for points on the convex hull, the incoming halfedge is on the
        convex hull; for other points, the choice of incoming halfedge is arbitrary. The
        inedges table can be used to traverse the Delaunay triangulation; see also
        delaunay.neighbors.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_halfedges>`_.
        """
        return Delaunay(content=f"{self.content}.halfedges()")


    def hull(self):
        """
        An Int32Array of point indexes that form the convex hull in counterclockwise order. If
        the points are collinear, returns them ordered.
        See also delaunay.renderHull.
        The triangle vertex indexes as an Uint32Array [i0, j0, k0, i1, j1, k1, …]. Each
        contiguous triplet of indexes i, j, k forms a counterclockwise triangle. The
        coordinates of the triangle’s points can be found by going through delaunay.points. For
        example, to render triangle i:
        .. code:: javascript

            const {points, triangles} = delaunay;
            const t0 = triangles[i * 3 + 0];
            const t1 = triangles[i * 3 + 1];
            const t2 = triangles[i * 3 + 2];
            context.moveTo(points[t0 * 2], points[t0 * 2 + 1]);
            context.lineTo(points[t1 * 2], points[t1 * 2 + 1]);
            context.lineTo(points[t2 * 2], points[t2 * 2 + 1]);
            context.closePath();

        See also delaunay.renderTriangle.
        The incoming halfedge indexes as a Int32Array [e0, e1, e2, …]. For each point i,
        inedges[i] is the halfedge index e of an incoming halfedge. For coincident points, the
        halfedge index is -1; for points on the convex hull, the incoming halfedge is on the
        convex hull; for other points, the choice of incoming halfedge is arbitrary. The
        inedges table can be used to traverse the Delaunay triangulation; see also
        delaunay.neighbors.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_hull>`_.
        """
        return Delaunay(content=f"{self.content}.hull()")


    def triangles(self):
        """
        The triangle vertex indexes as an Uint32Array [i0, j0, k0, i1, j1, k1, …]. Each
        contiguous triplet of indexes i, j, k forms a counterclockwise triangle. The
        coordinates of the triangle’s points can be found by going through delaunay.points. For
        example, to render triangle i:
        .. code:: javascript

            const {points, triangles} = delaunay;
            const t0 = triangles[i * 3 + 0];
            const t1 = triangles[i * 3 + 1];
            const t2 = triangles[i * 3 + 2];
            context.moveTo(points[t0 * 2], points[t0 * 2 + 1]);
            context.lineTo(points[t1 * 2], points[t1 * 2 + 1]);
            context.lineTo(points[t2 * 2], points[t2 * 2 + 1]);
            context.closePath();

        See also delaunay.renderTriangle.
        The incoming halfedge indexes as a Int32Array [e0, e1, e2, …]. For each point i,
        inedges[i] is the halfedge index e of an incoming halfedge. For coincident points, the
        halfedge index is -1; for points on the convex hull, the incoming halfedge is on the
        convex hull; for other points, the choice of incoming halfedge is arbitrary. The
        inedges table can be used to traverse the Delaunay triangulation; see also
        delaunay.neighbors.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_triangles>`_.
        """
        return Delaunay(content=f"{self.content}.triangles()")


    def inedges(self):
        """
        The incoming halfedge indexes as a Int32Array [e0, e1, e2, …]. For each point i,
        inedges[i] is the halfedge index e of an incoming halfedge. For coincident points, the
        halfedge index is -1; for points on the convex hull, the incoming halfedge is on the
        convex hull; for other points, the choice of incoming halfedge is arbitrary. The
        inedges table can be used to traverse the Delaunay triangulation; see also
        delaunay.neighbors.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_inedges>`_.
        """
        return Delaunay(content=f"{self.content}.inedges()")


    def find(self, x=None, y=None, i=None):
        """
        .. code:: javascript

            delaunay.find(0, 0) // -1

        Examples · Source · Returns the index of the input point that is closest to the
        specified point ⟨x, y⟩. The search is started at the specified point i. If i is not
        specified, it defaults to zero.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_find>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (x, y, i))))
        return Delaunay(content=f"{self.content}.find({arguments})")


    def neighbors(self, i=None):
        """
        .. code:: javascript

            delaunay.neighbors(-1) // []

        Source · Returns an iterable over the indexes of the neighboring points to the
        specified point i. The iterable is empty if i is a coincident point.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_neighbors>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (i,))))
        return Delaunay(content=f"{self.content}.neighbors({arguments})")


    def render(self, context=None):
        """
        Source · Renders the edges of the Delaunay triangulation to the specified context. The
        specified context must implement the context.moveTo and context.lineTo methods from the
        CanvasPathMethods API. If a context is not specified, an SVG path string is returned
        instead.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_render>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (context,))))
        return Delaunay(content=f"{self.content}.render({arguments})")


    def renderHull(self, context=None):
        """
        Source · Renders the convex hull of the Delaunay triangulation to the specified
        context. The specified context must implement the context.moveTo and context.lineTo
        methods from the CanvasPathMethods API. If a context is not specified, an SVG path
        string is returned instead.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_renderHull>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (context,))))
        return Delaunay(content=f"{self.content}.renderHull({arguments})")


    def renderTriangle(self, i=None, context=None):
        """
        Source · Renders triangle i of the Delaunay triangulation to the specified context. The
        specified context must implement the context.moveTo, context.lineTo and
        context.closePath methods from the CanvasPathMethods API. If a context is not
        specified, an SVG path string is returned instead.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_renderTriangle>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (i, context))))
        return Delaunay(content=f"{self.content}.renderTriangle({arguments})")


    def renderPoints(self, context=None, radius=None):
        """
        Source · Renders the input points of the Delaunay triangulation to the specified
        context as circles with the specified radius. If radius is not specified, it defaults
        to 2. The specified context must implement the context.moveTo and context.arc methods
        from the CanvasPathMethods API. If a context is not specified, an SVG path string is
        returned instead.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_renderPoints>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (context, radius))))
        return Delaunay(content=f"{self.content}.renderPoints({arguments})")


    def hullPolygon(self):
        """
        Source · Returns the closed polygon [[x0, y0], [x1, y1], …, [x0, y0]] representing the
        convex hull. See also delaunay.renderHull.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_hullPolygon>`_.
        """
        return Delaunay(content=f"{self.content}.hullPolygon()")


    def trianglePolygons(self):
        """
        Source · Returns an iterable over the polygons for each triangle, in order. See also
        delaunay.renderTriangle.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_trianglePolygons>`_.
        """
        return Delaunay(content=f"{self.content}.trianglePolygons()")


    def trianglePolygon(self, i=None):
        """
        Source · Returns the closed polygon [[x0, y0], [x1, y1], [x2, y2], [x0, y0]]
        representing the triangle i. See also delaunay.renderTriangle.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_trianglePolygon>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (i,))))
        return Delaunay(content=f"{self.content}.trianglePolygon({arguments})")


    def update(self):
        """
        Source · Recomputes the triangulation after the points have been modified in-place.

        See more informations `here <https://d3js.org/d3-delaunay/delaunay#delaunay_update>`_.
        """
        return Delaunay(content=f"{self.content}.update()")


    def voronoi(self, bounds=None):
        """
        Source · Returns the Voronoi diagram for the given Delaunay triangulation. When
        rendering, the diagram will be clipped to the specified bounds = [xmin, ymin, xmax,
        ymax].
        .. code:: javascript

            const delaunay = d3.Delaunay.from([[0, 0], [0, 100], [100, 0], [100, 100]]);
            const voronoi = delaunay.voronoi([0, 0, 640, 480]);

        If bounds is not specified, it defaults to [0, 0, 960, 500]. The Voronoi diagram is
        returned even in degenerate cases where no triangulation exists — namely 0, 1 or 2
        points, and collinear points.
        The Voronoi diagram’s associated Delaunay triangulation.
        The circumcenters of the Delaunay triangles as a Float64Array [cx0, cy0, cx1, cy1, …].
        Each contiguous pair of coordinates cx, cy is the circumcenter for the corresponding
        triangle. These circumcenters form the coordinates of the Voronoi cell polygons.
        A Float64Array [vx0, vy0, wx0, wy0, …] where each non-zero quadruple describes an open
        (infinite) cell on the outer hull, giving the directions of two open half-lines.
        The bounds of the viewport [xmin, ymin, xmax, ymax] for rendering the Voronoi diagram.
        These values only affect the rendering methods (voronoi.render, voronoi.renderBounds,
        voronoi.renderCell).

        See more informations `here <https://d3js.org/d3-delaunay/voronoi#delaunay_voronoi>`_.
        """
        arguments = ", ".join(map(repr, filter(partial(is_not, None), (bounds,))))
        return Delaunay(content=f"{self.content}.voronoi({arguments})")

