d3-polygon
Advanced tools
Comparing version 1.0.6 to 2.0.0-rc.1
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-polygon/ v1.0.6 Copyright 2019 Mike Bostock | ||
// https://d3js.org/d3-polygon/ v2.0.0-rc.1 Copyright 2020 Mike Bostock | ||
(function (global, factory) { | ||
@@ -61,7 +61,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
function computeUpperHullIndexes(points) { | ||
var n = points.length, | ||
indexes = [0, 1], | ||
size = 2; | ||
const n = points.length, | ||
indexes = [0, 1]; | ||
let size = 2, i; | ||
for (var i = 2; i < n; ++i) { | ||
for (i = 2; i < n; ++i) { | ||
while (size > 1 && cross(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size; | ||
@@ -137,3 +137,3 @@ indexes[size++] = i; | ||
ya -= yb; | ||
perimeter += Math.sqrt(xa * xa + ya * ya); | ||
perimeter += Math.hypot(xa, ya); | ||
} | ||
@@ -140,0 +140,0 @@ |
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-polygon/ v1.0.6 Copyright 2019 Mike Bostock | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n=n||self).d3=n.d3||{})}(this,function(n){"use strict";function e(n,e){return n[0]-e[0]||n[1]-e[1]}function r(n){for(var e,r,t,o=n.length,f=[0,1],u=2,l=2;l<o;++l){for(;u>1&&(e=n[f[u-2]],r=n[f[u-1]],t=n[l],(r[0]-e[0])*(t[1]-e[1])-(r[1]-e[1])*(t[0]-e[0])<=0);)--u;f[u++]=l}return f.slice(0,u)}n.polygonArea=function(n){for(var e,r=-1,t=n.length,o=n[t-1],f=0;++r<t;)e=o,o=n[r],f+=e[1]*o[0]-e[0]*o[1];return f/2},n.polygonCentroid=function(n){for(var e,r,t=-1,o=n.length,f=0,u=0,l=n[o-1],i=0;++t<o;)e=l,l=n[t],i+=r=e[0]*l[1]-l[0]*e[1],f+=(e[0]+l[0])*r,u+=(e[1]+l[1])*r;return[f/(i*=3),u/i]},n.polygonContains=function(n,e){for(var r,t,o=n.length,f=n[o-1],u=e[0],l=e[1],i=f[0],g=f[1],h=!1,a=0;a<o;++a)r=(f=n[a])[0],(t=f[1])>l!=g>l&&u<(i-r)*(l-t)/(g-t)+r&&(h=!h),i=r,g=t;return h},n.polygonHull=function(n){if((o=n.length)<3)return null;var t,o,f=new Array(o),u=new Array(o);for(t=0;t<o;++t)f[t]=[+n[t][0],+n[t][1],t];for(f.sort(e),t=0;t<o;++t)u[t]=[f[t][0],-f[t][1]];var l=r(f),i=r(u),g=i[0]===l[0],h=i[i.length-1]===l[l.length-1],a=[];for(t=l.length-1;t>=0;--t)a.push(n[f[l[t]][2]]);for(t=+g;t<i.length-h;++t)a.push(n[f[i[t]][2]]);return a},n.polygonLength=function(n){for(var e,r,t=-1,o=n.length,f=n[o-1],u=f[0],l=f[1],i=0;++t<o;)e=u,r=l,e-=u=(f=n[t])[0],r-=l=f[1],i+=Math.sqrt(e*e+r*r);return i},Object.defineProperty(n,"__esModule",{value:!0})}); | ||
// https://d3js.org/d3-polygon/ v2.0.0-rc.1 Copyright 2020 Mike Bostock | ||
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n=n||self).d3=n.d3||{})}(this,function(n){"use strict";function e(n,e){return n[0]-e[0]||n[1]-e[1]}function t(n){const e=n.length,t=[0,1];let r,o=2;for(r=2;r<e;++r){for(;o>1&&(f=n[t[o-2]],u=n[t[o-1]],l=n[r],(u[0]-f[0])*(l[1]-f[1])-(u[1]-f[1])*(l[0]-f[0])<=0);)--o;t[o++]=r}var f,u,l;return t.slice(0,o)}n.polygonArea=function(n){for(var e,t=-1,r=n.length,o=n[r-1],f=0;++t<r;)e=o,o=n[t],f+=e[1]*o[0]-e[0]*o[1];return f/2},n.polygonCentroid=function(n){for(var e,t,r=-1,o=n.length,f=0,u=0,l=n[o-1],i=0;++r<o;)e=l,l=n[r],i+=t=e[0]*l[1]-l[0]*e[1],f+=(e[0]+l[0])*t,u+=(e[1]+l[1])*t;return[f/(i*=3),u/i]},n.polygonContains=function(n,e){for(var t,r,o=n.length,f=n[o-1],u=e[0],l=e[1],i=f[0],g=f[1],h=!1,c=0;c<o;++c)t=(f=n[c])[0],(r=f[1])>l!=g>l&&u<(i-t)*(l-r)/(g-r)+t&&(h=!h),i=t,g=r;return h},n.polygonHull=function(n){if((o=n.length)<3)return null;var r,o,f=new Array(o),u=new Array(o);for(r=0;r<o;++r)f[r]=[+n[r][0],+n[r][1],r];for(f.sort(e),r=0;r<o;++r)u[r]=[f[r][0],-f[r][1]];var l=t(f),i=t(u),g=i[0]===l[0],h=i[i.length-1]===l[l.length-1],c=[];for(r=l.length-1;r>=0;--r)c.push(n[f[l[r]][2]]);for(r=+g;r<i.length-h;++r)c.push(n[f[i[r]][2]]);return c},n.polygonLength=function(n){for(var e,t,r=-1,o=n.length,f=n[o-1],u=f[0],l=f[1],i=0;++r<o;)e=u,t=l,e-=u=(f=n[r])[0],t-=l=f[1],i+=Math.hypot(e,t);return i},Object.defineProperty(n,"__esModule",{value:!0})}); |
{ | ||
"name": "d3-polygon", | ||
"version": "1.0.6", | ||
"version": "2.0.0-rc.1", | ||
"publishConfig": { | ||
"tag": "next" | ||
}, | ||
"description": "Operations for two-dimensional polygons.", | ||
@@ -5,0 +8,0 @@ "keywords": [ |
@@ -10,3 +10,3 @@ # d3-polygon | ||
```html | ||
<script src="https://d3js.org/d3-polygon.v1.min.js"></script> | ||
<script src="https://d3js.org/d3-polygon.v2.min.js"></script> | ||
<script> | ||
@@ -13,0 +13,0 @@ |
@@ -11,7 +11,7 @@ import cross from "./cross.js"; | ||
function computeUpperHullIndexes(points) { | ||
var n = points.length, | ||
indexes = [0, 1], | ||
size = 2; | ||
const n = points.length, | ||
indexes = [0, 1]; | ||
let size = 2, i; | ||
for (var i = 2; i < n; ++i) { | ||
for (i = 2; i < n; ++i) { | ||
while (size > 1 && cross(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size; | ||
@@ -18,0 +18,0 @@ indexes[size++] = i; |
@@ -19,3 +19,3 @@ export default function(polygon) { | ||
ya -= yb; | ||
perimeter += Math.sqrt(xa * xa + ya * ya); | ||
perimeter += Math.hypot(xa, ya); | ||
} | ||
@@ -22,0 +22,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15441
1
1