Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

perfect-arrows

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

perfect-arrows - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

8

CHANGELOG.md

@@ -0,1 +1,9 @@

# 0.3.2
- Improves start point when not colliding.
# 0.3.1
- Updates dependencies.
# 0.3.0

@@ -2,0 +10,0 @@

4

dist/perfect-arrows.cjs.development.js

@@ -595,3 +595,3 @@ 'use strict';

var arc = (bow + stretchEffect * stretch) / 2; // How much should the angle's intermediacy (45degree-ness) affect the angle?
var arc = bow + stretchEffect * stretch; // How much should the angle's intermediacy (45degree-ness) affect the angle?

@@ -630,3 +630,3 @@ var angleOffset = modulate(card, // a better curve here?

var _getPointBetween3 = getPointBetween(tsx, tsy, smpx, smpy, isColliding ? overlapEffect : distEffect);
var _getPointBetween3 = getPointBetween(tsx, tsy, smpx, smpy, isColliding ? overlapEffect : 0.15);

@@ -633,0 +633,0 @@ sx = _getPointBetween3[0];

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=Math.PI;function r(t,r,n,a){void 0===a&&(a=!1);var i=r[0],o=n[0],u=n[1],e=o+(t-i)/(r[1]-i)*(u-o);if(!0===a)if(o<u){if(e<o)return o;if(e>u)return u}else{if(e>o)return o;if(e<u)return u}return e}function n(t,r,n,a,i){var o=Math.sin(i),u=Math.cos(i),e=t-n,f=r-a;return[e*u-f*o+n,e*o+f*u+a]}function a(t,r,n,a){return Math.hypot(a-r,n-t)}function i(t,r,n,a){return Math.atan2(a-r,n-t)}function o(t,r,n,a){return[Math.cos(n)*a+t,Math.sin(n)*a+r]}function u(t,r,n,a,i){return void 0===i&&(i=.5),[t+(n-t)*i,r+(a-r)*i]}function e(r,n){return void 0===n&&(n=8),Math.floor(n*(.5+r/(2*t)%n))}function f(r){return r-2*t*Math.floor(r/(2*t))}function h(t,r,n,a,i,o,u,e){var f,h,v;if(a*(u-i)!=n*(e-o)&&0!=(v=n*(e-o)-a*(u-i))&&(h=((r-o)*n-(t-i)*a)/v,(f=((r-o)*(u-i)-(t-i)*(e-o))/v)>=0&&h>=0&&h<=1))return[t+f*n,r+f*a]}function v(t){return[Math.cos(t),Math.sin(t)]}function c(t,r,n,a,o,u,e,v,c){var M=o+e,s=u+v,d=o+c-1,p=u+c-1,I=o+e-c+1,P=u+v-c+1,l=[[d,p,Math.PI,1.5*Math.PI],[I,p,1.5*Math.PI,2*Math.PI],[I,P,0,.5*Math.PI],[d,P,.5*Math.PI,Math.PI]],x=[];return[[o,P,o,p],[d,u,I,u],[M,p,M,P],[I,s,d,s]].forEach((function(o,u){var e=o[0],v=o[1],M=o[2],s=o[3],d=l[u],p=d[0],I=d[1],P=d[2],b=d[3],m=function(t,r,n,a,i,o,u){return function(t,r,n,a,i,o,u){var e,f,h,v,c,M,s,d,p=[o-a,u-i],I=[a-t,i-r];return e=p[0]*I[0]+p[1]*I[1],f=2*(p[0]*p[0]+p[1]*p[1]),e*=-2,h=Math.sqrt(e*e-2*f*(I[0]*I[0]+I[1]*I[1]-n*n)),isNaN(h)?[]:(c=(e+h)/f,s=[],d=[],M=[],(v=(e-h)/f)<=1&&v>=0&&(s[0]=a+p[0]*v,s[1]=i+p[1]*v,M[0]=s),c<=1&&c>=0&&(d[0]=a+p[0]*c,d[1]=i+p[1]*c,M[M.length]=d),M)}(t,r,n,a,i,999999*o,999999*u)}(p,I,c,t,r,n,a);m&&m.filter((function(t){var r=f(i(p,I,t[0],t[1]));return r>P&&r<b})).forEach((function(t){return x.push(t)}));var w=h(t,r,n,a,e,v,M,s);w&&x.push(w)})),x}function M(t,r,n,a,i,o,u,e){return function(t,r,n,a){return[[t,r,t+n,r],[t+n,r,t+n,r+a],[t+n,r+a,t,r+a],[t,r+a,t,r]]}(t,r,n,a).find((function(t){return h(i,o,u,e,t[0],t[1],t[2],t[3])}))}var s=Math.PI;exports.getArrow=function(t,f,h,v,c){void 0===c&&(c={});var M=c.bow,s=void 0===M?0:M,d=c.stretch,p=void 0===d?.5:d,I=c.stretchMin,P=void 0===I?0:I,l=c.stretchMax,x=void 0===l?420:l,b=c.padStart,m=void 0===b?0:b,w=c.padEnd,E=void 0===w?0:w,g=c.flip,y=void 0!==g&&g,A=c.straights,B=void 0===A||A,N=i(t,f,h,v),S=a(t,f,h,v),_=function(t,r,n,a){return Math.abs((n-t)/2/((a-r)/2))}(t,f,h,v);if(S<2*(m+E)||0===s&&0===p||B&&[0,1,Infinity].includes(_)){var j=Math.max(0,Math.min(S-m,m)),q=Math.max(0,Math.min(S-j,E)),O=o(t,f,N,j),T=O[0],k=O[1],z=o(h,v,N+Math.PI,q),C=z[0],D=z[1],F=u(T,k,C,D,.5);return[T,k,F[0],F[1],C,D,N,N,N]}var G=(e(N)%2==0?1:-1)*(y?-1:1),H=s+r(S,[P,x],[1,0],!0)*p,J=u(t,f,h,v,.5),K=J[0],L=J[1],Q=u(t,f,h,v,.5-H),R=Q[0],U=Q[1],V=n(R,U,K,L,Math.PI/2*G),W=o(t,f,i(t,f,R=V[0],U=V[1]),m),X=W[0],Y=W[1],Z=o(h,v,i(h,v,R,U),E),$=Z[0],tt=Z[1],rt=i(R,U,t,f),nt=i(R,U,h,v),at=u(X,Y,$,tt,.5),it=at[0],ot=at[1],ut=u(X,Y,$,tt,.5-H),et=ut[0],ft=ut[1],ht=n(et,ft,it,ot,Math.PI/2*G),vt=u(R,U,et=ht[0],ft=ht[1],.5);return[X,Y,vt[0],vt[1],$,tt,nt,rt,N]},exports.getBoxToBoxArrow=function(o,h,d,p,I,P,l,x,b){var m,w,E,g;void 0===b&&(b={});var y=b.bow,A=void 0===y?0:y,B=b.stretch,N=void 0===B?.25:B,S=b.stretchMin,_=void 0===S?50:S,j=b.stretchMax,q=void 0===j?420:j,O=b.padStart,T=void 0===O?0:O,k=b.padEnd,z=void 0===k?20:k,C=b.flip,D=void 0!==C&&C,F=b.straights,G=void 0===F||F,H=o-T,J=h-T,K=d+2*T,L=p+2*T,Q=I-z,R=P-z,U=l+2*z,V=x+2*z,W=o+d/2,X=h+p/2,Y=I+l/2,Z=P+x/2,$=f(i(W,X,Y,Z)),tt=a(W,X,Y,Z);if(0===tt)return[W,X,Y,Z,Y,Z,0,0,0];var rt=(e($)%2==0?-1:1)*(D?-1:1),nt=function(r){return Math.abs(Math.abs(r%(t/2))-t/4)/(t/4)}($);nt<1&&nt>.85&&(nt=.99);var at=function(t,r,n,a,i,o,u,e){return!(t>=i+u||i>=t+n||r>=o+e||o>=r+a)}(H,J,K,L,Q,R,U,V),it=function(t,r,n,a,i,o,u,e,f,h){var v=t+n/2,M=r+a/2,s=o+e/2,d=u+f/2,p=(c(v,M,s-v,d-M,t,r,n,a,i)||[[v,M]])[0],I=p[0],P=p[1],l=(c(s,d,v-s,M-d,o,u,e,f,h)||[[s,d]])[0];return[I,P,l[0],l[1]]}(H,J,K,L,T,Q,R,U,V,z),ot=it[0],ut=it[1],et=it[2],ft=it[3],ht=a(ot,ut,et,ft);if(!at&&G&&nt%.5==0){var vt=u(ot,ut,et,ft,.5);return[ot,ut,vt[0],vt[1],et,ft,$,$-s,$]}var ct=at?r(ht,[0,tt],[0,1],!0):0,Mt=1-ht/tt,st=(A+r(ht,[_,q],[1,0],!0)*N)/2,dt=r(nt,[0,1],[.125*s,0],!0),pt=at?.5*s*nt:r(Mt,[.75,1],[0,.5*s],!0)*nt,It=v(ct>=.5?$+s*rt:$+(pt+dt*(at?1-ct:1))*rt),Pt=It[0],lt=It[1],xt=c(W,X,Pt,lt,H,J,K,L,T)[0],bt=xt[0],mt=xt[1],wt=M(H,J,K,L,W,X,Pt,lt);if(!wt)throw Error;var Et=u(wt[0],wt[1],wt[2],wt[3],.5),gt=Et[0],yt=Et[1],At=u(bt,mt,gt,yt,at?ct:Mt);if(m=At[0],w=At[1],ct>=.5){var Bt=v(i(W,X,gt,yt)),Nt=c(Y,Z,Bt[0],Bt[1],Q,R,U,V,z)[0];E=Nt[0],g=Nt[1]}else{var St=r(Mt,[.75,1],[0,1],!0),_t=at?r(ct,[0,1],[0,s/8],!0):0,jt=r(nt*St,[0,1],[0,s/16],!0),qt=v(ct>=.5?$+s*rt:$+s-(Mt*(s/12)*rt+(jt+_t)*rt+(pt+dt)*rt/2)),Ot=qt[0],Tt=qt[1],kt=c(Y,Z,Ot,Tt,Q,R,U,V,z)[0],zt=kt[0],Ct=kt[1],Dt=M(Q,R,U,V,Y,Z,Ot,Tt);if(!Dt)throw Error;var Ft=u(Dt[0],Dt[1],Dt[2],Dt[3],.5),Gt=u(zt,Ct,Ft[0],Ft[1],.25+.25*ct);E=Gt[0],g=Gt[1]}at&&(st+=ct/2),st*=1+(Mt*nt-ct)/2;var Ht=u(m,w,E,g,.5),Jt=Ht[0],Kt=Ht[1],Lt=u(m,w,E,g,Math.max(-2,Math.min(2,.5+st))),Qt=Lt[0],Rt=Lt[1],Ut=n(Qt,Rt,Jt,Kt,s/2*rt),Vt=Ut[0],Wt=Ut[1],Xt=n(Qt,Rt,Jt,Kt,s/2*-rt),Yt=Xt[0],Zt=Xt[1],$t=at&&a(Vt,Wt,Y,Z)<a(Yt,Zt,Y,Z)?[Yt,Zt]:[Vt,Wt],tr=$t[0],rr=$t[1],nr=i(tr,rr,m,w);return[m,w,tr,rr,E,g,i(tr,rr,E,g),nr,$]};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=Math.PI;function r(t,r,n,a){void 0===a&&(a=!1);var i=r[0],o=n[0],u=n[1],e=o+(t-i)/(r[1]-i)*(u-o);if(!0===a)if(o<u){if(e<o)return o;if(e>u)return u}else{if(e>o)return o;if(e<u)return u}return e}function n(t,r,n,a,i){var o=Math.sin(i),u=Math.cos(i),e=t-n,f=r-a;return[e*u-f*o+n,e*o+f*u+a]}function a(t,r,n,a){return Math.hypot(a-r,n-t)}function i(t,r,n,a){return Math.atan2(a-r,n-t)}function o(t,r,n,a){return[Math.cos(n)*a+t,Math.sin(n)*a+r]}function u(t,r,n,a,i){return void 0===i&&(i=.5),[t+(n-t)*i,r+(a-r)*i]}function e(r,n){return void 0===n&&(n=8),Math.floor(n*(.5+r/(2*t)%n))}function f(r){return r-2*t*Math.floor(r/(2*t))}function h(t,r,n,a,i,o,u,e){var f,h,v;if(a*(u-i)!=n*(e-o)&&0!=(v=n*(e-o)-a*(u-i))&&(h=((r-o)*n-(t-i)*a)/v,(f=((r-o)*(u-i)-(t-i)*(e-o))/v)>=0&&h>=0&&h<=1))return[t+f*n,r+f*a]}function v(t){return[Math.cos(t),Math.sin(t)]}function c(t,r,n,a,o,u,e,v,c){var M=o+e,s=u+v,d=o+c-1,p=u+c-1,I=o+e-c+1,P=u+v-c+1,l=[[d,p,Math.PI,1.5*Math.PI],[I,p,1.5*Math.PI,2*Math.PI],[I,P,0,.5*Math.PI],[d,P,.5*Math.PI,Math.PI]],x=[];return[[o,P,o,p],[d,u,I,u],[M,p,M,P],[I,s,d,s]].forEach((function(o,u){var e=o[0],v=o[1],M=o[2],s=o[3],d=l[u],p=d[0],I=d[1],P=d[2],b=d[3],m=function(t,r,n,a,i,o,u){return function(t,r,n,a,i,o,u){var e,f,h,v,c,M,s,d,p=[o-a,u-i],I=[a-t,i-r];return e=p[0]*I[0]+p[1]*I[1],f=2*(p[0]*p[0]+p[1]*p[1]),e*=-2,h=Math.sqrt(e*e-2*f*(I[0]*I[0]+I[1]*I[1]-n*n)),isNaN(h)?[]:(c=(e+h)/f,s=[],d=[],M=[],(v=(e-h)/f)<=1&&v>=0&&(s[0]=a+p[0]*v,s[1]=i+p[1]*v,M[0]=s),c<=1&&c>=0&&(d[0]=a+p[0]*c,d[1]=i+p[1]*c,M[M.length]=d),M)}(t,r,n,a,i,999999*o,999999*u)}(p,I,c,t,r,n,a);m&&m.filter((function(t){var r=f(i(p,I,t[0],t[1]));return r>P&&r<b})).forEach((function(t){return x.push(t)}));var w=h(t,r,n,a,e,v,M,s);w&&x.push(w)})),x}function M(t,r,n,a,i,o,u,e){return function(t,r,n,a){return[[t,r,t+n,r],[t+n,r,t+n,r+a],[t+n,r+a,t,r+a],[t,r+a,t,r]]}(t,r,n,a).find((function(t){return h(i,o,u,e,t[0],t[1],t[2],t[3])}))}var s=Math.PI;exports.getArrow=function(t,f,h,v,c){void 0===c&&(c={});var M=c.bow,s=void 0===M?0:M,d=c.stretch,p=void 0===d?.5:d,I=c.stretchMin,P=void 0===I?0:I,l=c.stretchMax,x=void 0===l?420:l,b=c.padStart,m=void 0===b?0:b,w=c.padEnd,E=void 0===w?0:w,g=c.flip,y=void 0!==g&&g,A=c.straights,B=void 0===A||A,N=i(t,f,h,v),S=a(t,f,h,v),_=function(t,r,n,a){return Math.abs((n-t)/2/((a-r)/2))}(t,f,h,v);if(S<2*(m+E)||0===s&&0===p||B&&[0,1,Infinity].includes(_)){var j=Math.max(0,Math.min(S-m,m)),q=Math.max(0,Math.min(S-j,E)),O=o(t,f,N,j),T=O[0],k=O[1],z=o(h,v,N+Math.PI,q),C=z[0],D=z[1],F=u(T,k,C,D,.5);return[T,k,F[0],F[1],C,D,N,N,N]}var G=(e(N)%2==0?1:-1)*(y?-1:1),H=s+r(S,[P,x],[1,0],!0)*p,J=u(t,f,h,v,.5),K=J[0],L=J[1],Q=u(t,f,h,v,.5-H),R=Q[0],U=Q[1],V=n(R,U,K,L,Math.PI/2*G),W=o(t,f,i(t,f,R=V[0],U=V[1]),m),X=W[0],Y=W[1],Z=o(h,v,i(h,v,R,U),E),$=Z[0],tt=Z[1],rt=i(R,U,t,f),nt=i(R,U,h,v),at=u(X,Y,$,tt,.5),it=at[0],ot=at[1],ut=u(X,Y,$,tt,.5-H),et=ut[0],ft=ut[1],ht=n(et,ft,it,ot,Math.PI/2*G),vt=u(R,U,et=ht[0],ft=ht[1],.5);return[X,Y,vt[0],vt[1],$,tt,nt,rt,N]},exports.getBoxToBoxArrow=function(o,h,d,p,I,P,l,x,b){var m,w,E,g;void 0===b&&(b={});var y=b.bow,A=void 0===y?0:y,B=b.stretch,N=void 0===B?.25:B,S=b.stretchMin,_=void 0===S?50:S,j=b.stretchMax,q=void 0===j?420:j,O=b.padStart,T=void 0===O?0:O,k=b.padEnd,z=void 0===k?20:k,C=b.flip,D=void 0!==C&&C,F=b.straights,G=void 0===F||F,H=o-T,J=h-T,K=d+2*T,L=p+2*T,Q=I-z,R=P-z,U=l+2*z,V=x+2*z,W=o+d/2,X=h+p/2,Y=I+l/2,Z=P+x/2,$=f(i(W,X,Y,Z)),tt=a(W,X,Y,Z);if(0===tt)return[W,X,Y,Z,Y,Z,0,0,0];var rt=(e($)%2==0?-1:1)*(D?-1:1),nt=function(r){return Math.abs(Math.abs(r%(t/2))-t/4)/(t/4)}($);nt<1&&nt>.85&&(nt=.99);var at=function(t,r,n,a,i,o,u,e){return!(t>=i+u||i>=t+n||r>=o+e||o>=r+a)}(H,J,K,L,Q,R,U,V),it=function(t,r,n,a,i,o,u,e,f,h){var v=t+n/2,M=r+a/2,s=o+e/2,d=u+f/2,p=(c(v,M,s-v,d-M,t,r,n,a,i)||[[v,M]])[0],I=p[0],P=p[1],l=(c(s,d,v-s,M-d,o,u,e,f,h)||[[s,d]])[0];return[I,P,l[0],l[1]]}(H,J,K,L,T,Q,R,U,V,z),ot=it[0],ut=it[1],et=it[2],ft=it[3],ht=a(ot,ut,et,ft);if(!at&&G&&nt%.5==0){var vt=u(ot,ut,et,ft,.5);return[ot,ut,vt[0],vt[1],et,ft,$,$-s,$]}var ct=at?r(ht,[0,tt],[0,1],!0):0,Mt=1-ht/tt,st=A+r(ht,[_,q],[1,0],!0)*N,dt=r(nt,[0,1],[.125*s,0],!0),pt=at?.5*s*nt:r(Mt,[.75,1],[0,.5*s],!0)*nt,It=v(ct>=.5?$+s*rt:$+(pt+dt*(at?1-ct:1))*rt),Pt=It[0],lt=It[1],xt=c(W,X,Pt,lt,H,J,K,L,T)[0],bt=xt[0],mt=xt[1],wt=M(H,J,K,L,W,X,Pt,lt);if(!wt)throw Error;var Et=u(wt[0],wt[1],wt[2],wt[3],.5),gt=Et[0],yt=Et[1],At=u(bt,mt,gt,yt,at?ct:.15);if(m=At[0],w=At[1],ct>=.5){var Bt=v(i(W,X,gt,yt)),Nt=c(Y,Z,Bt[0],Bt[1],Q,R,U,V,z)[0];E=Nt[0],g=Nt[1]}else{var St=r(Mt,[.75,1],[0,1],!0),_t=at?r(ct,[0,1],[0,s/8],!0):0,jt=r(nt*St,[0,1],[0,s/16],!0),qt=v(ct>=.5?$+s*rt:$+s-(Mt*(s/12)*rt+(jt+_t)*rt+(pt+dt)*rt/2)),Ot=qt[0],Tt=qt[1],kt=c(Y,Z,Ot,Tt,Q,R,U,V,z)[0],zt=kt[0],Ct=kt[1],Dt=M(Q,R,U,V,Y,Z,Ot,Tt);if(!Dt)throw Error;var Ft=u(Dt[0],Dt[1],Dt[2],Dt[3],.5),Gt=u(zt,Ct,Ft[0],Ft[1],.25+.25*ct);E=Gt[0],g=Gt[1]}at&&(st+=ct/2),st*=1+(Mt*nt-ct)/2;var Ht=u(m,w,E,g,.5),Jt=Ht[0],Kt=Ht[1],Lt=u(m,w,E,g,Math.max(-2,Math.min(2,.5+st))),Qt=Lt[0],Rt=Lt[1],Ut=n(Qt,Rt,Jt,Kt,s/2*rt),Vt=Ut[0],Wt=Ut[1],Xt=n(Qt,Rt,Jt,Kt,s/2*-rt),Yt=Xt[0],Zt=Xt[1],$t=at&&a(Vt,Wt,Y,Z)<a(Yt,Zt,Y,Z)?[Yt,Zt]:[Vt,Wt],tr=$t[0],rr=$t[1],nr=i(tr,rr,m,w);return[m,w,tr,rr,E,g,i(tr,rr,E,g),nr,$]};
//# sourceMappingURL=perfect-arrows.cjs.production.min.js.map

@@ -591,3 +591,3 @@ var PI = Math.PI;

var arc = (bow + stretchEffect * stretch) / 2; // How much should the angle's intermediacy (45degree-ness) affect the angle?
var arc = bow + stretchEffect * stretch; // How much should the angle's intermediacy (45degree-ness) affect the angle?

@@ -626,3 +626,3 @@ var angleOffset = modulate(card, // a better curve here?

var _getPointBetween3 = getPointBetween(tsx, tsy, smpx, smpy, isColliding ? overlapEffect : distEffect);
var _getPointBetween3 = getPointBetween(tsx, tsy, smpx, smpy, isColliding ? overlapEffect : 0.15);

@@ -629,0 +629,0 @@ sx = _getPointBetween3[0];

{
"version": "0.3.1",
"version": "0.3.2",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -155,3 +155,3 @@ import {

// What should the curved line's arc be?
let arc = (bow + stretchEffect * stretch) / 2
let arc = bow + stretchEffect * stretch

@@ -222,3 +222,3 @@ // How much should the angle's intermediacy (45degree-ness) affect the angle?

smpy,
isColliding ? overlapEffect : distEffect
isColliding ? overlapEffect : 0.15
)

@@ -225,0 +225,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc