UNPKG

2.91 kBMarkdownView Raw
1# Installation
2> `npm install --save @types/d3-polygon`
3
4# Summary
5This package contains type definitions for D3JS d3-polygon module (https://github.com/d3/d3-polygon/).
6
7# Details
8Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/d3-polygon.
9## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/d3-polygon/index.d.ts)
10````ts
11// Type definitions for D3JS d3-polygon module 3.0
12// Project: https://github.com/d3/d3-polygon/, https://d3js.org/d3-polygon
13// Definitions by: Tom Wanzek <https://github.com/tomwanzek>
14// Alex Ford <https://github.com/gustavderdrache>
15// Boris Yankov <https://github.com/borisyankov>
16// Nathan Bierema <https://github.com/Methuselah96>
17// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
18
19// Last module patch version validated against: 3.0.1
20
21/**
22 * Returns the signed area of the specified polygon. If the vertices of the polygon are in counterclockwise order
23 * (assuming a coordinate system where the origin <0,0> is in the top-left corner), the returned area is positive;
24 * otherwise it is negative, or zero.
25 *
26 * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
27 */
28export function polygonArea(polygon: Array<[number, number]>): number;
29
30/**
31 * Returns the centroid of the specified polygon.
32 *
33 * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
34 */
35export function polygonCentroid(polygon: Array<[number, number]>): [number, number];
36
37/**
38 * Returns the convex hull of the specified points using Andrew’s monotone chain algorithm.
39 * The returned hull is represented as an array containing a subset of the input points arranged in
40 * counterclockwise order. Returns null if points has fewer than three elements.
41 *
42 * @param points Array of coordinates <x0, y0>, <x1, y1> and so on.
43 */
44export function polygonHull(points: Array<[number, number]>): Array<[number, number]> | null;
45
46/**
47 * Returns true if and only if the specified point is inside the specified polygon.
48 *
49 * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
50 * @param point Coordinates of point <x, y>.
51 */
52export function polygonContains(polygon: Array<[number, number]>, point: [number, number]): boolean;
53
54/**
55 * Returns the length of the perimeter of the specified polygon.
56 *
57 * @param polygon Array of coordinates <x0, y0>, <x1, y1> and so on.
58 */
59export function polygonLength(polygon: Array<[number, number]>): number;
60
61````
62
63### Additional Details
64 * Last updated: Fri, 25 Jun 2021 14:01:31 GMT
65 * Dependencies: none
66 * Global values: none
67
68# Credits
69These definitions were written by [Tom Wanzek](https://github.com/tomwanzek), [Alex Ford](https://github.com/gustavderdrache), [Boris Yankov](https://github.com/borisyankov), and [Nathan Bierema](https://github.com/Methuselah96).
70
\No newline at end of file