makes sure that no pixels are drawn out of bounds
This commit is contained in:
parent
b6bc9185c7
commit
bfd28c9a7d
@ -21,17 +21,27 @@ function BallRenderer(thecanvas){
|
|||||||
this.availableWorkers = 10;
|
this.availableWorkers = 10;
|
||||||
this.mode = "heat";
|
this.mode = "heat";
|
||||||
this.cachedBalls = [];
|
this.cachedBalls = [];
|
||||||
|
this.initialize();
|
||||||
}
|
}
|
||||||
BallRenderer.prototype = {
|
BallRenderer.prototype = {
|
||||||
|
initialize: function(){
|
||||||
|
var self = this;
|
||||||
|
this.torqueLayer._map.on("movestart", function(){
|
||||||
|
self.transit = true
|
||||||
|
});
|
||||||
|
this.torqueLayer._map.on("moveend", function(){
|
||||||
|
self.transit = false
|
||||||
|
});
|
||||||
|
},
|
||||||
getBallIndices: function(x, y){
|
getBallIndices: function(x, y){
|
||||||
var indices = new Int8Array(2*r+1);
|
var indices = new Int8Array(2*r+1);
|
||||||
|
|
||||||
return indices;
|
return indices;
|
||||||
},
|
},
|
||||||
addBall: function(x0, y0, st){
|
addBall: function(x0, y0, st){
|
||||||
this.radius = st["marker-width"];
|
this.radius = st["marker-width"];
|
||||||
this.RW4 = this.radius * this.width *4;
|
this.RW4 = this.radius * this.width *4;
|
||||||
if(this.cachedBalls[this.radius]){
|
if(this.cachedBalls[this.radius]){
|
||||||
|
if(x0 < 0 || y0 < 0 || x0 > this.width || y0 > this.height) return;
|
||||||
var startingPoint = this.getRIndexPos(x0, y0) - this.RW4 - this.radius*4;
|
var startingPoint = this.getRIndexPos(x0, y0) - this.RW4 - this.radius*4;
|
||||||
var i = 0,
|
var i = 0,
|
||||||
pointer = startingPoint,
|
pointer = startingPoint,
|
||||||
|
Loading…
Reference in New Issue
Block a user