Socket
Socket
Sign inDemoInstall

perfect-freehand

Package Overview
Dependencies
Maintainers
1
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

perfect-freehand - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

2

dist/cjs/index.js

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

var mt=Object.defineProperty;var dt=t=>mt(t,"__esModule",{value:!0});var xt=(t,e)=>{dt(t);for(var n in e)mt(t,n,{get:e[n],enumerable:!0})};xt(exports,{default:()=>yt,getStroke:()=>nt,getStrokeOutlinePoints:()=>tt,getStrokePoints:()=>et});function X(t,e,n,O=k=>k){return t*O(.5-e*(.5-n))}function v(t,e){return[t[0]+e[0],t[1]+e[1]]}function d(t,e){return[t[0]-e[0],t[1]-e[1]]}function z(t,e){return[t[0]*e,t[1]*e]}function kt(t,e){return[t[0]/e,t[1]/e]}function I(t){return[t[1],-t[0]]}function at(t,e){return t[0]*e[0]+t[1]*e[1]}function j(t,e){return t[0]===e[0]&&t[1]===e[1]}function St(t){return Math.hypot(t[0],t[1])}function Pt(t){return t[0]*t[0]+t[1]*t[1]}function A(t,e){return Pt(d(t,e))}function R(t){return kt(t,St(t))}function q(t,e){return Math.hypot(t[1]-e[1],t[0]-e[0])}function lt(t,e){return z(v(t,e),.5)}function C(t,e,n){let O=Math.sin(n),k=Math.cos(n),u=t[0]-e[0],a=t[1]-e[1],b=u*k-a*O,g=u*O+a*k;return[b+e[0],g+e[1]]}function D(t,e,n){return v(t,z(d(e,t),n))}function x(t,e,n){return v(t,z(e,n))}var ft=.3,{min:_,PI:N}=Math;function tt(t,e={}){var ut;let{size:n=16,smoothing:O=.5,thinning:k=.5,simulatePressure:u=!0,easing:a=o=>o,start:b={},end:g={},last:E=!1}=e,{streamline:T=.5}=e,{cap:J=!0,taper:M=0,easing:bt=o=>o*(2-o)}=b,{cap:gt=!0,taper:K=0,easing:ht=o=>--o*o*o+1}=g;if(T/=2,t.length===0)return[];let rt=t[t.length-1].runningLength,h=[],P=[],Y=t.slice(0,10).reduce((o,S)=>{let l=S.pressure;if(u){let i=_(1,S.distance/n),p=_(1,1-i);l=_(1,o+(p-o)*(i*ft))}return(o+l)/2},t[0].pressure),y=X(n,k,t[t.length-1].pressure,a),ot,st=t[0].vector,V=t[0].point,F=V,c=V,m=F,Q=!0;for(let o=0;o<t.length-1;o++){let{pressure:S}=t[o],{point:l,vector:i,distance:p,runningLength:r}=t[o];if(o>0&&Q&&r<n/2)continue;if(Q&&(Q=!1),k){if(u){let H=_(1,p/n),w=_(1,1-H);S=_(1,Y+(w-Y)*(H*ft))}y=X(n,k,S,a)}else y=n/2;ot===void 0&&(ot=y);let s=r<M?bt(r/M):1,G=rt-r<K?ht((rt-r)/K):1;y=Math.max(.01,y*Math.min(s,G));let L=((ut=t[o+1])==null?void 0:ut.vector)||i,B=at(i,L);if(B<0){let H=z(I(st),y);for(let w=0;w<1;w+=.2)m=C(v(l,H),l,N*-w),c=C(d(l,H),l,N*w),P.push(m),h.push(c);V=c,F=m;continue}let it=z(I(D(L,i,B)),y);c=d(l,it),m=v(l,it);let pt=o<2||B<.25,ct=Math.pow(Math.max((r>n?n:n/2)*O,1),2);(pt||A(V,c)>ct)&&(h.push(D(V,c,T)),V=c),(pt||A(F,m)>ct)&&(P.push(D(F,m,T)),F=m),Y=S,st=i}let f=t[0],Z=t[t.length-1],$=Q||P.length<2||h.length<2;if($&&(!(M||K)||E)){let o=0,S=j(f.point,Z.point)?v(f.point,[1,1]):Z.point;for(let p=0;p<t.length;p++){let{pressure:r,runningLength:s}=t[p];if(s>n){o=X(n,k,r,a);break}}let l=x(f.point,I(R(d(f.point,S))),-(o||y)),i=[];for(let p=0,r=.1;p<=1;p+=r)i.push(C(l,f.point,N*2*p));return i}let U=[],W=[];if(h.length>1&&P.length>1){m=P[1];for(let r=1;r<h.length;r++)if(!j(m,h[r])){c=h[r];break}if(J||M)if(!M&&!(K&&$)){if(!j(m,c)){let r=x(f.point,R(d(c,m)),-q(m,c)/2);for(let s=0,G=.1;s<=1;s+=G){let L=C(r,f.point,N*s);if(q(L,c)<1)break;U.push(L)}h.shift(),P.shift()}}else U.push(f.point,v(f.point,[.1,.1]));else if(!j(m,c)){let r=R(d(c,m)),s=q(m,c)/2;U.concat(x(f.point,r,s*.95),x(f.point,r,s),x(f.point,r,-s),x(f.point,r,-s*.95)),h.shift(),P.shift()}let o=h[h.length-1],S=P[P.length-1],l=lt(o,S),i=Z.point,p=I(R(d(i,l)));if(gt||K)if(!K&&!(M&&$)){let r=x(i,p,y);for(let s=0,G=.1;s<=1;s+=G){let L=C(r,i,N*3*s);if(q(L,S)<1)break;W.push(L)}}else W.push(i);else{let r=D(l,i,.95),s=y*.95;W.concat(x(r,p,s),x(i,p,s),x(i,p,-s),x(r,p,-s))}}return h.concat(W,P.reverse(),U)}function et(t,e={}){let{streamline:n=.5}=e,{simulatePressure:O=!0,last:k=!1}=e;if(t.length===0)return[];n=n/(O?3:2);let u=Array.isArray(t[0])?t:t.map(({x:g,y:E,pressure:T=.5})=>[g,E,T]);u.length===1&&u.push([...v(u[0],[1,1]),u[0][2]||.5]);let a=[],b={point:[u[0][0],u[0][1]],pressure:u[0][2]||.25,vector:[1,1],distance:0,runningLength:0};a.push(b);for(let g=2;g<u.length;g++){let E=k&&g===u.length-1?u[g]:D(b.point,u[g],1-n);if(j(b.point,E))continue;let T=R(d(b.point,E)),J=q(E,b.point),M=b.runningLength+J;b={point:E,pressure:u[g][2]||.5,vector:T,distance:J,runningLength:M},a.push(b)}return a.length>1&&(a[0].vector=R(d(a[0].point,a[1].point))),a}function nt(t,e={}){return tt(et(t,e),e)}var yt=nt;
var ct=Object.defineProperty;var dt=t=>ct(t,"__esModule",{value:!0});var xt=(t,e)=>{dt(t);for(var n in e)ct(t,n,{get:e[n],enumerable:!0})};xt(exports,{default:()=>yt,getStroke:()=>nt,getStrokeOutlinePoints:()=>tt,getStrokePoints:()=>et});function X(t,e,n,O=k=>k){return t*O(.5-e*(.5-n))}function v(t,e){return[t[0]+e[0],t[1]+e[1]]}function d(t,e){return[t[0]-e[0],t[1]-e[1]]}function z(t,e){return[t[0]*e,t[1]*e]}function kt(t,e){return[t[0]/e,t[1]/e]}function I(t){return[t[1],-t[0]]}function at(t,e){return t[0]*e[0]+t[1]*e[1]}function j(t,e){return t[0]===e[0]&&t[1]===e[1]}function St(t){return Math.hypot(t[0],t[1])}function Pt(t){return t[0]*t[0]+t[1]*t[1]}function A(t,e){return Pt(d(t,e))}function R(t){return kt(t,St(t))}function q(t,e){return Math.hypot(t[1]-e[1],t[0]-e[0])}function lt(t,e){return z(v(t,e),.5)}function C(t,e,n){let O=Math.sin(n),k=Math.cos(n),u=t[0]-e[0],a=t[1]-e[1],b=u*k-a*O,h=u*O+a*k;return[b+e[0],h+e[1]]}function D(t,e,n){return v(t,z(d(e,t),n))}function x(t,e,n){return v(t,z(e,n))}var ft=.3,{min:_,PI:N}=Math;function tt(t,e={}){var ut;let{size:n=16,smoothing:O=.5,thinning:k=.5,simulatePressure:u=!0,easing:a=o=>o,start:b={},end:h={},last:E=!1}=e,{streamline:T=.5}=e,{cap:J=!0,taper:M=0,easing:bt=o=>o*(2-o)}=b,{cap:ht=!0,taper:K=0,easing:gt=o=>--o*o*o+1}=h;if(T/=2,t.length===0)return[];let rt=t[t.length-1].runningLength,g=[],P=[],Y=t.slice(0,10).reduce((o,S)=>{let l=S.pressure;if(u){let i=_(1,S.distance/n),p=_(1,1-i);l=_(1,o+(p-o)*(i*ft))}return(o+l)/2},t[0].pressure),y=X(n,k,t[t.length-1].pressure,a),ot,st=t[0].vector,V=t[0].point,F=V,m=V,c=F,Q=!0;for(let o=0;o<t.length-1;o++){let{pressure:S}=t[o],{point:l,vector:i,distance:p,runningLength:r}=t[o];if(o>0&&Q&&r<n/2)continue;if(Q&&(Q=!1),k){if(u){let H=_(1,p/n),w=_(1,1-H);S=_(1,Y+(w-Y)*(H*ft))}y=X(n,k,S,a)}else y=n/2;ot===void 0&&(ot=y);let s=r<M?bt(r/M):1,G=rt-r<K?gt((rt-r)/K):1;y=Math.max(.01,y*Math.min(s,G));let L=((ut=t[o+1])==null?void 0:ut.vector)||i,B=at(i,L);if(B<0){let H=z(I(st),y);for(let w=0;w<1;w+=.2)c=C(v(l,H),l,N*-w),m=C(d(l,H),l,N*w),P.push(c),g.push(m);V=m,F=c;continue}let it=z(I(D(L,i,B)),y);m=d(l,it),c=v(l,it);let pt=o<2||B<.25,mt=Math.pow(Math.max((r>n?n:n/2)*O,1),2);(pt||A(V,m)>mt)&&(g.push(D(V,m,T)),V=m),(pt||A(F,c)>mt)&&(P.push(D(F,c,T)),F=c),Y=S,st=i}let f=t[0],Z=t[t.length-1],$=Q||P.length<2||g.length<2;if($&&(!(M||K)||E)){let o=0,S=j(f.point,Z.point)?v(f.point,[1,1]):Z.point;for(let p=0;p<t.length;p++){let{pressure:r,runningLength:s}=t[p];if(s>n){o=X(n,k,r,a);break}}let l=x(f.point,I(R(d(f.point,S))),-(o||y)),i=[];for(let p=0,r=.1;p<=1;p+=r)i.push(C(l,f.point,N*2*p));return i}let U=[],W=[];if(g.length>1&&P.length>1){c=P[1];for(let r=1;r<g.length;r++)if(!j(c,g[r])){m=g[r];break}if(J||M)if(!M&&!(K&&$)){if(!j(c,m)){let r=x(f.point,R(d(m,c)),-q(c,m)/2);for(let s=0,G=.1;s<=1;s+=G){let L=C(r,f.point,N*s);if(q(L,m)<1)break;U.push(L)}g.shift(),P.shift()}}else U.push(f.point,v(f.point,[.1,.1]));else if(!j(c,m)){let r=R(d(m,c)),s=q(c,m)/2;U.push(x(f.point,r,s*.95),x(f.point,r,s),x(f.point,r,-s),x(f.point,r,-s*.95)),g.shift(),P.shift()}let o=g[g.length-1],S=P[P.length-1],l=lt(o,S),i=Z.point,p=I(R(d(i,l)));if(ht||K)if(!K&&!(M&&$)){let r=x(i,p,y);for(let s=0,G=.1;s<=1;s+=G){let L=C(r,i,N*3*s);if(q(L,S)<1)break;W.push(L)}}else W.push(i);else{let r=D(l,i,.95),s=y*.95;W.push(x(r,p,s),x(i,p,s),x(i,p,-s),x(r,p,-s))}}return g.concat(W,P.reverse(),U)}function et(t,e={}){let{streamline:n=.5}=e,{simulatePressure:O=!0,last:k=!1}=e;if(t.length===0)return[];n=n/(O?3:2);let u=Array.isArray(t[0])?t:t.map(({x:h,y:E,pressure:T=.5})=>[h,E,T]);u.length===1&&u.push([...v(u[0],[1,1]),u[0][2]||.5]);let a=[],b={point:[u[0][0],u[0][1]],pressure:u[0][2]||.25,vector:[1,1],distance:0,runningLength:0};a.push(b);for(let h=2;h<u.length;h++){let E=k&&h===u.length-1?u[h]:D(b.point,u[h],1-n);if(j(b.point,E))continue;let T=R(d(b.point,E)),J=q(E,b.point),M=b.runningLength+J;b={point:E,pressure:u[h][2]||.5,vector:T,distance:J,runningLength:M},a.push(b)}return a.length>1&&(a[0].vector=R(d(a[0].point,a[1].point))),a}function nt(t,e={}){return tt(et(t,e),e)}var yt=nt;

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

function X(t,e,o,O=k=>k){return t*O(.5-e*(.5-o))}function v(t,e){return[t[0]+e[0],t[1]+e[1]]}function d(t,e){return[t[0]-e[0],t[1]-e[1]]}function z(t,e){return[t[0]*e,t[1]*e]}function ht(t,e){return[t[0]/e,t[1]/e]}function I(t){return[t[1],-t[0]]}function it(t,e){return t[0]*e[0]+t[1]*e[1]}function j(t,e){return t[0]===e[0]&&t[1]===e[1]}function dt(t){return Math.hypot(t[0],t[1])}function xt(t){return t[0]*t[0]+t[1]*t[1]}function A(t,e){return xt(d(t,e))}function R(t){return ht(t,dt(t))}function q(t,e){return Math.hypot(t[1]-e[1],t[0]-e[0])}function pt(t,e){return z(v(t,e),.5)}function C(t,e,o){let O=Math.sin(o),k=Math.cos(o),u=t[0]-e[0],a=t[1]-e[1],b=u*k-a*O,g=u*O+a*k;return[b+e[0],g+e[1]]}function D(t,e,o){return v(t,z(d(e,t),o))}function x(t,e,o){return v(t,z(e,o))}var ct=.3,{min:_,PI:N}=Math;function mt(t,e={}){var rt;let{size:o=16,smoothing:O=.5,thinning:k=.5,simulatePressure:u=!0,easing:a=r=>r,start:b={},end:g={},last:E=!1}=e,{streamline:T=.5}=e,{cap:J=!0,taper:M=0,easing:ft=r=>r*(2-r)}=b,{cap:bt=!0,taper:K=0,easing:gt=r=>--r*r*r+1}=g;if(T/=2,t.length===0)return[];let tt=t[t.length-1].runningLength,h=[],P=[],Y=t.slice(0,10).reduce((r,S)=>{let l=S.pressure;if(u){let i=_(1,S.distance/o),p=_(1,1-i);l=_(1,r+(p-r)*(i*ct))}return(r+l)/2},t[0].pressure),y=X(o,k,t[t.length-1].pressure,a),et,nt=t[0].vector,V=t[0].point,F=V,c=V,m=F,Q=!0;for(let r=0;r<t.length-1;r++){let{pressure:S}=t[r],{point:l,vector:i,distance:p,runningLength:n}=t[r];if(r>0&&Q&&n<o/2)continue;if(Q&&(Q=!1),k){if(u){let H=_(1,p/o),w=_(1,1-H);S=_(1,Y+(w-Y)*(H*ct))}y=X(o,k,S,a)}else y=o/2;et===void 0&&(et=y);let s=n<M?ft(n/M):1,G=tt-n<K?gt((tt-n)/K):1;y=Math.max(.01,y*Math.min(s,G));let L=((rt=t[r+1])==null?void 0:rt.vector)||i,B=it(i,L);if(B<0){let H=z(I(nt),y);for(let w=0;w<1;w+=.2)m=C(v(l,H),l,N*-w),c=C(d(l,H),l,N*w),P.push(m),h.push(c);V=c,F=m;continue}let ot=z(I(D(L,i,B)),y);c=d(l,ot),m=v(l,ot);let st=r<2||B<.25,ut=Math.pow(Math.max((n>o?o:o/2)*O,1),2);(st||A(V,c)>ut)&&(h.push(D(V,c,T)),V=c),(st||A(F,m)>ut)&&(P.push(D(F,m,T)),F=m),Y=S,nt=i}let f=t[0],Z=t[t.length-1],$=Q||P.length<2||h.length<2;if($&&(!(M||K)||E)){let r=0,S=j(f.point,Z.point)?v(f.point,[1,1]):Z.point;for(let p=0;p<t.length;p++){let{pressure:n,runningLength:s}=t[p];if(s>o){r=X(o,k,n,a);break}}let l=x(f.point,I(R(d(f.point,S))),-(r||y)),i=[];for(let p=0,n=.1;p<=1;p+=n)i.push(C(l,f.point,N*2*p));return i}let U=[],W=[];if(h.length>1&&P.length>1){m=P[1];for(let n=1;n<h.length;n++)if(!j(m,h[n])){c=h[n];break}if(J||M)if(!M&&!(K&&$)){if(!j(m,c)){let n=x(f.point,R(d(c,m)),-q(m,c)/2);for(let s=0,G=.1;s<=1;s+=G){let L=C(n,f.point,N*s);if(q(L,c)<1)break;U.push(L)}h.shift(),P.shift()}}else U.push(f.point,v(f.point,[.1,.1]));else if(!j(m,c)){let n=R(d(c,m)),s=q(m,c)/2;U.concat(x(f.point,n,s*.95),x(f.point,n,s),x(f.point,n,-s),x(f.point,n,-s*.95)),h.shift(),P.shift()}let r=h[h.length-1],S=P[P.length-1],l=pt(r,S),i=Z.point,p=I(R(d(i,l)));if(bt||K)if(!K&&!(M&&$)){let n=x(i,p,y);for(let s=0,G=.1;s<=1;s+=G){let L=C(n,i,N*3*s);if(q(L,S)<1)break;W.push(L)}}else W.push(i);else{let n=D(l,i,.95),s=y*.95;W.concat(x(n,p,s),x(i,p,s),x(i,p,-s),x(n,p,-s))}}return h.concat(W,P.reverse(),U)}function at(t,e={}){let{streamline:o=.5}=e,{simulatePressure:O=!0,last:k=!1}=e;if(t.length===0)return[];o=o/(O?3:2);let u=Array.isArray(t[0])?t:t.map(({x:g,y:E,pressure:T=.5})=>[g,E,T]);u.length===1&&u.push([...v(u[0],[1,1]),u[0][2]||.5]);let a=[],b={point:[u[0][0],u[0][1]],pressure:u[0][2]||.25,vector:[1,1],distance:0,runningLength:0};a.push(b);for(let g=2;g<u.length;g++){let E=k&&g===u.length-1?u[g]:D(b.point,u[g],1-o);if(j(b.point,E))continue;let T=R(d(b.point,E)),J=q(E,b.point),M=b.runningLength+J;b={point:E,pressure:u[g][2]||.5,vector:T,distance:J,runningLength:M},a.push(b)}return a.length>1&&(a[0].vector=R(d(a[0].point,a[1].point))),a}function lt(t,e={}){return mt(at(t,e),e)}var qt=lt;export{qt as default,lt as getStroke,mt as getStrokeOutlinePoints,at as getStrokePoints};
function X(t,e,o,O=k=>k){return t*O(.5-e*(.5-o))}function v(t,e){return[t[0]+e[0],t[1]+e[1]]}function d(t,e){return[t[0]-e[0],t[1]-e[1]]}function z(t,e){return[t[0]*e,t[1]*e]}function gt(t,e){return[t[0]/e,t[1]/e]}function I(t){return[t[1],-t[0]]}function it(t,e){return t[0]*e[0]+t[1]*e[1]}function j(t,e){return t[0]===e[0]&&t[1]===e[1]}function dt(t){return Math.hypot(t[0],t[1])}function xt(t){return t[0]*t[0]+t[1]*t[1]}function A(t,e){return xt(d(t,e))}function R(t){return gt(t,dt(t))}function q(t,e){return Math.hypot(t[1]-e[1],t[0]-e[0])}function pt(t,e){return z(v(t,e),.5)}function C(t,e,o){let O=Math.sin(o),k=Math.cos(o),u=t[0]-e[0],a=t[1]-e[1],b=u*k-a*O,h=u*O+a*k;return[b+e[0],h+e[1]]}function D(t,e,o){return v(t,z(d(e,t),o))}function x(t,e,o){return v(t,z(e,o))}var mt=.3,{min:_,PI:N}=Math;function ct(t,e={}){var rt;let{size:o=16,smoothing:O=.5,thinning:k=.5,simulatePressure:u=!0,easing:a=r=>r,start:b={},end:h={},last:E=!1}=e,{streamline:T=.5}=e,{cap:J=!0,taper:M=0,easing:ft=r=>r*(2-r)}=b,{cap:bt=!0,taper:K=0,easing:ht=r=>--r*r*r+1}=h;if(T/=2,t.length===0)return[];let tt=t[t.length-1].runningLength,g=[],P=[],Y=t.slice(0,10).reduce((r,S)=>{let l=S.pressure;if(u){let i=_(1,S.distance/o),p=_(1,1-i);l=_(1,r+(p-r)*(i*mt))}return(r+l)/2},t[0].pressure),y=X(o,k,t[t.length-1].pressure,a),et,nt=t[0].vector,V=t[0].point,F=V,m=V,c=F,Q=!0;for(let r=0;r<t.length-1;r++){let{pressure:S}=t[r],{point:l,vector:i,distance:p,runningLength:n}=t[r];if(r>0&&Q&&n<o/2)continue;if(Q&&(Q=!1),k){if(u){let H=_(1,p/o),w=_(1,1-H);S=_(1,Y+(w-Y)*(H*mt))}y=X(o,k,S,a)}else y=o/2;et===void 0&&(et=y);let s=n<M?ft(n/M):1,G=tt-n<K?ht((tt-n)/K):1;y=Math.max(.01,y*Math.min(s,G));let L=((rt=t[r+1])==null?void 0:rt.vector)||i,B=it(i,L);if(B<0){let H=z(I(nt),y);for(let w=0;w<1;w+=.2)c=C(v(l,H),l,N*-w),m=C(d(l,H),l,N*w),P.push(c),g.push(m);V=m,F=c;continue}let ot=z(I(D(L,i,B)),y);m=d(l,ot),c=v(l,ot);let st=r<2||B<.25,ut=Math.pow(Math.max((n>o?o:o/2)*O,1),2);(st||A(V,m)>ut)&&(g.push(D(V,m,T)),V=m),(st||A(F,c)>ut)&&(P.push(D(F,c,T)),F=c),Y=S,nt=i}let f=t[0],Z=t[t.length-1],$=Q||P.length<2||g.length<2;if($&&(!(M||K)||E)){let r=0,S=j(f.point,Z.point)?v(f.point,[1,1]):Z.point;for(let p=0;p<t.length;p++){let{pressure:n,runningLength:s}=t[p];if(s>o){r=X(o,k,n,a);break}}let l=x(f.point,I(R(d(f.point,S))),-(r||y)),i=[];for(let p=0,n=.1;p<=1;p+=n)i.push(C(l,f.point,N*2*p));return i}let U=[],W=[];if(g.length>1&&P.length>1){c=P[1];for(let n=1;n<g.length;n++)if(!j(c,g[n])){m=g[n];break}if(J||M)if(!M&&!(K&&$)){if(!j(c,m)){let n=x(f.point,R(d(m,c)),-q(c,m)/2);for(let s=0,G=.1;s<=1;s+=G){let L=C(n,f.point,N*s);if(q(L,m)<1)break;U.push(L)}g.shift(),P.shift()}}else U.push(f.point,v(f.point,[.1,.1]));else if(!j(c,m)){let n=R(d(m,c)),s=q(c,m)/2;U.push(x(f.point,n,s*.95),x(f.point,n,s),x(f.point,n,-s),x(f.point,n,-s*.95)),g.shift(),P.shift()}let r=g[g.length-1],S=P[P.length-1],l=pt(r,S),i=Z.point,p=I(R(d(i,l)));if(bt||K)if(!K&&!(M&&$)){let n=x(i,p,y);for(let s=0,G=.1;s<=1;s+=G){let L=C(n,i,N*3*s);if(q(L,S)<1)break;W.push(L)}}else W.push(i);else{let n=D(l,i,.95),s=y*.95;W.push(x(n,p,s),x(i,p,s),x(i,p,-s),x(n,p,-s))}}return g.concat(W,P.reverse(),U)}function at(t,e={}){let{streamline:o=.5}=e,{simulatePressure:O=!0,last:k=!1}=e;if(t.length===0)return[];o=o/(O?3:2);let u=Array.isArray(t[0])?t:t.map(({x:h,y:E,pressure:T=.5})=>[h,E,T]);u.length===1&&u.push([...v(u[0],[1,1]),u[0][2]||.5]);let a=[],b={point:[u[0][0],u[0][1]],pressure:u[0][2]||.25,vector:[1,1],distance:0,runningLength:0};a.push(b);for(let h=2;h<u.length;h++){let E=k&&h===u.length-1?u[h]:D(b.point,u[h],1-o);if(j(b.point,E))continue;let T=R(d(b.point,E)),J=q(E,b.point),M=b.runningLength+J;b={point:E,pressure:u[h][2]||.5,vector:T,distance:J,runningLength:M},a.push(b)}return a.length>1&&(a[0].vector=R(d(a[0].point,a[1].point))),a}function lt(t,e={}){return ct(at(t,e),e)}var qt=lt;export{qt as default,lt as getStroke,ct as getStrokeOutlinePoints,at as getStrokePoints};
{
"version": "1.0.4",
"version": "1.0.5",
"name": "perfect-freehand",

@@ -60,3 +60,3 @@ "private": false,

},
"gitHead": "629d7676258936730d13ecb767d00f79a9cd0e68"
"gitHead": "cb9b0f5a1daacdf204d03b07029781db1abc419b"
}

@@ -352,3 +352,3 @@ import { getStrokeRadius } from './getStrokeRadius'

startCap.concat(
startCap.push(
prj(firstPoint.point, vector, ptDist * 0.95),

@@ -407,3 +407,3 @@ prj(firstPoint.point, vector, ptDist),

const r = radius * 0.95
endCap.concat(
endCap.push(
prj(justBefore, direction, r),

@@ -410,0 +410,0 @@ prj(last, direction, r),

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