弧度测试

This commit is contained in:
郑浩乐 2016-01-04 08:14:34 +08:00
parent b317efb37a
commit bd030944c1

144
index.js
View File

@ -112,50 +112,106 @@
y:15, y:15,
data:map_data, data:map_data,
draw:function(context){ draw:function(context){
var x_length = this.data[0].length; context.strokeStyle='#f00';
var y_length = this.data.length; context.beginPath();
for(var i=0; i<x_length; i++){ context.moveTo(15,15);
for(var j=0; j<y_length; j++){ context.lineTo(15,15-this.size/2);
context.lineWidth = 2; context.stroke();
context.strokeStyle="#09c"; context.closePath();
if(this.get(j,i)){ context.beginPath();
var x = this.x+i*this.size; context.moveTo(15,15);
var y = this.y+j*this.size; context.lineTo(15,15+this.size/2);
if(this.get(j,i-1)&&!(this.get(j-1,i-1)&&this.get(j+1,i-1)&&this.get(j-1,i)&&this.get(j+1,i))){ context.stroke();
if(i){ context.closePath();
context.beginPath(); // var x_length = this.data[0].length;
context.moveTo(x,y); // var y_length = this.data.length;
context.lineTo(x-this.size/2,y); // for(var i=0; i<x_length; i++){
context.stroke(); // for(var j=0; j<y_length; j++){
} // context.lineWidth = 2;
} // context.strokeStyle="#09c";
if(this.get(j,i+1)&&!(this.get(j-1,i+1)&&this.get(j+1,i+1)&&this.get(j-1,i)&&this.get(j+1,i))){ // if(this.get(j,i)){
if(i<x_length-1){ // var x = this.x+i*this.size;
context.beginPath(); // var y = this.y+j*this.size;
context.moveTo(x,y); // var code = 0;
context.lineTo(x+this.size/2,y); // if(this.get(j-1,i)&&!(this.get(j-1,i-1)&&this.get(j-1,i+1)&&this.get(j,i-1)&&this.get(j,i+1))){
context.stroke(); // if(j){
} // code += 1000;
} // }
if(this.get(j-1,i)&&!(this.get(j-1,i-1)&&this.get(j-1,i+1)&&this.get(j,i-1)&&this.get(j,i+1))){ // }
if(j){ // if(this.get(j,i+1)&&!(this.get(j-1,i+1)&&this.get(j+1,i+1)&&this.get(j-1,i)&&this.get(j+1,i))){
context.beginPath(); // if(i<x_length-1){
context.moveTo(x,y); // code += 100;
context.lineTo(x,y-this.size/2); // }
context.stroke(); // }
} // if(this.get(j+1,i)&&!(this.get(j+1,i-1)&&this.get(j+1,i+1)&&this.get(j,i-1)&&this.get(j,i+1))){
} // if(j<y_length-1){
if(this.get(j+1,i)&&!(this.get(j+1,i-1)&&this.get(j+1,i+1)&&this.get(j,i-1)&&this.get(j,i+1))){ // code += 10;
if(j<y_length-1){ // }
context.beginPath(); // }
context.moveTo(x,y); // if(this.get(j,i-1)&&!(this.get(j-1,i-1)&&this.get(j+1,i-1)&&this.get(j-1,i)&&this.get(j+1,i))){
context.lineTo(x,y+this.size/2); // if(i){
context.stroke(); // code += 1;
} // }
} // }
} // if(code){
} // context.beginPath();
} // switch(code){
// case 1100:
// context.arc(x+this.size,y-this.size,this.size/2,.5*Math.PI,1*Math.PI,false);
// context.stroke();
// context.closePath();
// break;
// case 110:
// context.arc(x+this.size,y+this.size,this.size/2,Math.PI,1.5*Math.PI,false);
// context.stroke();
// context.closePath();
// break;
// case 11:
// context.arc(x-this.size,y+this.size,this.size/2,1.5*Math.PI,2*Math.PI,false);
// context.stroke();
// context.closePath();
// break;
// case 1001:
// context.arc(x-this.size,y-this.size,this.size/2,0,.5*Math.PI,false);
// context.stroke();
// context.closePath();
// break;
// default:
// if(code/1000){
// context.moveTo(x,y);
// context.lineTo(x,y-this.size);
// context.stroke();
// context.closePath();
// context.beginPath();
// }
// code %= 1000;
// if(code/100){
// context.moveTo(x,y);
// context.lineTo(x+this.size,y);
// context.stroke();
// context.closePath();
// context.beginPath();
// }
// code %= 100;
// if(code/10){
// context.moveTo(x,y);
// context.lineTo(x,y+this.size);
// context.stroke();
// context.closePath();
// context.beginPath();
// }
// code %= 10;
// if(code/1){
// context.moveTo(x,y);
// context.lineTo(x-this.size,y);
// context.stroke();
// }
// context.closePath();
// }
// }
// }
// }
// }
} }
}); });
})(); })();