码迷,mamicode.com
首页 > 其他好文 > 详细

图形数据处理(原创)

时间:2017-04-29 17:27:11      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:llb   执行   blog   math   timeout   ext   原创   float   function   

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;
            }
            
        }
        
    }
}

 

图形数据处理(原创)

标签:llb   执行   blog   math   timeout   ext   原创   float   function   

原文地址:http://www.cnblogs.com/SATinnovation/p/6785534.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!