@leafer-in/motion-path 1.8.0 → 1.9.1
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.cjs +198 -186
- package/dist/motion-path.esm.js +195 -185
- package/dist/motion-path.esm.min.js +1 -1
- package/dist/motion-path.esm.min.js.map +1 -1
- package/dist/motion-path.js +174 -193
- package/dist/motion-path.min.cjs +1 -1
- package/dist/motion-path.min.cjs.map +1 -1
- package/dist/motion-path.min.js +1 -1
- package/dist/motion-path.min.js.map +1 -1
- package/package.json +4 -4
- package/src/index.ts +7 -9
package/dist/motion-path.min.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var t=require("@leafer-ui/draw");const e=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],o=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:n}=Math,{getDerivative:
|
|
1
|
+
"use strict";var t=require("@leafer-ui/draw");const e=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],o=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:n}=Math,{getDerivative:i}=t.BezierHelper,r={getDistance(t,r,a,s,c,h,u,l,g=1){let f,m,d,p,P,_,M=0,x=g/2;for(let g=0;g<e.length;g++)f=x*(1+e[g]),m=x*(1-e[g]),d=i(f,t,a,c,u),p=i(f,r,s,h,l),P=i(m,t,a,c,u),_=i(m,r,s,h,l),M+=o[g]*(n(d*d+p*p)+n(P*P+_*_));return M*x},getRotation(e,o,n,r,a,s,c,h,u){const l=i(e,o,r,s,h),g=i(e,n,a,c,u);return Math.atan2(g,l)/t.OneRadian},getT(t,e,o,n,i,r,s,c,h,u,l=1){let g=0,f=1,m=t/e,d=l/e/3;if(m>=1)return 1;if(m<=0)return 0;for(;f-g>d;)a(o,n,i,r,s,c,h,u,m)<t?g=m:f=m,m=(g+f)/2;return m},cut(e,o,n,i,r,a,s,c,h,u){const l=1-o,g=l*n+o*r,f=l*i+o*a,m=l*r+o*s,d=l*a+o*c,p=l*g+o*m,P=l*f+o*d,_=l*p+o*(l*m+o*(l*s+o*h)),M=l*P+o*(l*d+o*(l*c+o*u));e.push(t.PathCommandMap.C,g,f,p,P,_,M)}},{getDistance:a}=r,{M:s,L:c,C:h,Z:u}=t.PathCommandMap,l={},g={},f={transform(t,e){let o,n=0;const i=t.length;for(;n<i;)switch(o=t[n],o){case s:case c:f.transformPoints(t,e,n,1),n+=3;break;case h:f.transformPoints(t,e,n,3),n+=7;break;case u:n+=1}},transformPoints(e,o,n,i){for(let r=n+1,a=r+2*i;r<a;r+=2)l.x=e[r],l.y=e[r+1],t.MatrixHelper.toOuterPoint(o,l),e[r]=l.x,e[r+1]=l.y},getMotionPathData(e){let o,n,i,a,l=0,g=[],f=0,m=0,d=0;const p=e.length;for(;f<p;){switch(a=e[f],a){case s:case c:n=e[f+1],i=e[f+2],o=a===c&&f>0?t.PointHelper.getDistanceFrom(m,d,n,i):0,m=n,d=i,f+=3;break;case h:n=e[f+5],i=e[f+6],o=r.getDistance(m,d,e[f+1],e[f+2],e[f+3],e[f+4],n,i),m=n,d=i,f+=7;break;case u:f+=1;default:o=0}g.push(o),l+=o}return{total:l,segments:g,data:e}},getDistancePoint(e,o,n){const{segments:i,data:a}=e;o=t.UnitConvert.number(o,e.total);let l,f,m,d,p,P,_,M,x,b=0,D={},y=0,H=0,C=0,T=0;const v=a.length;for(;y<v;){switch(d=a[y],d){case s:case c:if(f=a[y+1],m=a[y+2],l=i[H],b+l>=o||!e.total)return y||(C=f,T=m),g.x=C,g.y=T,D.x=f,D.y=m,t.PointHelper.getDistancePoint(g,D,o-b,!0),D.rotation=t.PointHelper.getAngle(g,D),D;C=f,T=m,y+=3;break;case h:if(f=a[y+5],m=a[y+6],l=i[H],b+l>=o)return p=a[y+1],P=a[y+2],_=a[y+3],M=a[y+4],x=r.getT(o-b,l,C,T,p,P,_,M,f,m,n),t.BezierHelper.getPointAndSet(x,C,T,p,P,_,M,f,m,D),D.rotation=r.getRotation(x,C,T,p,P,_,M,f,m),D;C=f,T=m,y+=7;break;case u:y+=1;default:l=0}H++,b+=l}return D},getDistancePath(e,o,n){const{segments:i,data:a}=e,l=[];o=t.UnitConvert.number(o,e.total);let f,m,d,p,P,_,M,x,b,D=0,y={},H=0,C=0,T=0,v=0;const A=a.length;for(;H<A;){switch(p=a[H],p){case s:case c:if(m=a[H+1],d=a[H+2],f=i[C],D+f>=o||!e.total)return H||(T=m,v=d),g.x=T,g.y=v,y.x=m,y.y=d,t.PointHelper.getDistancePoint(g,y,o-D,!0),l.push(p,y.x,y.y),l;T=m,v=d,H+=3,l.push(p,T,v);break;case h:if(P=a[H+1],_=a[H+2],M=a[H+3],x=a[H+4],m=a[H+5],d=a[H+6],f=i[C],D+f>=o)return b=r.getT(o-D,f,T,v,P,_,M,x,m,d,n),r.cut(l,b,T,v,P,_,M,x,m,d),l;T=m,v=d,H+=7,l.push(p,P,_,M,x,m,d);break;case u:H+=1,l.push(p);default:f=0}C++,D+=f}return l}};function m(e){return t.decorateLeafAttr(e,e=>t.attr({set(o){this.__setAttr(e,o),this.__hasMotionPath=this.motionPath||!t.isNull(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}}))}t.Plugin.add("motion-path"),t.Transition.register("motion",function(e,o,n,i){return t.isObject(e)&&(e=t.UnitConvert.number(e,i.getMotionTotal())),t.isObject(o)&&(o=t.UnitConvert.number(o,i.getMotionTotal())),t.Transition.number(e||0,o||0,n)}),t.Transition.register("motionRotation",function(e,o,n){return t.Transition.number(e,o,n)});const d=t.UI.prototype,{updateMatrix:p,updateAllMatrix:P}=t.LeafHelper,{updateBounds:_}=t.BranchHelper;function M(e){const{motion:o,leaferIsCreated:n}=e;if(!t.isNull(o)){if(n&&(e.leafer.created=!1),e.motionPath){const t=b(e);t.total&&(e.__.__pathForRender=f.getDistancePath(t,o,e.motionPrecision))}else e.set(e.getMotionPoint(o)),e.__hasAutoLayout||(e.isBranch?(P(e),_(e,e)):p(e));n&&(e.leafer.created=!0)}}function x(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function b(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=f.getMotionPathData(t.getPath(!0,!0))}t.UI.addAttr("motionPath",void 0,m),t.UI.addAttr("motionPrecision",1,m),t.UI.addAttr("motion",void 0,m),t.UI.addAttr("motionRotation",!0,m),d.getMotionPathData=function(){return b(x(this))},d.getMotionPoint=function(e){const o=x(this),n=b(o);if(!n.total)return{};const i=f.getDistancePoint(n,e,o.motionPrecision);t.MatrixHelper.toOuterPoint(o.localTransform,i);const{motionRotation:r}=this;return!1===r?delete i.rotation:t.isNumber(r)&&(i.rotation+=r),i},d.getMotionTotal=function(){return this.getMotionPathData().total},d.__updateMotionPath=function(){const e=this.__;if(this.__layout.resized&&e.__pathForMotion&&(e.__pathForMotion=void 0),this.motionPath){let e;const{children:o}=this.parent;for(let n=0;n<o.length;n++)e=o[n],t.isNull(e.motion)||e.__layout.matrixChanged||(e!==this&&e.__extraUpdate(),M(e))}else M(this)},exports.HighBezierHelper=r,exports.HighCurveHelper=f,exports.motionPathType=m;
|
|
2
2
|
//# sourceMappingURL=motion-path.min.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion-path.min.cjs","sources":["../../../../../../src/in/packages/motion-path/src/HighBezierHelper.ts","../../../../../../src/in/packages/motion-path/src/HighCurveHelper.ts","../../../../../../src/in/packages/motion-path/src/decorator.ts","../../../../../../src/in/packages/motion-path/src/index.ts"],"sourcesContent":["import { IPathCommandData } from '@leafer-ui/interface'\nimport { BezierHelper, OneRadian, PathCommandMap } from '@leafer-ui/draw'\n\n\n// 高斯-勒让德积分节点和权重\nconst gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285]\nconst gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443]\n\nconst { sqrt } = Math\nconst { getDerivative } = BezierHelper\n\nexport const HighBezierHelper = {\n\n getDistance(fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number, t = 1): number {\n let distance = 0, t1: number, t2: number, d1X: number, d1Y: number, d2X: number, d2Y: number, half = t / 2\n for (let i = 0; i < gaussNodes.length; i++) {\n t1 = half * (1 + gaussNodes[i])\n t2 = half * (1 - gaussNodes[i])\n\n d1X = getDerivative(t1, fromX, x1, x2, toX)\n d1Y = getDerivative(t1, fromY, y1, y2, toY)\n\n d2X = getDerivative(t2, fromX, x1, x2, toX)\n d2Y = getDerivative(t2, fromY, y1, y2, toY)\n\n distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y))\n }\n return distance * half\n },\n\n getRotation(t: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number): number { // 切线角度\n const dx = getDerivative(t, fromX, x1, x2, toX)\n const dy = getDerivative(t, fromY, y1, y2, toY)\n return Math.atan2(dy, dx) / OneRadian\n },\n\n getT(distance: number, totalDistance: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number, precision = 1): number { // 弧长反解 t\n let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3\n\n if (middle >= 1) return 1\n if (middle <= 0) return 0\n\n while (high - low > realPrecision) { // 2分法快速对比\n getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle\n middle = (low + high) / 2\n }\n\n return middle\n },\n\n cut(data: IPathCommandData, t: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number) {\n const o = 1 - t\n const ax = o * fromX + t * x1, ay = o * fromY + t * y1\n const mbx = o * x1 + t * x2, mby = o * y1 + t * y2\n const mcx = o * x2 + t * toX, mcy = o * y2 + t * toY\n\n const bx = o * ax + t * mbx, by = o * ay + t * mby\n const mbcx = o * mbx + t * mcx, mbcy = o * mby + t * mcy\n\n const cx = o * bx + t * mbcx, cy = o * by + t * mbcy\n data.push(PathCommandMap.C, ax, ay, bx, by, cx, cy)\n }\n\n}\n\nconst { getDistance } = HighBezierHelper","import { IMatrixData, IPathCommandData, IMotionPathData, IRotationPointData, IPointData, IUnitData } from '@leafer-ui/interface'\nimport { BezierHelper, MatrixHelper, PathCommandMap, PointHelper, UnitConvert } from '@leafer-ui/draw'\n\nimport { HighBezierHelper } from './HighBezierHelper'\n\n\nconst { M, L, C, Z } = PathCommandMap\nconst tempPoint = {} as IPointData, tempFrom = {} as IPointData\n\nexport const HighCurveHelper = {\n\n transform(data: IPathCommandData, matrix: IMatrixData): void {\n let i: number = 0, command: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n HighCurveHelper.transformPoints(data, matrix, i, 1)\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n HighCurveHelper.transformPoints(data, matrix, i, 3)\n i += 7\n break\n case Z: //closepath()\n i += 1\n }\n }\n },\n\n transformPoints(data: IPathCommandData, matrix: IMatrixData, start: number, pointCount: number): void {\n for (let i = start + 1, end = i + pointCount * 2; i < end; i += 2) {\n tempPoint.x = data[i]\n tempPoint.y = data[i + 1]\n MatrixHelper.toOuterPoint(matrix, tempPoint)\n data[i] = tempPoint.x\n data[i + 1] = tempPoint.y\n }\n },\n\n getMotionPathData(data: IPathCommandData): IMotionPathData {\n let total = 0, distance: number, segments: number[] = []\n let i = 0, x = 0, y = 0, toX: number, toY: number, command: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = (command === L && i > 0) ? PointHelper.getDistanceFrom(x, y, toX, toY) : 0\n x = toX\n y = toY\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n toX = data[i + 5]\n toY = data[i + 6]\n distance = HighBezierHelper.getDistance(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY)\n x = toX\n y = toY\n i += 7\n break\n case Z: //closepath()\n i += 1\n default:\n distance = 0\n\n }\n\n segments.push(distance)\n total += distance\n }\n\n return { total, segments, data }\n\n },\n\n\n getDistancePoint(distanceData: IMotionPathData, motionDistance: number | IUnitData, motionPrecision?: number): IRotationPointData {\n const { segments, data } = distanceData\n motionDistance = UnitConvert.number(motionDistance, distanceData.total)\n\n let total = 0, distance: number, to = {} as IRotationPointData\n let i = 0, index = 0, x: number = 0, y: number = 0, toX: number, toY: number, command: number\n let x1: number, y1: number, x2: number, y2: number, t: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = segments[index]\n\n if (total + distance >= motionDistance || !distanceData.total) {\n if (!i) x = toX, y = toY // first M\n tempFrom.x = x\n tempFrom.y = y\n to.x = toX\n to.y = toY\n PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true)\n to.rotation = PointHelper.getAngle(tempFrom, to)\n return to\n }\n\n x = toX\n y = toY\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n toX = data[i + 5]\n toY = data[i + 6]\n distance = segments[index]\n\n if (total + distance >= motionDistance) {\n x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4]\n t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision)\n BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to)\n to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY)\n return to\n }\n\n x = toX\n y = toY\n i += 7\n break\n case Z: //closepath()\n i += 1\n default:\n distance = 0\n }\n\n index++\n total += distance\n }\n\n return to\n },\n\n getDistancePath(distanceData: IMotionPathData, motionDistance: number | IUnitData, motionPrecision?: number): IPathCommandData {\n const { segments, data } = distanceData, path: IPathCommandData = []\n motionDistance = UnitConvert.number(motionDistance, distanceData.total)\n\n let total = 0, distance: number, to = {} as IRotationPointData\n let i = 0, index = 0, x: number = 0, y: number = 0, toX: number, toY: number, command: number\n let x1: number, y1: number, x2: number, y2: number, t: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = segments[index]\n\n if (total + distance >= motionDistance || !distanceData.total) {\n if (!i) x = toX, y = toY // first M\n tempFrom.x = x\n tempFrom.y = y\n to.x = toX\n to.y = toY\n PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true)\n path.push(command, to.x, to.y)\n return path\n }\n\n x = toX\n y = toY\n i += 3\n path.push(command, x, y)\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4]\n toX = data[i + 5]\n toY = data[i + 6]\n distance = segments[index]\n\n if (total + distance >= motionDistance) {\n t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision)\n HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY)\n return path\n }\n\n x = toX\n y = toY\n i += 7\n path.push(command, x1, y1, x2, y2, toX, toY)\n break\n case Z: //closepath()\n i += 1\n path.push(command)\n default:\n distance = 0\n\n }\n\n index++\n total += distance\n }\n\n return path\n }\n\n}","import { IValue } from '@leafer-ui/interface'\nimport { decorateLeafAttr, attr, isNull } from '@leafer-ui/draw'\n\nexport function motionPathType(defaultValue?: IValue) {\n return decorateLeafAttr(defaultValue, (key: string) => attr({\n set(value: any) {\n this.__setAttr(key, value)\n this.__hasMotionPath = this.motionPath || !isNull(this.motion)\n this.__layout.matrixChanged || this.__layout.matrixChange()\n }\n }))\n}","export { HighCurveHelper } from './HighCurveHelper'\nexport { HighBezierHelper } from './HighBezierHelper'\nexport { motionPathType } from './decorator'\n\nimport { IMotionPathData, IUI, IUnitData, IRotationPointData } from '@leafer-ui/interface'\nimport { isNull, MatrixHelper, LeafHelper, BranchHelper, Transition, UI, UnitConvert, Plugin } from '@leafer-ui/draw'\n\nimport { HighCurveHelper } from './HighCurveHelper'\nimport { motionPathType } from './decorator'\n\n\nPlugin.add('motion-path')\n\n\nTransition.register('motion', function (from: any, to: any, t: number, target: IUI): number {\n if (!from) from = 0\n else if (typeof from === 'object') from = UnitConvert.number(from, target.getMotionTotal())\n if (!to) to = 0\n else if (typeof to === 'object') to = UnitConvert.number(to, target.getMotionTotal())\n return Transition.number(from, to, t)\n})\n\nTransition.register('motionRotation', function (from: any, to: any, t: number): number {\n return Transition.number(from, to, t)\n})\n\n\nconst ui = UI.prototype\nconst { updateMatrix, updateAllMatrix } = LeafHelper\nconst { updateBounds } = BranchHelper\n\n\n// addAttr\nUI.addAttr('motionPath', undefined, motionPathType)\nUI.addAttr('motionPrecision', 1, motionPathType)\n\nUI.addAttr('motion', undefined, motionPathType)\nUI.addAttr('motionRotation', true, motionPathType)\n\n\nui.getMotionPathData = function (): IMotionPathData {\n return getMotionPathData(getMotionPath(this))\n}\n\nui.getMotionPoint = function (motionDistance: number | IUnitData): IRotationPointData {\n const path = getMotionPath(this)\n const data = getMotionPathData(path)\n if (!data.total) return {} as IRotationPointData\n\n const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision)\n MatrixHelper.toOuterPoint(path.localTransform, point)\n\n const { motionRotation } = this\n if (motionRotation === false) delete point.rotation\n else if (typeof motionRotation === 'number') point.rotation += motionRotation\n return point\n}\n\nui.getMotionTotal = function (): number {\n return this.getMotionPathData().total\n}\n\nui.__updateMotionPath = function (): void {\n const data = this.__\n if (this.__layout.resized && data.__pathForMotion) data.__pathForMotion = undefined\n\n if (this.motionPath) {\n let child: IUI\n const { children } = this.parent\n for (let i = 0; i < children.length; i++) {\n child = children[i]\n if (!isNull(child.motion) && !child.__layout.matrixChanged) {\n if (child !== this) child.__extraUpdate()\n updateMotion(child)\n }\n }\n } else updateMotion(this)\n}\n\n\nfunction updateMotion(leaf: IUI): void {\n const { motion, leaferIsCreated } = leaf\n if (isNull(motion)) return\n\n if (leaferIsCreated) leaf.leafer.created = false // 拦截布局更新通知,进行手动更新布局\n\n if (leaf.motionPath) {\n\n const data = getMotionPathData(leaf)\n if (data.total) leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision) // 生长路径\n\n } else {\n\n leaf.set(leaf.getMotionPoint(motion)) // 动画路径\n\n if (!leaf.__hasAutoLayout) { // 手动更新布局\n if (leaf.isBranch) updateAllMatrix(leaf), updateBounds(leaf, leaf)\n else updateMatrix(leaf)\n }\n\n }\n\n if (leaferIsCreated) leaf.leafer.created = true\n}\n\nfunction getMotionPath(leaf: IUI): IUI {\n const { parent } = leaf\n if (!leaf.motionPath && parent) {\n const { children } = parent\n for (let i = 0; i < children.length; i++) {\n if (children[i].motionPath) return children[i]\n }\n }\n return leaf\n}\n\nfunction getMotionPathData(leaf: IUI): IMotionPathData {\n const data = leaf.__\n if (data.__pathForMotion) return data.__pathForMotion\n return data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true))\n}"],"names":["gaussNodes","gaussWeights","sqrt","Math","getDerivative","BezierHelper","HighBezierHelper","getDistance","fromX","fromY","x1","y1","x2","y2","toX","toY","t","t1","t2","d1X","d1Y","d2X","d2Y","distance","half","i","length","getRotation","dx","dy","atan2","OneRadian","getT","totalDistance","precision","low","high","middle","realPrecision","cut","data","o","ax","ay","mbx","mby","bx","by","cx","cy","push","PathCommandMap","C","M","L","Z","tempPoint","tempFrom","HighCurveHelper","transform","matrix","command","len","transformPoints","start","pointCount","end","x","y","MatrixHelper","toOuterPoint","getMotionPathData","total","segments","PointHelper","getDistanceFrom","getDistancePoint","distanceData","motionDistance","motionPrecision","UnitConvert","number","to","index","rotation","getAngle","getPointAndSet","getDistancePath","path","motionPathType","defaultValue","decorateLeafAttr","key","attr","set","value","this","__setAttr","__hasMotionPath","motionPath","isNull","motion","__layout","matrixChanged","matrixChange","Plugin","add","Transition","register","from","target","getMotionTotal","ui","UI","prototype","updateMatrix","updateAllMatrix","LeafHelper","updateBounds","BranchHelper","updateMotion","leaf","leaferIsCreated","leafer","created","__","__pathForRender","getMotionPoint","__hasAutoLayout","isBranch","getMotionPath","parent","children","__pathForMotion","getPath","addAttr","undefined","point","localTransform","motionRotation","__updateMotionPath","resized","child","__extraUpdate"],"mappings":"8CAKA,MAAMA,EAAa,CAAC,YAAc,YAAc,YAAc,YAAc,aACtEC,EAAe,CAAC,YAAc,YAAc,YAAc,YAAc,cAExEC,KAAEA,GAASC,MACXC,cAAEA,GAAkBC,EAAYA,aAEzBC,EAAmB,CAE5B,WAAAC,CAAYC,EAAeC,EAAeC,EAAYC,EAAYC,EAAYC,EAAYC,EAAaC,EAAaC,EAAI,GACpH,IAAkBC,EAAYC,EAAYC,EAAaC,EAAaC,EAAaC,EAA7EC,EAAW,EAA+EC,EAAOR,EAAI,EACzG,IAAK,IAAIS,EAAI,EAAGA,EAAIzB,EAAW0B,OAAQD,IACnCR,EAAKO,GAAQ,EAAIxB,EAAWyB,IAC5BP,EAAKM,GAAQ,EAAIxB,EAAWyB,IAE5BN,EAAMf,EAAca,EAAIT,EAAOE,EAAIE,EAAIE,GACvCM,EAAMhB,EAAca,EAAIR,EAAOE,EAAIE,EAAIE,GAEvCM,EAAMjB,EAAcc,EAAIV,EAAOE,EAAIE,EAAIE,GACvCQ,EAAMlB,EAAcc,EAAIT,EAAOE,EAAIE,EAAIE,GAEvCQ,GAAYtB,EAAawB,IAAMvB,EAAKiB,EAAMA,EAAMC,EAAMA,GAAOlB,EAAKmB,EAAMA,EAAMC,EAAMA,IAExF,OAAOC,EAAWC,CACrB,EAED,WAAAG,CAAYX,EAAWR,EAAeC,EAAeC,EAAYC,EAAYC,EAAYC,EAAYC,EAAaC,GAC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AAKmC,OAC1B,IAAK,IAAI1G,EAAI,EAAGA,EAAI2G,EAAS1G,OAAQD,IACjCqH,EAAQV,EAAS3G,GACZ2E,EAAMA,OAAC0C,EAAMzC,SAAYyC,EAAMxC,SAASC,gBACrCuC,IAAU9C,MAAM8C,EAAMC,gBAC1BvB,EAAasB,SAGlBtB,EAAaxB,KACxB"}
|
|
1
|
+
{"version":3,"file":"motion-path.min.cjs","sources":["../../../../../../src/in/packages/motion-path/src/HighBezierHelper.ts","../../../../../../src/in/packages/motion-path/src/HighCurveHelper.ts","../../../../../../src/in/packages/motion-path/src/decorator.ts","../../../../../../src/in/packages/motion-path/src/index.ts"],"sourcesContent":["import { IPathCommandData } from '@leafer-ui/interface'\nimport { BezierHelper, OneRadian, PathCommandMap } from '@leafer-ui/draw'\n\n\n// 高斯-勒让德积分节点和权重\nconst gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285]\nconst gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443]\n\nconst { sqrt } = Math\nconst { getDerivative } = BezierHelper\n\nexport const HighBezierHelper = {\n\n getDistance(fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number, t = 1): number {\n let distance = 0, t1: number, t2: number, d1X: number, d1Y: number, d2X: number, d2Y: number, half = t / 2\n for (let i = 0; i < gaussNodes.length; i++) {\n t1 = half * (1 + gaussNodes[i])\n t2 = half * (1 - gaussNodes[i])\n\n d1X = getDerivative(t1, fromX, x1, x2, toX)\n d1Y = getDerivative(t1, fromY, y1, y2, toY)\n\n d2X = getDerivative(t2, fromX, x1, x2, toX)\n d2Y = getDerivative(t2, fromY, y1, y2, toY)\n\n distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y))\n }\n return distance * half\n },\n\n getRotation(t: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number): number { // 切线角度\n const dx = getDerivative(t, fromX, x1, x2, toX)\n const dy = getDerivative(t, fromY, y1, y2, toY)\n return Math.atan2(dy, dx) / OneRadian\n },\n\n getT(distance: number, totalDistance: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number, precision = 1): number { // 弧长反解 t\n let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3\n\n if (middle >= 1) return 1\n if (middle <= 0) return 0\n\n while (high - low > realPrecision) { // 2分法快速对比\n getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle\n middle = (low + high) / 2\n }\n\n return middle\n },\n\n cut(data: IPathCommandData, t: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number) {\n const o = 1 - t\n const ax = o * fromX + t * x1, ay = o * fromY + t * y1\n const mbx = o * x1 + t * x2, mby = o * y1 + t * y2\n const mcx = o * x2 + t * toX, mcy = o * y2 + t * toY\n\n const bx = o * ax + t * mbx, by = o * ay + t * mby\n const mbcx = o * mbx + t * mcx, mbcy = o * mby + t * mcy\n\n const cx = o * bx + t * mbcx, cy = o * by + t * mbcy\n data.push(PathCommandMap.C, ax, ay, bx, by, cx, cy)\n }\n\n}\n\nconst { getDistance } = HighBezierHelper","import { IMatrixData, IPathCommandData, IMotionPathData, IRotationPointData, IPointData, IUnitData } from '@leafer-ui/interface'\nimport { BezierHelper, MatrixHelper, PathCommandMap, PointHelper, UnitConvert } from '@leafer-ui/draw'\n\nimport { HighBezierHelper } from './HighBezierHelper'\n\n\nconst { M, L, C, Z } = PathCommandMap\nconst tempPoint = {} as IPointData, tempFrom = {} as IPointData\n\nexport const HighCurveHelper = {\n\n transform(data: IPathCommandData, matrix: IMatrixData): void {\n let i: number = 0, command: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n HighCurveHelper.transformPoints(data, matrix, i, 1)\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n HighCurveHelper.transformPoints(data, matrix, i, 3)\n i += 7\n break\n case Z: //closepath()\n i += 1\n }\n }\n },\n\n transformPoints(data: IPathCommandData, matrix: IMatrixData, start: number, pointCount: number): void {\n for (let i = start + 1, end = i + pointCount * 2; i < end; i += 2) {\n tempPoint.x = data[i]\n tempPoint.y = data[i + 1]\n MatrixHelper.toOuterPoint(matrix, tempPoint)\n data[i] = tempPoint.x\n data[i + 1] = tempPoint.y\n }\n },\n\n getMotionPathData(data: IPathCommandData): IMotionPathData {\n let total = 0, distance: number, segments: number[] = []\n let i = 0, x = 0, y = 0, toX: number, toY: number, command: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = (command === L && i > 0) ? PointHelper.getDistanceFrom(x, y, toX, toY) : 0\n x = toX\n y = toY\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n toX = data[i + 5]\n toY = data[i + 6]\n distance = HighBezierHelper.getDistance(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY)\n x = toX\n y = toY\n i += 7\n break\n case Z: //closepath()\n i += 1\n default:\n distance = 0\n\n }\n\n segments.push(distance)\n total += distance\n }\n\n return { total, segments, data }\n\n },\n\n\n getDistancePoint(distanceData: IMotionPathData, motionDistance: number | IUnitData, motionPrecision?: number): IRotationPointData {\n const { segments, data } = distanceData\n motionDistance = UnitConvert.number(motionDistance, distanceData.total)\n\n let total = 0, distance: number, to = {} as IRotationPointData\n let i = 0, index = 0, x: number = 0, y: number = 0, toX: number, toY: number, command: number\n let x1: number, y1: number, x2: number, y2: number, t: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = segments[index]\n\n if (total + distance >= motionDistance || !distanceData.total) {\n if (!i) x = toX, y = toY // first M\n tempFrom.x = x\n tempFrom.y = y\n to.x = toX\n to.y = toY\n PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true)\n to.rotation = PointHelper.getAngle(tempFrom, to)\n return to\n }\n\n x = toX\n y = toY\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n toX = data[i + 5]\n toY = data[i + 6]\n distance = segments[index]\n\n if (total + distance >= motionDistance) {\n x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4]\n t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision)\n BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to)\n to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY)\n return to\n }\n\n x = toX\n y = toY\n i += 7\n break\n case Z: //closepath()\n i += 1\n default:\n distance = 0\n }\n\n index++\n total += distance\n }\n\n return to\n },\n\n getDistancePath(distanceData: IMotionPathData, motionDistance: number | IUnitData, motionPrecision?: number): IPathCommandData {\n const { segments, data } = distanceData, path: IPathCommandData = []\n motionDistance = UnitConvert.number(motionDistance, distanceData.total)\n\n let total = 0, distance: number, to = {} as IRotationPointData\n let i = 0, index = 0, x: number = 0, y: number = 0, toX: number, toY: number, command: number\n let x1: number, y1: number, x2: number, y2: number, t: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = segments[index]\n\n if (total + distance >= motionDistance || !distanceData.total) {\n if (!i) x = toX, y = toY // first M\n tempFrom.x = x\n tempFrom.y = y\n to.x = toX\n to.y = toY\n PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true)\n path.push(command, to.x, to.y)\n return path\n }\n\n x = toX\n y = toY\n i += 3\n path.push(command, x, y)\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4]\n toX = data[i + 5]\n toY = data[i + 6]\n distance = segments[index]\n\n if (total + distance >= motionDistance) {\n t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision)\n HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY)\n return path\n }\n\n x = toX\n y = toY\n i += 7\n path.push(command, x1, y1, x2, y2, toX, toY)\n break\n case Z: //closepath()\n i += 1\n path.push(command)\n default:\n distance = 0\n\n }\n\n index++\n total += distance\n }\n\n return path\n }\n\n}","import { IValue } from '@leafer-ui/interface'\nimport { decorateLeafAttr, attr, isNull } from '@leafer-ui/draw'\n\nexport function motionPathType(defaultValue?: IValue) {\n return decorateLeafAttr(defaultValue, (key: string) => attr({\n set(value: any) {\n this.__setAttr(key, value)\n this.__hasMotionPath = this.motionPath || !isNull(this.motion)\n this.__layout.matrixChanged || this.__layout.matrixChange()\n }\n }))\n}","export { HighCurveHelper } from './HighCurveHelper'\nexport { HighBezierHelper } from './HighBezierHelper'\nexport { motionPathType } from './decorator'\n\nimport { IMotionPathData, IUI, IUnitData, IRotationPointData, IPercentData } from '@leafer-ui/interface'\nimport { isNull, MatrixHelper, LeafHelper, BranchHelper, Transition, UI, UnitConvert, Plugin, isObject, isNumber } from '@leafer-ui/draw'\n\nimport { HighCurveHelper } from './HighCurveHelper'\nimport { motionPathType } from './decorator'\n\n\nPlugin.add('motion-path')\n\n\nTransition.register('motion', function (from: number | IPercentData, to: number | IPercentData, t: number, target: IUI): number {\n if (isObject(from)) from = UnitConvert.number(from, target.getMotionTotal())\n if (isObject(to)) to = UnitConvert.number(to, target.getMotionTotal())\n return Transition.number(from || 0, to || 0, t)\n})\n\nTransition.register('motionRotation', function (from: any, to: any, t: number): number {\n return Transition.number(from, to, t)\n})\n\n\nconst ui = UI.prototype\nconst { updateMatrix, updateAllMatrix } = LeafHelper\nconst { updateBounds } = BranchHelper\n\n\n// addAttr\nUI.addAttr('motionPath', undefined, motionPathType)\nUI.addAttr('motionPrecision', 1, motionPathType)\n\nUI.addAttr('motion', undefined, motionPathType)\nUI.addAttr('motionRotation', true, motionPathType)\n\n\nui.getMotionPathData = function (): IMotionPathData {\n return getMotionPathData(getMotionPath(this))\n}\n\nui.getMotionPoint = function (motionDistance: number | IUnitData): IRotationPointData {\n const path = getMotionPath(this)\n const data = getMotionPathData(path)\n if (!data.total) return {} as IRotationPointData\n\n const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision)\n MatrixHelper.toOuterPoint(path.localTransform, point)\n\n const { motionRotation } = this\n if (motionRotation === false) delete point.rotation\n else if (isNumber(motionRotation)) point.rotation += motionRotation\n return point\n}\n\nui.getMotionTotal = function (): number {\n return this.getMotionPathData().total\n}\n\nui.__updateMotionPath = function (): void {\n const data = this.__\n if (this.__layout.resized && data.__pathForMotion) data.__pathForMotion = undefined\n\n if (this.motionPath) {\n let child: IUI\n const { children } = this.parent\n for (let i = 0; i < children.length; i++) {\n child = children[i]\n if (!isNull(child.motion) && !child.__layout.matrixChanged) {\n if (child !== this) child.__extraUpdate()\n updateMotion(child)\n }\n }\n } else updateMotion(this)\n}\n\n\nfunction updateMotion(leaf: IUI): void {\n const { motion, leaferIsCreated } = leaf\n if (isNull(motion)) return\n\n if (leaferIsCreated) leaf.leafer.created = false // 拦截布局更新通知,进行手动更新布局\n\n if (leaf.motionPath) {\n\n const data = getMotionPathData(leaf)\n if (data.total) leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision) // 生长路径\n\n } else {\n\n leaf.set(leaf.getMotionPoint(motion)) // 动画路径\n\n if (!leaf.__hasAutoLayout) { // 手动更新布局\n if (leaf.isBranch) updateAllMatrix(leaf), updateBounds(leaf, leaf)\n else updateMatrix(leaf)\n }\n\n }\n\n if (leaferIsCreated) leaf.leafer.created = true\n}\n\nfunction getMotionPath(leaf: IUI): IUI {\n const { parent } = leaf\n if (!leaf.motionPath && parent) {\n const { children } = parent\n for (let i = 0; i < children.length; i++) {\n if (children[i].motionPath) return children[i]\n }\n }\n return leaf\n}\n\nfunction getMotionPathData(leaf: IUI): IMotionPathData {\n const data = leaf.__\n if (data.__pathForMotion) return data.__pathForMotion\n return data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true))\n}"],"names":["gaussNodes","gaussWeights","sqrt","Math","getDerivative","BezierHelper","HighBezierHelper","getDistance","fromX","fromY","x1","y1","x2","y2","toX","toY","t","t1","t2","d1X","d1Y","d2X","d2Y","distance","half","i","length","getRotation","dx","dy","atan2","OneRadian","getT","totalDistance","precision","low","high","middle","realPrecision","cut","data","o","ax","ay","mbx","mby","bx","by","cx","cy","push","PathCommandMap","C","M","L","Z","tempPoint","tempFrom","HighCurveHelper","transform","matrix","command","len","transformPoints","start","pointCount","end","x","y","MatrixHelper","toOuterPoint","getMotionPathData","total","segments","PointHelper","getDistanceFrom","getDistancePoint","distanceData","motionDistance","motionPrecision","UnitConvert","number","to","index","rotation","getAngle","getPointAndSet","getDistancePath","path","motionPathType","defaultValue","decorateLeafAttr","key","attr","set","value","this","__setAttr","__hasMotionPath","motionPath","isNull","motion","__layout","matrixChanged","matrixChange","Plugin","add","Transition","register","from","target","isObject","getMotionTotal","ui","UI","prototype","updateMatrix","updateAllMatrix","LeafHelper","updateBounds","BranchHelper","updateMotion","leaf","leaferIsCreated","leafer","created","__","__pathForRender","getMotionPoint","__hasAutoLayout","isBranch","getMotionPath","parent","children","__pathForMotion","getPath","addAttr","undefined","point","localTransform","motionRotation","isNumber","__updateMotionPath","resized","child","__extraUpdate"],"mappings":"8CAKA,MAAMA,EAAa,CAAC,YAAc,YAAc,YAAc,YAAc,aACtEC,EAAe,CAAC,YAAc,YAAc,YAAc,YAAc,cAExEC,KAAEA,GAASC,MACXC,cAAEA,GAAkBC,EAAAA,aAEbC,EAAmB,CAE5B,WAAAC,CAAYC,EAAeC,EAAeC,EAAYC,EAAYC,EAAYC,EAAYC,EAAaC,EAA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C,kBAAoB,WACnB,OAAOA,EAAkB4D,EAAcnC,MAC3C,EAEAiB,EAAGe,eAAiB,SAAUlD,GAC1B,MAAMU,EAAO2C,EAAcnC,MACrBxD,EAAO+B,EAAkBiB,GAC/B,IAAKhD,EAAKgC,MAAO,MAAO,CAAA,EAExB,MAAMkE,EAAQhF,EAAgBkB,iBAAiBpC,EAAMsC,EAAgBU,EAAKT,iBAC1EV,EAAAA,aAAaC,aAAakB,EAAKmD,eAAgBD,GAE/C,MAAME,eAAEA,GAAmB5C,KAG3B,OAFuB,IAAnB4C,SAAiCF,EAAMtD,SAClCyD,EAAAA,SAASD,KAAiBF,EAAMtD,UAAYwD,GAC9CF,CACX,EAEAzB,EAAGD,eAAiB,WAChB,OAAOhB,KAAKzB,oBAAoBC,KACpC,EAEAyC,EAAG6B,mBAAqB,WACpB,MAAMtG,EAAOwD,KAAK8B,GAGlB,GAFI9B,KAAKM,SAASyC,SAAWvG,EAAK8F,kBAAiB9F,EAAK8F,qBAAkBG,GAEtEzC,KAAKG,WAAY,CACjB,IAAI6C,EACJ,MAAMX,SAAEA,GAAarC,KAAKoC,OAC1B,IAAK,IAAI3G,EAAI,EAAGA,EAAI4G,EAAS3G,OAAQD,IACjCuH,EAAQX,EAAS5G,GACZ2E,EAAAA,OAAO4C,EAAM3C,SAAY2C,EAAM1C,SAASC,gBACrCyC,IAAUhD,MAAMgD,EAAMC,gBAC1BxB,EAAauB,GAGzB,MAAOvB,EAAazB,KACxB"}
|
package/dist/motion-path.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.motionPath=function(t,e){"use strict";const o=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],n=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:
|
|
1
|
+
this.LeaferIN=this.LeaferIN||{},this.LeaferIN.motionPath=function(t,e){"use strict";const o=[.1488743389,.4333953941,.6794095682,.8650633666,.9739065285],n=[.2955242247,.2692667193,.2190863625,.1494513491,.0666713443],{sqrt:i}=Math,{getDerivative:a}=e.BezierHelper,r={getDistance(t,e,r,s,c,h,u,l,f=1){let g,m,d,P,p,_,M=0,b=f/2;for(let f=0;f<o.length;f++)g=b*(1+o[f]),m=b*(1-o[f]),d=a(g,t,r,c,u),P=a(g,e,s,h,l),p=a(m,t,r,c,u),_=a(m,e,s,h,l),M+=n[f]*(i(d*d+P*P)+i(p*p+_*_));return M*b},getRotation(t,o,n,i,r,s,c,h,u){const l=a(t,o,i,s,h),f=a(t,n,r,c,u);return Math.atan2(f,l)/e.OneRadian},getT(t,e,o,n,i,a,r,c,h,u,l=1){let f=0,g=1,m=t/e,d=l/e/3;if(m>=1)return 1;if(m<=0)return 0;for(;g-f>d;)s(o,n,i,a,r,c,h,u,m)<t?f=m:g=m,m=(f+g)/2;return m},cut(t,o,n,i,a,r,s,c,h,u){const l=1-o,f=l*n+o*a,g=l*i+o*r,m=l*a+o*s,d=l*r+o*c,P=l*f+o*m,p=l*g+o*d,_=l*P+o*(l*m+o*(l*s+o*h)),M=l*p+o*(l*d+o*(l*c+o*u));t.push(e.PathCommandMap.C,f,g,P,p,_,M)}},{getDistance:s}=r,{M:c,L:h,C:u,Z:l}=e.PathCommandMap,f={},g={},m={transform(t,e){let o,n=0;const i=t.length;for(;n<i;)switch(o=t[n],o){case c:case h:m.transformPoints(t,e,n,1),n+=3;break;case u:m.transformPoints(t,e,n,3),n+=7;break;case l:n+=1}},transformPoints(t,o,n,i){for(let a=n+1,r=a+2*i;a<r;a+=2)f.x=t[a],f.y=t[a+1],e.MatrixHelper.toOuterPoint(o,f),t[a]=f.x,t[a+1]=f.y},getMotionPathData(t){let o,n,i,a,s=0,f=[],g=0,m=0,d=0;const P=t.length;for(;g<P;){switch(a=t[g],a){case c:case h:n=t[g+1],i=t[g+2],o=a===h&&g>0?e.PointHelper.getDistanceFrom(m,d,n,i):0,m=n,d=i,g+=3;break;case u:n=t[g+5],i=t[g+6],o=r.getDistance(m,d,t[g+1],t[g+2],t[g+3],t[g+4],n,i),m=n,d=i,g+=7;break;case l:g+=1;default:o=0}f.push(o),s+=o}return{total:s,segments:f,data:t}},getDistancePoint(t,o,n){const{segments:i,data:a}=t;o=e.UnitConvert.number(o,t.total);let s,f,m,d,P,p,_,M,b,x=0,D={},y=0,H=0,C=0,T=0;const U=a.length;for(;y<U;){switch(d=a[y],d){case c:case h:if(f=a[y+1],m=a[y+2],s=i[H],x+s>=o||!t.total)return y||(C=f,T=m),g.x=C,g.y=T,D.x=f,D.y=m,e.PointHelper.getDistancePoint(g,D,o-x,!0),D.rotation=e.PointHelper.getAngle(g,D),D;C=f,T=m,y+=3;break;case u:if(f=a[y+5],m=a[y+6],s=i[H],x+s>=o)return P=a[y+1],p=a[y+2],_=a[y+3],M=a[y+4],b=r.getT(o-x,s,C,T,P,p,_,M,f,m,n),e.BezierHelper.getPointAndSet(b,C,T,P,p,_,M,f,m,D),D.rotation=r.getRotation(b,C,T,P,p,_,M,f,m),D;C=f,T=m,y+=7;break;case l:y+=1;default:s=0}H++,x+=s}return D},getDistancePath(t,o,n){const{segments:i,data:a}=t,s=[];o=e.UnitConvert.number(o,t.total);let f,m,d,P,p,_,M,b,x,D=0,y={},H=0,C=0,T=0,U=0;const v=a.length;for(;H<v;){switch(P=a[H],P){case c:case h:if(m=a[H+1],d=a[H+2],f=i[C],D+f>=o||!t.total)return H||(T=m,U=d),g.x=T,g.y=U,y.x=m,y.y=d,e.PointHelper.getDistancePoint(g,y,o-D,!0),s.push(P,y.x,y.y),s;T=m,U=d,H+=3,s.push(P,T,U);break;case u:if(p=a[H+1],_=a[H+2],M=a[H+3],b=a[H+4],m=a[H+5],d=a[H+6],f=i[C],D+f>=o)return x=r.getT(o-D,f,T,U,p,_,M,b,m,d,n),r.cut(s,x,T,U,p,_,M,b,m,d),s;T=m,U=d,H+=7,s.push(P,p,_,M,b,m,d);break;case l:H+=1,s.push(P);default:f=0}C++,D+=f}return s}};function d(t){return e.decorateLeafAttr(t,t=>e.attr({set(o){this.__setAttr(t,o),this.__hasMotionPath=this.motionPath||!e.isNull(this.motion),this.__layout.matrixChanged||this.__layout.matrixChange()}}))}e.Plugin.add("motion-path"),e.Transition.register("motion",function(t,o,n,i){return e.isObject(t)&&(t=e.UnitConvert.number(t,i.getMotionTotal())),e.isObject(o)&&(o=e.UnitConvert.number(o,i.getMotionTotal())),e.Transition.number(t||0,o||0,n)}),e.Transition.register("motionRotation",function(t,o,n){return e.Transition.number(t,o,n)});const P=e.UI.prototype,{updateMatrix:p,updateAllMatrix:_}=e.LeafHelper,{updateBounds:M}=e.BranchHelper;function b(t){const{motion:o,leaferIsCreated:n}=t;if(!e.isNull(o)){if(n&&(t.leafer.created=!1),t.motionPath){const e=D(t);e.total&&(t.__.__pathForRender=m.getDistancePath(e,o,t.motionPrecision))}else t.set(t.getMotionPoint(o)),t.__hasAutoLayout||(t.isBranch?(_(t),M(t,t)):p(t));n&&(t.leafer.created=!0)}}function x(t){const{parent:e}=t;if(!t.motionPath&&e){const{children:t}=e;for(let e=0;e<t.length;e++)if(t[e].motionPath)return t[e]}return t}function D(t){const e=t.__;return e.__pathForMotion?e.__pathForMotion:e.__pathForMotion=m.getMotionPathData(t.getPath(!0,!0))}return e.UI.addAttr("motionPath",void 0,d),e.UI.addAttr("motionPrecision",1,d),e.UI.addAttr("motion",void 0,d),e.UI.addAttr("motionRotation",!0,d),P.getMotionPathData=function(){return D(x(this))},P.getMotionPoint=function(t){const o=x(this),n=D(o);if(!n.total)return{};const i=m.getDistancePoint(n,t,o.motionPrecision);e.MatrixHelper.toOuterPoint(o.localTransform,i);const{motionRotation:a}=this;return!1===a?delete i.rotation:e.isNumber(a)&&(i.rotation+=a),i},P.getMotionTotal=function(){return this.getMotionPathData().total},P.__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 n=0;n<o.length;n++)t=o[n],e.isNull(t.motion)||t.__layout.matrixChanged||(t!==this&&t.__extraUpdate(),b(t))}else b(this)},t.HighBezierHelper=r,t.HighCurveHelper=m,t.motionPathType=d,t}({},LeaferUI);
|
|
2
2
|
//# sourceMappingURL=motion-path.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"motion-path.min.js","sources":["../../../../../../src/in/packages/motion-path/src/HighBezierHelper.ts","../../../../../../src/in/packages/motion-path/src/HighCurveHelper.ts","../../../../../../src/in/packages/motion-path/src/decorator.ts","../../../../../../src/in/packages/motion-path/src/index.ts"],"sourcesContent":["import { IPathCommandData } from '@leafer-ui/interface'\nimport { BezierHelper, OneRadian, PathCommandMap } from '@leafer-ui/draw'\n\n\n// 高斯-勒让德积分节点和权重\nconst gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285]\nconst gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443]\n\nconst { sqrt } = Math\nconst { getDerivative } = BezierHelper\n\nexport const HighBezierHelper = {\n\n getDistance(fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number, t = 1): number {\n let distance = 0, t1: number, t2: number, d1X: number, d1Y: number, d2X: number, d2Y: number, half = t / 2\n for (let i = 0; i < gaussNodes.length; i++) {\n t1 = half * (1 + gaussNodes[i])\n t2 = half * (1 - gaussNodes[i])\n\n d1X = getDerivative(t1, fromX, x1, x2, toX)\n d1Y = getDerivative(t1, fromY, y1, y2, toY)\n\n d2X = getDerivative(t2, fromX, x1, x2, toX)\n d2Y = getDerivative(t2, fromY, y1, y2, toY)\n\n distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y))\n }\n return distance * half\n },\n\n getRotation(t: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number): number { // 切线角度\n const dx = getDerivative(t, fromX, x1, x2, toX)\n const dy = getDerivative(t, fromY, y1, y2, toY)\n return Math.atan2(dy, dx) / OneRadian\n },\n\n getT(distance: number, totalDistance: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number, precision = 1): number { // 弧长反解 t\n let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3\n\n if (middle >= 1) return 1\n if (middle <= 0) return 0\n\n while (high - low > realPrecision) { // 2分法快速对比\n getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle\n middle = (low + high) / 2\n }\n\n return middle\n },\n\n cut(data: IPathCommandData, t: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number) {\n const o = 1 - t\n const ax = o * fromX + t * x1, ay = o * fromY + t * y1\n const mbx = o * x1 + t * x2, mby = o * y1 + t * y2\n const mcx = o * x2 + t * toX, mcy = o * y2 + t * toY\n\n const bx = o * ax + t * mbx, by = o * ay + t * mby\n const mbcx = o * mbx + t * mcx, mbcy = o * mby + t * mcy\n\n const cx = o * bx + t * mbcx, cy = o * by + t * mbcy\n data.push(PathCommandMap.C, ax, ay, bx, by, cx, cy)\n }\n\n}\n\nconst { getDistance } = HighBezierHelper","import { IMatrixData, IPathCommandData, IMotionPathData, IRotationPointData, IPointData, IUnitData } from '@leafer-ui/interface'\nimport { BezierHelper, MatrixHelper, PathCommandMap, PointHelper, UnitConvert } from '@leafer-ui/draw'\n\nimport { HighBezierHelper } from './HighBezierHelper'\n\n\nconst { M, L, C, Z } = PathCommandMap\nconst tempPoint = {} as IPointData, tempFrom = {} as IPointData\n\nexport const HighCurveHelper = {\n\n transform(data: IPathCommandData, matrix: IMatrixData): void {\n let i: number = 0, command: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n HighCurveHelper.transformPoints(data, matrix, i, 1)\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n HighCurveHelper.transformPoints(data, matrix, i, 3)\n i += 7\n break\n case Z: //closepath()\n i += 1\n }\n }\n },\n\n transformPoints(data: IPathCommandData, matrix: IMatrixData, start: number, pointCount: number): void {\n for (let i = start + 1, end = i + pointCount * 2; i < end; i += 2) {\n tempPoint.x = data[i]\n tempPoint.y = data[i + 1]\n MatrixHelper.toOuterPoint(matrix, tempPoint)\n data[i] = tempPoint.x\n data[i + 1] = tempPoint.y\n }\n },\n\n getMotionPathData(data: IPathCommandData): IMotionPathData {\n let total = 0, distance: number, segments: number[] = []\n let i = 0, x = 0, y = 0, toX: number, toY: number, command: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = (command === L && i > 0) ? PointHelper.getDistanceFrom(x, y, toX, toY) : 0\n x = toX\n y = toY\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n toX = data[i + 5]\n toY = data[i + 6]\n distance = HighBezierHelper.getDistance(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY)\n x = toX\n y = toY\n i += 7\n break\n case Z: //closepath()\n i += 1\n default:\n distance = 0\n\n }\n\n segments.push(distance)\n total += distance\n }\n\n return { total, segments, data }\n\n },\n\n\n getDistancePoint(distanceData: IMotionPathData, motionDistance: number | IUnitData, motionPrecision?: number): IRotationPointData {\n const { segments, data } = distanceData\n motionDistance = UnitConvert.number(motionDistance, distanceData.total)\n\n let total = 0, distance: number, to = {} as IRotationPointData\n let i = 0, index = 0, x: number = 0, y: number = 0, toX: number, toY: number, command: number\n let x1: number, y1: number, x2: number, y2: number, t: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = segments[index]\n\n if (total + distance >= motionDistance || !distanceData.total) {\n if (!i) x = toX, y = toY // first M\n tempFrom.x = x\n tempFrom.y = y\n to.x = toX\n to.y = toY\n PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true)\n to.rotation = PointHelper.getAngle(tempFrom, to)\n return to\n }\n\n x = toX\n y = toY\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n toX = data[i + 5]\n toY = data[i + 6]\n distance = segments[index]\n\n if (total + distance >= motionDistance) {\n x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4]\n t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision)\n BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to)\n to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY)\n return to\n }\n\n x = toX\n y = toY\n i += 7\n break\n case Z: //closepath()\n i += 1\n default:\n distance = 0\n }\n\n index++\n total += distance\n }\n\n return to\n },\n\n getDistancePath(distanceData: IMotionPathData, motionDistance: number | IUnitData, motionPrecision?: number): IPathCommandData {\n const { segments, data } = distanceData, path: IPathCommandData = []\n motionDistance = UnitConvert.number(motionDistance, distanceData.total)\n\n let total = 0, distance: number, to = {} as IRotationPointData\n let i = 0, index = 0, x: number = 0, y: number = 0, toX: number, toY: number, command: number\n let x1: number, y1: number, x2: number, y2: number, t: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = segments[index]\n\n if (total + distance >= motionDistance || !distanceData.total) {\n if (!i) x = toX, y = toY // first M\n tempFrom.x = x\n tempFrom.y = y\n to.x = toX\n to.y = toY\n PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true)\n path.push(command, to.x, to.y)\n return path\n }\n\n x = toX\n y = toY\n i += 3\n path.push(command, x, y)\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4]\n toX = data[i + 5]\n toY = data[i + 6]\n distance = segments[index]\n\n if (total + distance >= motionDistance) {\n t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision)\n HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY)\n return path\n }\n\n x = toX\n y = toY\n i += 7\n path.push(command, x1, y1, x2, y2, toX, toY)\n break\n case Z: //closepath()\n i += 1\n path.push(command)\n default:\n distance = 0\n\n }\n\n index++\n total += distance\n }\n\n return path\n }\n\n}","import { IValue } from '@leafer-ui/interface'\nimport { decorateLeafAttr, attr, isNull } from '@leafer-ui/draw'\n\nexport function motionPathType(defaultValue?: IValue) {\n return decorateLeafAttr(defaultValue, (key: string) => attr({\n set(value: any) {\n this.__setAttr(key, value)\n this.__hasMotionPath = this.motionPath || !isNull(this.motion)\n this.__layout.matrixChanged || this.__layout.matrixChange()\n }\n }))\n}","export { HighCurveHelper } from './HighCurveHelper'\nexport { HighBezierHelper } from './HighBezierHelper'\nexport { motionPathType } from './decorator'\n\nimport { IMotionPathData, IUI, IUnitData, IRotationPointData } from '@leafer-ui/interface'\nimport { isNull, MatrixHelper, LeafHelper, BranchHelper, Transition, UI, UnitConvert, Plugin } from '@leafer-ui/draw'\n\nimport { HighCurveHelper } from './HighCurveHelper'\nimport { motionPathType } from './decorator'\n\n\nPlugin.add('motion-path')\n\n\nTransition.register('motion', function (from: any, to: any, t: number, target: IUI): number {\n if (!from) from = 0\n else if (typeof from === 'object') from = UnitConvert.number(from, target.getMotionTotal())\n if (!to) to = 0\n else if (typeof to === 'object') to = UnitConvert.number(to, target.getMotionTotal())\n return Transition.number(from, to, t)\n})\n\nTransition.register('motionRotation', function (from: any, to: any, t: number): number {\n return Transition.number(from, to, t)\n})\n\n\nconst ui = UI.prototype\nconst { updateMatrix, updateAllMatrix } = LeafHelper\nconst { updateBounds } = BranchHelper\n\n\n// addAttr\nUI.addAttr('motionPath', undefined, motionPathType)\nUI.addAttr('motionPrecision', 1, motionPathType)\n\nUI.addAttr('motion', undefined, motionPathType)\nUI.addAttr('motionRotation', true, motionPathType)\n\n\nui.getMotionPathData = function (): IMotionPathData {\n return getMotionPathData(getMotionPath(this))\n}\n\nui.getMotionPoint = function (motionDistance: number | IUnitData): IRotationPointData {\n const path = getMotionPath(this)\n const data = getMotionPathData(path)\n if (!data.total) return {} as IRotationPointData\n\n const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision)\n MatrixHelper.toOuterPoint(path.localTransform, point)\n\n const { motionRotation } = this\n if (motionRotation === false) delete point.rotation\n else if (typeof motionRotation === 'number') point.rotation += motionRotation\n return point\n}\n\nui.getMotionTotal = function (): number {\n return this.getMotionPathData().total\n}\n\nui.__updateMotionPath = function (): void {\n const data = this.__\n if (this.__layout.resized && data.__pathForMotion) data.__pathForMotion = undefined\n\n if (this.motionPath) {\n let child: IUI\n const { children } = this.parent\n for (let i = 0; i < children.length; i++) {\n child = children[i]\n if (!isNull(child.motion) && !child.__layout.matrixChanged) {\n if (child !== this) child.__extraUpdate()\n updateMotion(child)\n }\n }\n } else updateMotion(this)\n}\n\n\nfunction updateMotion(leaf: IUI): void {\n const { motion, leaferIsCreated } = leaf\n if (isNull(motion)) return\n\n if (leaferIsCreated) leaf.leafer.created = false // 拦截布局更新通知,进行手动更新布局\n\n if (leaf.motionPath) {\n\n const data = getMotionPathData(leaf)\n if (data.total) leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision) // 生长路径\n\n } else {\n\n leaf.set(leaf.getMotionPoint(motion)) // 动画路径\n\n if (!leaf.__hasAutoLayout) { // 手动更新布局\n if (leaf.isBranch) updateAllMatrix(leaf), updateBounds(leaf, leaf)\n else updateMatrix(leaf)\n }\n\n }\n\n if (leaferIsCreated) leaf.leafer.created = true\n}\n\nfunction getMotionPath(leaf: IUI): IUI {\n const { parent } = leaf\n if (!leaf.motionPath && parent) {\n const { children } = parent\n for (let i = 0; i < children.length; i++) {\n if (children[i].motionPath) return children[i]\n }\n }\n return leaf\n}\n\nfunction getMotionPathData(leaf: IUI): IMotionPathData {\n const data = leaf.__\n if (data.__pathForMotion) return data.__pathForMotion\n return data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true))\n}"],"names":["gaussNodes","gaussWeights","sqrt","Math","getDerivative","BezierHelper","HighBezierHelper","getDistance","fromX","fromY","x1","y1","x2","y2","toX","toY","t","t1","t2","d1X","d1Y","d2X","d2Y","distance","half","i","length","getRotation","dx","dy","atan2","OneRadian","getT","totalDistance","precision","low","high","middle","realPrecision","cut","data","o","ax","ay","mbx","mby","bx","by","cx","cy","push","PathCommandMap","C","M","L","Z","tempPoint","tempFrom","HighCurveHelper","transform","matrix","command","len","transformPoints","start","pointCount","end","x","y","MatrixHelper","toOuterPoint","getMotionPathData","total","segments","PointHelper","getDistanceFrom","getDistancePoint","distanceData","motionDistance","motionPrecision","UnitConvert","number","to","index","rotation","getAngle","getPointAndSet","getDistancePath","path","motionPathType","defaultValue","decorateLeafAttr","key","attr","set","value","this","__setAttr","__hasMotionPath","motionPath","isNull","motion","__layout","matrixChanged","matrixChange","Plugin","add","Transition","register","from","target","getMotionTotal","draw","ui","UI","prototype","updateMatrix","updateAllMatrix","LeafHelper","updateBounds","BranchHelper","updateMotion","leaf","leaferIsCreated","leafer","created","__","__pathForRender","getMotionPoint","__hasAutoLayout","isBranch","getMotionPath","parent","children","__pathForMotion","getPath","addAttr","undefined","point","localTransform","motionRotation","__updateMotionPath","resized","child","__extraUpdate"],"mappings":"oFAKA,MAAMA,EAAa,CAAC,YAAc,YAAc,YAAc,YAAc,aACtEC,EAAe,CAAC,YAAc,YAAc,YAAc,YAAc,cAExEC,KAAEA,GAASC,MACXC,cAAEA,GAAkBC,EAAYA,aAEzBC,EAAmB,CAE5B,WAAAC,CAAYC,EAAeC,EAAeC,EAAYC,EAAYC,EAAYC,EAAYC,EAAaC,EAAaC,EAAI,GACpH,IAAkBC,EAAYC,EAAYC,EAAaC,EAAaC,EAAaC,E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,EAAO2C,EAAcnC,MACrBxD,EAAO+B,EAAkBiB,GAC/B,IAAKhD,EAAKgC,MAAO,MAAO,CAAwB,EAEhD,MAAMkE,EAAQhF,EAAgBkB,iBAAiBpC,EAAMsC,EAAgBU,EAAKT,iBAC1EV,EAAAA,aAAaC,aAAakB,EAAKmD,eAAgBD,GAE/C,MAAME,eAAEA,GAAmB5C,KAG3B,OAFuB,IAAnB4C,SAAiCF,EAAMtD,SACR,iBAAnBwD,IAA6BF,EAAMtD,UAAYwD,GACxDF,CACX,EAEAzB,EAAGF,eAAiB,WAChB,OAAOf,KAAKzB,oBAAoBC,KACpC,EAEAyC,EAAG4B,mBAAqB,WACpB,MAAMrG,EAAOwD,KAAK8B,GAGlB,GAFI9B,KAAKM,SAASwC,SAAWtG,EAAK8F,kBAAiB9F,EAAK8F,qBAAkBG,GAEtEzC,KAAKG,WAAY,CACjB,IAAI4C,EACJ,MAAMV,SAAEA,GAAarC,KAAKoC,OAC1B,IAAK,IAAI3G,EAAI,EAAGA,EAAI4G,EAAS3G,OAAQD,IACjCsH,EAAQV,EAAS5G,GACZ2E,EAAMA,OAAC2C,EAAM1C,SAAY0C,EAAMzC,SAASC,gBACrCwC,IAAU/C,MAAM+C,EAAMC,gBAC1BvB,EAAasB,SAGlBtB,EAAazB,KACxB"}
|
|
1
|
+
{"version":3,"file":"motion-path.min.js","sources":["../../../../../../src/in/packages/motion-path/src/HighBezierHelper.ts","../../../../../../src/in/packages/motion-path/src/HighCurveHelper.ts","../../../../../../src/in/packages/motion-path/src/decorator.ts","../../../../../../src/in/packages/motion-path/src/index.ts"],"sourcesContent":["import { IPathCommandData } from '@leafer-ui/interface'\nimport { BezierHelper, OneRadian, PathCommandMap } from '@leafer-ui/draw'\n\n\n// 高斯-勒让德积分节点和权重\nconst gaussNodes = [0.1488743389, 0.4333953941, 0.6794095682, 0.8650633666, 0.9739065285]\nconst gaussWeights = [0.2955242247, 0.2692667193, 0.2190863625, 0.1494513491, 0.0666713443]\n\nconst { sqrt } = Math\nconst { getDerivative } = BezierHelper\n\nexport const HighBezierHelper = {\n\n getDistance(fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number, t = 1): number {\n let distance = 0, t1: number, t2: number, d1X: number, d1Y: number, d2X: number, d2Y: number, half = t / 2\n for (let i = 0; i < gaussNodes.length; i++) {\n t1 = half * (1 + gaussNodes[i])\n t2 = half * (1 - gaussNodes[i])\n\n d1X = getDerivative(t1, fromX, x1, x2, toX)\n d1Y = getDerivative(t1, fromY, y1, y2, toY)\n\n d2X = getDerivative(t2, fromX, x1, x2, toX)\n d2Y = getDerivative(t2, fromY, y1, y2, toY)\n\n distance += gaussWeights[i] * (sqrt(d1X * d1X + d1Y * d1Y) + sqrt(d2X * d2X + d2Y * d2Y))\n }\n return distance * half\n },\n\n getRotation(t: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number): number { // 切线角度\n const dx = getDerivative(t, fromX, x1, x2, toX)\n const dy = getDerivative(t, fromY, y1, y2, toY)\n return Math.atan2(dy, dx) / OneRadian\n },\n\n getT(distance: number, totalDistance: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number, precision = 1): number { // 弧长反解 t\n let low = 0, high = 1, middle = distance / totalDistance, realPrecision = precision / totalDistance / 3\n\n if (middle >= 1) return 1\n if (middle <= 0) return 0\n\n while (high - low > realPrecision) { // 2分法快速对比\n getDistance(fromX, fromY, x1, y1, x2, y2, toX, toY, middle) < distance ? low = middle : high = middle\n middle = (low + high) / 2\n }\n\n return middle\n },\n\n cut(data: IPathCommandData, t: number, fromX: number, fromY: number, x1: number, y1: number, x2: number, y2: number, toX: number, toY: number) {\n const o = 1 - t\n const ax = o * fromX + t * x1, ay = o * fromY + t * y1\n const mbx = o * x1 + t * x2, mby = o * y1 + t * y2\n const mcx = o * x2 + t * toX, mcy = o * y2 + t * toY\n\n const bx = o * ax + t * mbx, by = o * ay + t * mby\n const mbcx = o * mbx + t * mcx, mbcy = o * mby + t * mcy\n\n const cx = o * bx + t * mbcx, cy = o * by + t * mbcy\n data.push(PathCommandMap.C, ax, ay, bx, by, cx, cy)\n }\n\n}\n\nconst { getDistance } = HighBezierHelper","import { IMatrixData, IPathCommandData, IMotionPathData, IRotationPointData, IPointData, IUnitData } from '@leafer-ui/interface'\nimport { BezierHelper, MatrixHelper, PathCommandMap, PointHelper, UnitConvert } from '@leafer-ui/draw'\n\nimport { HighBezierHelper } from './HighBezierHelper'\n\n\nconst { M, L, C, Z } = PathCommandMap\nconst tempPoint = {} as IPointData, tempFrom = {} as IPointData\n\nexport const HighCurveHelper = {\n\n transform(data: IPathCommandData, matrix: IMatrixData): void {\n let i: number = 0, command: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n HighCurveHelper.transformPoints(data, matrix, i, 1)\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n HighCurveHelper.transformPoints(data, matrix, i, 3)\n i += 7\n break\n case Z: //closepath()\n i += 1\n }\n }\n },\n\n transformPoints(data: IPathCommandData, matrix: IMatrixData, start: number, pointCount: number): void {\n for (let i = start + 1, end = i + pointCount * 2; i < end; i += 2) {\n tempPoint.x = data[i]\n tempPoint.y = data[i + 1]\n MatrixHelper.toOuterPoint(matrix, tempPoint)\n data[i] = tempPoint.x\n data[i + 1] = tempPoint.y\n }\n },\n\n getMotionPathData(data: IPathCommandData): IMotionPathData {\n let total = 0, distance: number, segments: number[] = []\n let i = 0, x = 0, y = 0, toX: number, toY: number, command: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = (command === L && i > 0) ? PointHelper.getDistanceFrom(x, y, toX, toY) : 0\n x = toX\n y = toY\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n toX = data[i + 5]\n toY = data[i + 6]\n distance = HighBezierHelper.getDistance(x, y, data[i + 1], data[i + 2], data[i + 3], data[i + 4], toX, toY)\n x = toX\n y = toY\n i += 7\n break\n case Z: //closepath()\n i += 1\n default:\n distance = 0\n\n }\n\n segments.push(distance)\n total += distance\n }\n\n return { total, segments, data }\n\n },\n\n\n getDistancePoint(distanceData: IMotionPathData, motionDistance: number | IUnitData, motionPrecision?: number): IRotationPointData {\n const { segments, data } = distanceData\n motionDistance = UnitConvert.number(motionDistance, distanceData.total)\n\n let total = 0, distance: number, to = {} as IRotationPointData\n let i = 0, index = 0, x: number = 0, y: number = 0, toX: number, toY: number, command: number\n let x1: number, y1: number, x2: number, y2: number, t: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = segments[index]\n\n if (total + distance >= motionDistance || !distanceData.total) {\n if (!i) x = toX, y = toY // first M\n tempFrom.x = x\n tempFrom.y = y\n to.x = toX\n to.y = toY\n PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true)\n to.rotation = PointHelper.getAngle(tempFrom, to)\n return to\n }\n\n x = toX\n y = toY\n i += 3\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n toX = data[i + 5]\n toY = data[i + 6]\n distance = segments[index]\n\n if (total + distance >= motionDistance) {\n x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4]\n t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision)\n BezierHelper.getPointAndSet(t, x, y, x1, y1, x2, y2, toX, toY, to)\n to.rotation = HighBezierHelper.getRotation(t, x, y, x1, y1, x2, y2, toX, toY)\n return to\n }\n\n x = toX\n y = toY\n i += 7\n break\n case Z: //closepath()\n i += 1\n default:\n distance = 0\n }\n\n index++\n total += distance\n }\n\n return to\n },\n\n getDistancePath(distanceData: IMotionPathData, motionDistance: number | IUnitData, motionPrecision?: number): IPathCommandData {\n const { segments, data } = distanceData, path: IPathCommandData = []\n motionDistance = UnitConvert.number(motionDistance, distanceData.total)\n\n let total = 0, distance: number, to = {} as IRotationPointData\n let i = 0, index = 0, x: number = 0, y: number = 0, toX: number, toY: number, command: number\n let x1: number, y1: number, x2: number, y2: number, t: number\n\n const len = data.length\n while (i < len) {\n command = data[i]\n switch (command) {\n case M: //moveto(x, y)\n case L: //lineto(x, y)\n toX = data[i + 1]\n toY = data[i + 2]\n distance = segments[index]\n\n if (total + distance >= motionDistance || !distanceData.total) {\n if (!i) x = toX, y = toY // first M\n tempFrom.x = x\n tempFrom.y = y\n to.x = toX\n to.y = toY\n PointHelper.getDistancePoint(tempFrom, to, motionDistance - total, true)\n path.push(command, to.x, to.y)\n return path\n }\n\n x = toX\n y = toY\n i += 3\n path.push(command, x, y)\n break\n case C: //bezierCurveTo(x1, y1, x2, y2, x,y)\n x1 = data[i + 1], y1 = data[i + 2], x2 = data[i + 3], y2 = data[i + 4]\n toX = data[i + 5]\n toY = data[i + 6]\n distance = segments[index]\n\n if (total + distance >= motionDistance) {\n t = HighBezierHelper.getT(motionDistance - total, distance, x, y, x1, y1, x2, y2, toX, toY, motionPrecision)\n HighBezierHelper.cut(path, t, x, y, x1, y1, x2, y2, toX, toY)\n return path\n }\n\n x = toX\n y = toY\n i += 7\n path.push(command, x1, y1, x2, y2, toX, toY)\n break\n case Z: //closepath()\n i += 1\n path.push(command)\n default:\n distance = 0\n\n }\n\n index++\n total += distance\n }\n\n return path\n }\n\n}","import { IValue } from '@leafer-ui/interface'\nimport { decorateLeafAttr, attr, isNull } from '@leafer-ui/draw'\n\nexport function motionPathType(defaultValue?: IValue) {\n return decorateLeafAttr(defaultValue, (key: string) => attr({\n set(value: any) {\n this.__setAttr(key, value)\n this.__hasMotionPath = this.motionPath || !isNull(this.motion)\n this.__layout.matrixChanged || this.__layout.matrixChange()\n }\n }))\n}","export { HighCurveHelper } from './HighCurveHelper'\nexport { HighBezierHelper } from './HighBezierHelper'\nexport { motionPathType } from './decorator'\n\nimport { IMotionPathData, IUI, IUnitData, IRotationPointData, IPercentData } from '@leafer-ui/interface'\nimport { isNull, MatrixHelper, LeafHelper, BranchHelper, Transition, UI, UnitConvert, Plugin, isObject, isNumber } from '@leafer-ui/draw'\n\nimport { HighCurveHelper } from './HighCurveHelper'\nimport { motionPathType } from './decorator'\n\n\nPlugin.add('motion-path')\n\n\nTransition.register('motion', function (from: number | IPercentData, to: number | IPercentData, t: number, target: IUI): number {\n if (isObject(from)) from = UnitConvert.number(from, target.getMotionTotal())\n if (isObject(to)) to = UnitConvert.number(to, target.getMotionTotal())\n return Transition.number(from || 0, to || 0, t)\n})\n\nTransition.register('motionRotation', function (from: any, to: any, t: number): number {\n return Transition.number(from, to, t)\n})\n\n\nconst ui = UI.prototype\nconst { updateMatrix, updateAllMatrix } = LeafHelper\nconst { updateBounds } = BranchHelper\n\n\n// addAttr\nUI.addAttr('motionPath', undefined, motionPathType)\nUI.addAttr('motionPrecision', 1, motionPathType)\n\nUI.addAttr('motion', undefined, motionPathType)\nUI.addAttr('motionRotation', true, motionPathType)\n\n\nui.getMotionPathData = function (): IMotionPathData {\n return getMotionPathData(getMotionPath(this))\n}\n\nui.getMotionPoint = function (motionDistance: number | IUnitData): IRotationPointData {\n const path = getMotionPath(this)\n const data = getMotionPathData(path)\n if (!data.total) return {} as IRotationPointData\n\n const point = HighCurveHelper.getDistancePoint(data, motionDistance, path.motionPrecision)\n MatrixHelper.toOuterPoint(path.localTransform, point)\n\n const { motionRotation } = this\n if (motionRotation === false) delete point.rotation\n else if (isNumber(motionRotation)) point.rotation += motionRotation\n return point\n}\n\nui.getMotionTotal = function (): number {\n return this.getMotionPathData().total\n}\n\nui.__updateMotionPath = function (): void {\n const data = this.__\n if (this.__layout.resized && data.__pathForMotion) data.__pathForMotion = undefined\n\n if (this.motionPath) {\n let child: IUI\n const { children } = this.parent\n for (let i = 0; i < children.length; i++) {\n child = children[i]\n if (!isNull(child.motion) && !child.__layout.matrixChanged) {\n if (child !== this) child.__extraUpdate()\n updateMotion(child)\n }\n }\n } else updateMotion(this)\n}\n\n\nfunction updateMotion(leaf: IUI): void {\n const { motion, leaferIsCreated } = leaf\n if (isNull(motion)) return\n\n if (leaferIsCreated) leaf.leafer.created = false // 拦截布局更新通知,进行手动更新布局\n\n if (leaf.motionPath) {\n\n const data = getMotionPathData(leaf)\n if (data.total) leaf.__.__pathForRender = HighCurveHelper.getDistancePath(data, motion, leaf.motionPrecision) // 生长路径\n\n } else {\n\n leaf.set(leaf.getMotionPoint(motion)) // 动画路径\n\n if (!leaf.__hasAutoLayout) { // 手动更新布局\n if (leaf.isBranch) updateAllMatrix(leaf), updateBounds(leaf, leaf)\n else updateMatrix(leaf)\n }\n\n }\n\n if (leaferIsCreated) leaf.leafer.created = true\n}\n\nfunction getMotionPath(leaf: IUI): IUI {\n const { parent } = leaf\n if (!leaf.motionPath && parent) {\n const { children } = parent\n for (let i = 0; i < children.length; i++) {\n if (children[i].motionPath) return children[i]\n }\n }\n return leaf\n}\n\nfunction getMotionPathData(leaf: IUI): IMotionPathData {\n const data = leaf.__\n if (data.__pathForMotion) return data.__pathForMotion\n return data.__pathForMotion = HighCurveHelper.getMotionPathData(leaf.getPath(true, true))\n}"],"names":["gaussNodes","gaussWeights","sqrt","Math","getDerivative","BezierHelper","HighBezierHelper","getDistance","fromX","fromY","x1","y1","x2","y2","toX","toY","t","t1","t2","d1X","d1Y","d2X","d2Y","distance","half","i","length","getRotation","dx","dy","atan2","OneRadian","getT","totalDistance","precision","low","high","middle","realPrecision","cut","data","o","ax","ay","mbx","mby","bx","by","cx","cy","push","PathCommandMap","C","M","L","Z","tempPoint","tempFrom","HighCurveHelper","transform","matrix","command","len","transformPoints","start","pointCount","end","x","y","MatrixHelper","toOuterPoint","getMotionPathData","total","segments","PointHelper","getDistanceFrom","getDistancePoint","distanceData","motionDistance","motionPrecision","UnitConvert","number","to","index","rotation","getAngle","getPointAndSet","getDistancePath","path","motionPathType","defaultValue","decorateLeafAttr","key","attr","set","value","this","__setAttr","__hasMotionPath","motionPath","isNull","motion","__layout","matrixChanged","matrixChange","Plugin","add","Transition","register","from","target","isObject","getMotionTotal","ui","UI","prototype","updateMatrix","updateAllMatrix","LeafHelper","updateBounds","BranchHelper","updateMotion","leaf","leaferIsCreated","leafer","created","__","__pathForRender","getMotionPoint","__hasAutoLayout","isBranch","getMotionPath","parent","children","__pathForMotion","getPath","addAttr","undefined","point","localTransform","motionRotation","isNumber","__updateMotionPath","resized","child","__extraUpdate"],"mappings":"oFAKA,MAAMA,EAAa,CAAC,YAAc,YAAc,YAAc,YAAc,aACtEC,EAAe,CAAC,YAAc,YAAc,YAAc,YAAc,cAExEC,KAAEA,GAASC,MACXC,cAAEA,GAAkBC,EAAAA,aAEbC,EAAmB,CAE5B,WAAAC,CAAYC,EAAeC,EAAeC,EAAYC,EAAYC,EAAYC,EAAYC,EAAaC,EAAaC,EAAI,GACpH,IAAkBC,EAAYC,EAAYC,EAAaC,EAAaC,EAAaC,EAA7EC,EAAW,EAA+EC,EAAOR,EAAI,EACzG,IAAK,IAAIS,EAAI,EAAGA,EAAIzB,EAAW0B,OAAQD,IACnCR,EAAKO,GAAQ,EAAIxB,EAAWyB,IAC5BP,EAAKM,GAAQ,EAAIxB,EAAWyB,IAE5BN,EAAMf,EAAca,EAAIT,EAAOE,EAAIE,EAAIE,GACvCM,EAAMhB,EAAca,EAAIR,EAAOE,EAAIE,EAAIE,GAEvCM,EAAMjB,EAAcc,EAAIV,EAAOE,EAAIE,EAAIE,GACvCQ,EAAMlB,EAAcc,EAAIT,EAAOE,EAAIE,EAAIE,GAEvCQ,GAAYtB,EAAawB,IAAMvB,EAAKiB,EAAMA,EAAMC,EAAMA,GAAOlB,EAAKmB,EAAMA,EAAMC,EAAMA,IAExF,OAAOC,EAAWC,CACtB,EAEA,WAAAG,CAAYX,EAAWR,EAAeC,EAAeC,EAAYC,EAAYC,EAAYC,EAAYC,EAAaC,GAC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,IAAI6C,EACJ,MAAMX,SAAEA,GAAarC,KAAKoC,OAC1B,IAAK,IAAI3G,EAAI,EAAGA,EAAI4G,EAAS3G,OAAQD,IACjCuH,EAAQX,EAAS5G,GACZ2E,EAAAA,OAAO4C,EAAM3C,SAAY2C,EAAM1C,SAASC,gBACrCyC,IAAUhD,MAAMgD,EAAMC,gBAC1BxB,EAAauB,GAGzB,MAAOvB,EAAazB,KACxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/motion-path",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.1",
|
|
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.
|
|
38
|
-
"@leafer-ui/interface": "^1.
|
|
39
|
-
"@leafer-in/interface": "^1.
|
|
37
|
+
"@leafer-ui/draw": "^1.9.1",
|
|
38
|
+
"@leafer-ui/interface": "^1.9.1",
|
|
39
|
+
"@leafer-in/interface": "^1.9.1"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -2,8 +2,8 @@ export { HighCurveHelper } from './HighCurveHelper'
|
|
|
2
2
|
export { HighBezierHelper } from './HighBezierHelper'
|
|
3
3
|
export { motionPathType } from './decorator'
|
|
4
4
|
|
|
5
|
-
import { IMotionPathData, IUI, IUnitData, IRotationPointData } from '@leafer-ui/interface'
|
|
6
|
-
import { isNull, MatrixHelper, LeafHelper, BranchHelper, Transition, UI, UnitConvert, Plugin } from '@leafer-ui/draw'
|
|
5
|
+
import { IMotionPathData, IUI, IUnitData, IRotationPointData, IPercentData } from '@leafer-ui/interface'
|
|
6
|
+
import { isNull, MatrixHelper, LeafHelper, BranchHelper, Transition, UI, UnitConvert, Plugin, isObject, isNumber } from '@leafer-ui/draw'
|
|
7
7
|
|
|
8
8
|
import { HighCurveHelper } from './HighCurveHelper'
|
|
9
9
|
import { motionPathType } from './decorator'
|
|
@@ -12,12 +12,10 @@ import { motionPathType } from './decorator'
|
|
|
12
12
|
Plugin.add('motion-path')
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
Transition.register('motion', function (from:
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
else if (typeof to === 'object') to = UnitConvert.number(to, target.getMotionTotal())
|
|
20
|
-
return Transition.number(from, to, t)
|
|
15
|
+
Transition.register('motion', function (from: number | IPercentData, to: number | IPercentData, t: number, target: IUI): number {
|
|
16
|
+
if (isObject(from)) from = UnitConvert.number(from, target.getMotionTotal())
|
|
17
|
+
if (isObject(to)) to = UnitConvert.number(to, target.getMotionTotal())
|
|
18
|
+
return Transition.number(from || 0, to || 0, t)
|
|
21
19
|
})
|
|
22
20
|
|
|
23
21
|
Transition.register('motionRotation', function (from: any, to: any, t: number): number {
|
|
@@ -52,7 +50,7 @@ ui.getMotionPoint = function (motionDistance: number | IUnitData): IRotationPoin
|
|
|
52
50
|
|
|
53
51
|
const { motionRotation } = this
|
|
54
52
|
if (motionRotation === false) delete point.rotation
|
|
55
|
-
else if (
|
|
53
|
+
else if (isNumber(motionRotation)) point.rotation += motionRotation
|
|
56
54
|
return point
|
|
57
55
|
}
|
|
58
56
|
|