From 7fed0cd757b9e427298d81d0b05501c5edd9738c Mon Sep 17 00:00:00 2001 From: Francisco Dans Date: Mon, 16 Mar 2015 11:14:22 +0100 Subject: [PATCH] line stuff --- lib/torque/renderer/ball.js | 17 +++++++++++++++++ lib/torque/renderer/point.js | 3 ++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/torque/renderer/ball.js b/lib/torque/renderer/ball.js index 8f19df7..69dfbd8 100644 --- a/lib/torque/renderer/ball.js +++ b/lib/torque/renderer/ball.js @@ -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; diff --git a/lib/torque/renderer/point.js b/lib/torque/renderer/point.js index 7913d1e..53068b3 100644 --- a/lib/torque/renderer/point.js +++ b/lib/torque/renderer/point.js @@ -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));