document.myui_common = { //进度-假进度-以进度先执行,结果回调 processBade:function(canvasId,store,callback){ var pro = 0; var myrun = function(){ if(pro>100){ callback(pro); return; }else{ //设置中间进度数 var process_center = store[canvasId].process_center; process_center.style.text = pro+'%'; pro++; setTimeout(myrun,0) } } myrun(); }, //解析三维数组 poi指定方向 getPackList:function(g3_point,splitIndex,poi){ var self = this; var arry = self.getGpoint(g3_point,splitIndex,poi); var arrli = new Array(); for(var i=0;i<arry.length;i++){ var temp_arry = arry[i]; for(var j=0;j<temp_arry.length;j++){ arrli.push(temp_arry[j]); } } return arrli; }, //拐点遍历 getGpoint:function(g3_point,splitIndex,poi){ var self = this; var start = 0; var end = 1; var allList = new Array(); var run = function(g3_point,splitIndex,start,end){ if(end>=g3_point.length){ return; } var tempLi = [g3_point[start],g3_point[end]] var arry = self.splitLine(tempLi,splitIndex,poi); allList.push(arry); run(g3_point,splitIndex,start+1,end+1); } run(g3_point,splitIndex,start,end); return allList; }, //细分坐标,两个点细分出多个点 splitLine:function(g3_point,splitIndex,poi){ var slist = new Array(); var x1 = g3_point[0][0]; var y1 = g3_point[0][1]; var x2 = g3_point[1][0]; var y2 = g3_point[1][1]; if(x2==x1){ var distance = parseFloat((Math.abs(y2-y1)/10).toFixed(2)); for(var i=0;i<splitIndex;i++){ var x3 = x1; var y3 = i*distance+y1; var temp = new Array(); temp.push(x3); temp.push(y3); slist.push(temp); } return slist; }else{ if(poi=='right'){ var k = ((y2-y1)/(x2-x1)).toFixed(2); for(var i=0;i<splitIndex;i++){ var x3 = parseFloat((Math.abs(x2-x1)*((i+1)/splitIndex)).toFixed(2))+x1;//等分 var y3 = Math.abs(x3-x1)*k+y1; var temp = new Array(); temp.push(x3); temp.push(y3); slist.push(temp); } return slist; }else if(poi=='left'){ var k = ((y2-y1)/(x2-x1)).toFixed(2); for(var i=0;i<splitIndex;i++){ var x3 = x1-parseFloat((Math.abs(x1-x2)*(i/splitIndex)).toFixed(2));//等分 var y3 = Math.abs(x3-x1)*k+y1; var temp = new Array(); temp.push(x3); temp.push(y3); slist.push(temp); } return slist; } } } }