3 lines
2.8 KiB
JavaScript
3 lines
2.8 KiB
JavaScript
define("local_treestudyplan/util/svgarc",["exports"],(function(_exports){function _slicedToArray(arr,i){return function(arr){if(Array.isArray(arr))return arr}(arr)||function(arr,i){var _i=null==arr?null:"undefined"!=typeof Symbol&&arr[Symbol.iterator]||arr["@@iterator"];if(null==_i)return;var _s,_e,_arr=[],_n=!0,_d=!1;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done)&&(_arr.push(_s.value),!i||_arr.length!==i);_n=!0);}catch(err){_d=!0,_e=err}finally{try{_n||null==_i.return||_i.return()}finally{if(_d)throw _e}}return _arr}(arr,i)||function(o,minLen){if(!o)return;if("string"==typeof o)return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);"Object"===n&&o.constructor&&(n=o.constructor.name);if("Map"===n||"Set"===n)return Array.from(o);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen)}(arr,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(arr,len){(null==len||len>arr.length)&&(len=arr.length);for(var i=0,arr2=new Array(len);i<len;i++)arr2[i]=arr[i];return arr2}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.svgarcpath=_exports.svgarc=void 0;var cos=Math.cos,sin=Math.sin,π=Math.PI,f_matrix_times=function(_ref,_ref2){var _ref3=_slicedToArray(_ref,2),_ref3$=_slicedToArray(_ref3[0],2),a=_ref3$[0],b=_ref3$[1],_ref3$2=_slicedToArray(_ref3[1],2),c=_ref3$2[0],d=_ref3$2[1],_ref4=_slicedToArray(_ref2,2),x=_ref4[0],y=_ref4[1];return[a*x+b*y,c*x+d*y]},f_vec_add=function(_ref5,_ref6){var _ref7=_slicedToArray(_ref5,2),a1=_ref7[0],a2=_ref7[1],_ref8=_slicedToArray(_ref6,2);return[a1+_ref8[0],a2+_ref8[1]]},svgarcpath=function(_ref9,_ref10,_ref11,φ){var _ref12=_slicedToArray(_ref9,2),cx=_ref12[0],cy=_ref12[1],_ref13=_slicedToArray(_ref10,2),rx=_ref13[0],ry=_ref13[1],_ref14=_slicedToArray(_ref11,2),t1=_ref14[0],Δ=_ref14[1];Δ%=2*π;var x,rotMatrix=[[cos(x=φ),-sin(x)],[sin(x),cos(x)]],_f_vec_add2=_slicedToArray(f_vec_add(f_matrix_times(rotMatrix,[rx*cos(t1),ry*sin(t1)]),[cx,cy]),2),sX=_f_vec_add2[0],sY=_f_vec_add2[1],_f_vec_add4=_slicedToArray(f_vec_add(f_matrix_times(rotMatrix,[rx*cos(t1+Δ),ry*sin(t1+Δ)]),[cx,cy]),2),eX=_f_vec_add4[0],eY=_f_vec_add4[1];return"M "+sX+" "+sY+" A "+[rx,ry,φ/(2*π)*360,Δ>π?1:0,Δ>0?1:0,eX,eY].join(" ")};_exports.svgarcpath=svgarcpath;_exports.svgarc=function(_ref15,_ref16,_ref17,φ){var _ref18=_slicedToArray(_ref15,2),cx=_ref18[0],cy=_ref18[1],_ref19=_slicedToArray(_ref16,2),rx=_ref19[0],ry=_ref19[1],_ref20=_slicedToArray(_ref17,2),t1=_ref20[0],Δ=_ref20[1],path_2wk2r=document.createElementNS("http://www.w3.org/2000/svg","path"),d=svgarcpath([cx,cy],[rx,ry],[t1,Δ],φ);return path_2wk2r.setAttribute("d",d),path_2wk2r}}));
|
|
|
|
//# sourceMappingURL=svgarc.min.js.map
|