@leafer-in/motion-path 1.4.0 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/motion-path.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PathCommandMap, OneRadian, UnitConvert, PointHelper, BezierHelper, MatrixHelper, decorateLeafAttr, attr, isNull, Plugin, Transition, UI, LeafHelper, BranchHelper } from '@leafer-ui/draw';
|
|
2
2
|
|
|
3
3
|
const gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285];
|
|
4
4
|
const gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{PathCommandMap as t,OneRadian as o,UnitConvert as e,PointHelper as n,BezierHelper as a,MatrixHelper as i,decorateLeafAttr as r,attr as s,isNull as c,Plugin as h,Transition as u,UI as l,LeafHelper as f,BranchHelper as g}from"@leafer-ui/draw";const m=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],_=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:P}=Math,d={getDistance(t,o,e,n,a,i,r,s,c=1){let h,u,l,f,g,d,M=0,b=c/2;for(let c=0;c<m.length;c++)h=b*(1+m[c]),u=b*(1-m[c]),l=p(h,t,e,a,r),f=p(h,o,n,i,s),g=p(u,t,e,a,r),d=p(u,o,n,i,s),M+=_[c]*(P(l*l+f*f)+P(g*g+d*d));return M*b},getDerivative(t,o,e,n,a){const i=1-t;return 3*i*i*(e-o)+6*i*t*(n-e)+3*t*t*(a-n)},getRotation(t,e,n,a,i,r,s,c,h){const u=p(t,e,a,r,c),l=p(t,n,i,s,h);return Math.atan2(l,u)/o},getT(t,o,e,n,a,i,r,s,c,h,u=1){let l=0,f=1,g=t/o,m=u/o/3;if(g>=1)return 1;if(g<=0)return 0;for(;f-l>m;)M(e,n,a,i,r,s,c,h,g)<t?l=g:f=g,g=(l+f)/2;return g},cut(o,e,n,a,i,r,s,c,h,u){const l=1-e,f=l*n+e*i,g=l*a+e*r,m=l*i+e*s,_=l*r+e*c,P=l*f+e*m,d=l*g+e*_,p=l*P+e*(l*m+e*(l*s+e*h)),M=l*d+e*(l*_+e*(l*c+e*u));o.push(t.C,f,g,P,d,p,M)}},{getDerivative:p,getDistance:M}=d,{M:b,L:y,C:D,Z:x}=t,k={},F={},T={transform(t,o){let e,n=0;const a=t.length;for(;n<a;)switch(e=t[n],e){case b:case y:T.transformPoints(t,o,n,1),n+=3;break;case D:T.transformPoints(t,o,n,3),n+=7;break;case x:n+=1}},transformPoints(t,o,e,n){for(let a=e+1,r=a+2*n;a<r;a+=2)k.x=t[a],k.y=t[a+1],i.toOuterPoint(o,k),t[a]=k.x,t[a+1]=k.y},getMotionPathData(t){let o,e,a,i,r=0,s=[],c=0,h=0,u=0;const l=t.length;for(;c<l;){switch(i=t[c],i){case b:case y:e=t[c+1],a=t[c+2],o=i===y&&c>0?n.getDistanceFrom(h,u,e,a):0,h=e,u=a,c+=3;break;case D:e=t[c+5],a=t[c+6],o=d.getDistance(h,u,t[c+1],t[c+2],t[c+3],t[c+4],e,a),h=e,u=a,c+=7;break;case x:c+=1;default:o=0}s.push(o),r+=o}return{total:r,segments:s,data:t}},getDistancePoint(t,o,i){const{segments:r,data:s}=t;o=e.number(o,t.total);let c,h,u,l,f,g,m,_,P,p=0,M={},k=0,T=0,C=0,R=0;const v=s.length;for(;k<v;){switch(l=s[k],l){case b:case y:if(h=s[k+1],u=s[k+2],c=r[T],p+c>o||!t.total)return k||(C=h,R=u),F.x=C,F.y=R,M.x=h,M.y=u,n.getDistancePoint(F,M,o-p,!0),M.rotation=n.getAngle(F,M),M;C=h,R=u,k+=3;break;case D:if(h=s[k+5],u=s[k+6],c=r[T],p+c>o)return f=s[k+1],g=s[k+2],m=s[k+3],_=s[k+4],P=d.getT(o-p,c,C,R,f,g,m,_,h,u,i),a.getPointAndSet(P,C,R,f,g,m,_,h,u,M),M.rotation=d.getRotation(P,C,R,f,g,m,_,h,u),M;C=h,R=u,k+=7;break;case x:k+=1;default:c=0}T++,p+=c}return M},getDistancePath(t,o,a){const{segments:i,data:r}=t,s=[];o=e.number(o,t.total);let c,h,u,l,f,g,m,_,P,p=0,M={},k=0,T=0,C=0,R=0;const v=r.length;for(;k<v;){switch(l=r[k],l){case b:case y:if(h=r[k+1],u=r[k+2],c=i[T],p+c>o||!t.total)return k||(C=h,R=u),F.x=C,F.y=R,M.x=h,M.y=u,n.getDistancePoint(F,M,o-p,!0),s.push(l,M.x,M.y),s;C=h,R=u,k+=3,s.push(l,C,R);break;case D:if(f=r[k+1],g=r[k+2],m=r[k+3],_=r[k+4],h=r[k+5],u=r[k+6],c=i[T],p+c>o)return P=d.getT(o-p,c,C,R,f,g,m,_,h,u,a),d.cut(s,P,C,R,f,g,m,_,h,u),s;C=h,R=u,k+=7,s.push(l,f,g,m,_,h,u);break;case x:k+=1,s.push(l);default:c=0}T++,p+=c}return s}};function C(t){return r(t,(t=>s({set(o){this.__setAttr(t,o),this.__hasMotionPath=this.motionPath||!c(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}})))}h.add("motion-path"),u.register("motion",(function(t,o,n,a){return t?"object"==typeof t&&(t=e.number(t,a.getMotionTotal())):t=0,o?"object"==typeof o&&(o=e.number(o,a.getMotionTotal())):o=0,u.number(t,o,n)})),u.register("motionRotation",(function(t,o,e){return u.number(t,o,e)}));const R=l.prototype,{updateMatrix:v,updateAllMatrix:w}=f,{updateBounds:A}=g;function j(t){const{motion:o,leaferIsCreated:e}=t;if(!c(o)){if(e&&(t.leafer.created=!1),t.motionPath){const e=L(t);e.total&&(t.__.__pathForRender=T.getDistancePath(e,o,t.motionPrecision))}else t.set(t.getMotionPoint(o)),t.__hasAutoLayout||(t.isBranch?(w(t),A(t,t)):v(t));e&&(t.leafer.created=!0)}}function B(t){const{parent:o}=t;if(!t.motionPath&&o){const{children:t}=o;for(let o=0;o<t.length;o++)if(t[o].motionPath)return t[o]}return t}function L(t){const o=t.__;return o.__pathForMotion?o.__pathForMotion:o.__pathForMotion=T.getMotionPathData(t.getPath(!0,!0))}C()(R,"motionPath"),C(1)(R,"motionPrecision"),C()(R,"motion"),C(!0)(R,"motionRotation"),R.getMotionPathData=function(){return L(B(this))},R.getMotionPoint=function(t){const o=B(this),e=L(o);if(!e.total)return{};const n=T.getDistancePoint(e,t,o.motionPrecision);i.toOuterPoint(o.localTransform,n);const{motionRotation:a}=this;return!1===a?delete n.rotation:"number"==typeof a&&(n.rotation+=a),n},R.getMotionTotal=function(){return this.getMotionPathData().total},R.__updateMotionPath=function(){const t=this.__;if(this.__layout.resized&&t.__pathForMotion&&(t.__pathForMotion=void 0),this.motionPath){let t;const{children:o}=this.parent;for(let e=0;e<o.length;e++)t=o[e],c(t.motion)||t.__layout.matrixChanged||(t!==this&&t.__extraUpdate(),j(t))}else j(this)};export{d as HighBezierHelper,T as HighCurveHelper,C as motionPathType};
|
|
2
2
|
//# sourceMappingURL=motion-path.esm.min.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/motion-path",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "@leafer-in/motion-path",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@leafer-ui/draw": "^1.4.
|
|
38
|
-
"@leafer-ui/interface": "^1.4.
|
|
39
|
-
"@leafer-in/interface": "^1.4.
|
|
37
|
+
"@leafer-ui/draw": "^1.4.2",
|
|
38
|
+
"@leafer-ui/interface": "^1.4.2",
|
|
39
|
+
"@leafer-in/interface": "^1.4.2"
|
|
40
40
|
}
|
|
41
41
|
}
|