Skip to content

Latest commit

 

History

History
19 lines (10 loc) · 1002 Bytes

Polygon-Geom.md

File metadata and controls

19 lines (10 loc) · 1002 Bytes

API ReferenceGeometryPolygon Geom

The D3 4.0 API Reference has moved. This page describes the D3 3.x API.

# d3.geom.polygon(vertices)

Returns the input array of vertices with additional methods attached, as described below.

# polygon.area()

Returns the signed area of this polygon. If the vertices are in counterclockwise order, the area is positive, otherwise it is negative.

# polygon.centroid()

Returns a two-element array representing the centroid of this polygon.

# polygon.clip(subject)

Clips the subject polygon against this polygon. In other words, returns a polygon representing the intersection of this polygon and the subject polygon. Assumes the clip polygon is counterclockwise and convex.