line stuff

This commit is contained in:
Francisco Dans 2015-03-16 11:14:22 +01:00
parent 9b761ffd4c
commit 7fed0cd757
2 changed files with 19 additions and 1 deletions

View File

@ -71,6 +71,12 @@ BallRenderer.prototype = {
}
},
addLinePoint: function(x, y){
if(!this.line){
this.line = [];
}
line.push({x,y});
},
horizontalLine: function(xi, xf, yi, x0, y0){
// Assumes xi is on the left and xf is on the right
if(typeof this.drawnTemp[yi] === "undefined"){
@ -94,6 +100,17 @@ BallRenderer.prototype = {
return Math.sqrt( xs + ys );
},
draw: function(dataArray){
if(this.line){
ctx.beginPath()
for (i in this.line){
if(i === 0) this.ctx.moveTo(this.line[i].x, this.line[i].x);
else{
this.ctx.lineTo(this.line[i].x, this.line[i].x);
}
}
ctx.endPath();
}
ctx.stroke();
if (!dataArray){
if (this.isoplethLayer) dataArray = this.isoplethLayer;
else if (this.contourLayer) dataArray = this.contourLayer;

View File

@ -266,7 +266,8 @@ var Filters = require('./torque_filters');
var x = tile.x[posIdx];
var y = tileMax - tile.y[posIdx]; // flip mercator
if(!this.ballRenderer) this.ballRenderer = new BallRenderer(this._canvas);
this.ballRenderer.addBall(pos.x + x, pos.y + y);
//this.ballRenderer.addBall(pos.x + x, pos.y + y);
this.ballRenderer.addLinePoint(pos.x + x, pos.y + y);
// var sp = sprites[c];
// if (sp === undefined) {
// sp = sprites[c] = this.generateSprite(shader, c, torque.extend({ zoom: tile.z, 'frame-offset': frame_offset }, shaderVars));