fabric
Version:
Object model for HTML5 canvas, and SVG-to-canvas parser. Backed by jsdom and node-canvas.
3 lines (2 loc) • 2.13 kB
JavaScript
import{iMatrix as t}from"../../constants.min.mjs";import{Point as n}from"../../Point.min.mjs";import{cos as e}from"./cos.min.mjs";import{radiansToDegrees as r,degreesToRadians as o}from"./radiansDegreesConversion.min.mjs";import{sin as s}from"./sin.min.mjs";const a=n=>n.every(((n,e)=>n===t[e])),i=(t,e,r)=>new n(t).transform(e,r),l=t=>{const e=1/(t[0]*t[3]-t[1]*t[2]),r=[e*t[3],-e*t[1],-e*t[2],e*t[0],0,0],{x:o,y:s}=new n(t[4],t[5]).transform(r,!0);return r[4]=-o,r[5]=-s,r},m=(t,n,e)=>[t[0]*n[0]+t[2]*n[1],t[1]*n[0]+t[3]*n[1],t[0]*n[2]+t[2]*n[3],t[1]*n[2]+t[3]*n[3],e?0:t[0]*n[4]+t[2]*n[5]+t[4],e?0:t[1]*n[4]+t[3]*n[5]+t[5]],c=(n,e)=>n.reduceRight(((t,n)=>n&&t?m(n,t,e):n||t),void 0)||t.concat(),f=t=>{let[n,e]=t;return Math.atan2(e,n)},u=t=>{const n=f(t),e=Math.pow(t[0],2)+Math.pow(t[1],2),o=Math.sqrt(e),s=(t[0]*t[3]-t[2]*t[1])/o,a=Math.atan2(t[0]*t[2]+t[1]*t[3],e);return{angle:r(n),scaleX:o,scaleY:s,skewX:r(a),skewY:0,translateX:t[4]||0,translateY:t[5]||0}},h=function(t){return[1,0,0,1,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0]};function g(){let{angle:t=0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{x:n=0,y:r=0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const a=o(t),i=e(a),l=s(a);return[i,l,-l,i,n?n-(i*n-l*r):0,r?r-(l*n+i*r):0]}const p=function(t){return[t,0,0,arguments.length>1&&void 0!==arguments[1]?arguments[1]:t,0,0]},w=t=>Math.tan(o(t)),d=t=>[1,0,w(t),1,0,0],v=t=>[1,w(t),0,1,0,0],X=t=>{let{scaleX:n=1,scaleY:e=1,flipX:r=!1,flipY:o=!1,skewX:s=0,skewY:a=0}=t,i=p(r?-n:n,o?-e:e);return s&&(i=m(i,d(s),!0)),a&&(i=m(i,v(a),!0)),i},Y=t=>{const{translateX:n=0,translateY:e=0,angle:r=0}=t;let o=h(n,e);r&&(o=m(o,g({angle:r})));const s=X(t);return a(s)||(o=m(o,s)),o};export{w as angleToSkew,X as calcDimensionsMatrix,f as calcPlaneRotation,Y as composeMatrix,g as createRotateMatrix,p as createScaleMatrix,d as createSkewXMatrix,v as createSkewYMatrix,h as createTranslateMatrix,l as invertTransform,a as isIdentityMatrix,m as multiplyTransformMatrices,c as multiplyTransformMatrixArray,u as qrDecompose,i as transformPoint};
//# sourceMappingURL=matrix.min.mjs.map