import{_ as M,o as r,c as d,f as g,F as f,h as w,K as u,t as I}from"./index.699f1124.js";const v={name:"cloudWork",props:{width:{type:Number,default:129},height:{type:Number,default:129},data:{type:Array,default:()=>[{name:"\u6D4B\u8BD5\u4E00\u7C7B",value:30},{name:"\u6D4B\u8BD5\u4E8C\u7C7B",value:30},{name:"\u6D4B\u8BD5\u4E09\u7C7B",value:30},{name:"\u6D4B\u8BD5\u56DB\u7C7B",value:30}]}},data:()=>({color:["#0054FF","#B9B9B9","#D1AF07","#E27914","#CB4A4D","#B02690"],contentEle:[],direction:"-1",speed:400,animateID:null}),created(){this.contentEle=this.data.map(()=>({x:0,y:0,z:0,style:{}}))},mounted(){this.innit()},methods:{innit(){const s=(this.width-50)/2,n=(this.height-50)/2;this.contentEle=[];for(let a=0;a<this.data.length;a+=1){const t=-1+(2*(a+1)-1)/this.data.length,o=Math.acos(t),e=o*Math.sqrt(this.data.length*Math.PI),i=s*Math.sin(o)*Math.cos(e),c=n*Math.sin(o)*Math.sin(e),h=s*Math.cos(o),l={x:i,y:c,z:h,style:{}};this.contentEle.push(l)}this.animate()},animate(){this.rotateX(),this.rotateY(),this.move(),this.animateID=window.requestAnimationFrame(this.animate)},rotateX(){const s=["-1","1"].includes(this.direction)?Math.PI/(1/0):Math.PI/(Number(this.direction)/2*Number(this.speed)),n=Math.cos(s),a=Math.sin(s);this.contentEle=this.contentEle.map(t=>{const o=t.y*n-t.z*a,e=t.z*n+t.y*a;return{...t,y:o,z:e}})},rotateY(){const s=["-2","2"].includes(this.direction)?Math.PI/(1/0):Math.PI/(Number(this.direction)*Number(this.speed)),n=Math.cos(s),a=Math.sin(s);this.contentEle=this.contentEle.map(t=>{const o=t.x*n-t.z*a,e=t.z*n+t.x*a;return{...t,x:o,z:e}})},move(){const s=this.width/2,n=this.height/2;this.contentEle=this.contentEle.map(a=>{const{x:t,y:o,z:e}=a,i=500,c=(this.width-50)/2,h=i/(i-e),l=(e+c)/(2*c),m=`${t+s-15}px`,p=`${o+n-15}px`,y=`translate(${m}, ${p}) scale(${h})`,_={...a.style,opacity:l+.5,zIndex:parseInt(h*100,10),transform:y};return{x:t,y:o,z:e,style:_}})},stop(){window.cancelAnimationFrame(this.animateID)},start(){this.animate()}}},z={class:"wordcloud"},E=["title"];function x(s,n,a,t,o,e){return r(),d("div",z,[g("div",{class:"wordCloud__tagBall",style:u({width:`${this.width}px`,height:`${this.height}px`}),onMouseenter:n[0]||(n[0]=(...i)=>e.stop&&e.stop(...i)),onMouseleave:n[1]||(n[1]=(...i)=>e.start&&e.start(...i))},[(r(!0),d(f,null,w(a.data,(i,c)=>(r(),d("span",{class:"wordCloud__tag",key:c,style:u({color:s.color[c%s.color.length],...s.contentEle[c].style}),title:i.name+i.value},I(i.name),13,E))),128))],36)])}var D=M(v,[["render",x],["__scopeId","data-v-15ef63c1"]]);export{D as w};
