Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
polyclip-ts
Advanced tools
Apply boolean polygon clipping operations (intersection, union, difference, xor) to your Polygons & MultiPolygons.
Apply boolean polygon clipping operations (intersection
, union
, difference
, xor
) to your Polygons & MultiPolygons.
If you use npm, npm install polyclip-ts
. You can also download the latest release on GitHub. For vanilla HTML in modern browsers, import polyclip-ts from Skypack:
<script type="module">
import * as polyclip from "https://cdn.skypack.dev/polyclip-ts";
polyclip.intersection(…)
</script>
For legacy environments, you can load polyclip-ts’s UMD bundle from an npm-based CDN such as jsDelivr; a polyclip global is exported:
<script src="https://cdn.jsdelivr.net/npm/polyclip-ts/dist/polyclip-ts.umd.min.js"></script>
<script>
polyclip.intersection(…)
</script>
import * as polyclip from "polyclip-ts"
const poly1 = [[[0,0],[2,0],[0,2],[0,0]]]
const poly2 = [[[-1,0],[1,0],[0,1],[-1,0]]]
polyclip.union (poly1, poly2 /* , poly3, ... */)
polyclip.intersection(poly1, poly2 /* , poly3, ... */)
polyclip.xor (poly1, poly2 /* , poly3, ... */)
polyclip.difference (poly1, poly2 /* , poly3, ... */)
/* All functions take one or more [multi]polygon(s) as input */
polyclip.union (geom, ...moreGeoms)
polyclip.intersection(geom, ...moreGeoms)
polyclip.xor (geom, ...moreGeoms)
/* The moreGeoms will be subtracted from the geom */
polyclip.difference (geom, ...moreGeoms)
Each positional argument (geom
) may be either a Polygon or a MultiPolygon. The GeoJSON spec is followed, with the following notes/modifications:
For non-empty results, output will always be a MultiPolygon containing one or more non-overlapping, non-edge-sharing Polygons. The GeoJSON spec is followed, with the following notes/modifications:
In the event that the result of the operation is the empty set, output will be a MultiPolygon with no Polygons: []
.
Run: npm test
The tests are broken up into unit tests and end-to-end tests. The end-to-end tests are organized as GeoJSON files, to make them easy to visualize thanks to GitHub's helpful rendering of GeoJSON files. Browse those tests here.
The Martinez-Rueda-Feito polygon clipping algorithm is used to compute the result in O((n+k)*log(n))
time, where n
is the total number of edges in all polygons involved and k
is the number of intersections between edges.
FAQs
Apply boolean polygon clipping operations (intersection, union, difference, xor) to your Polygons & MultiPolygons.
The npm package polyclip-ts receives a total of 80,369 weekly downloads. As such, polyclip-ts popularity was classified as popular.
We found that polyclip-ts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.