Abstract canvas/image creation, if a class is provided it will use that as constructor.
Otherwise it will fallback to browser implementation.
This commit is contained in:
parent
3471a2ac6d
commit
7499e8cf6a
@ -77,8 +77,7 @@ var carto = require('carto');
|
||||
return null;
|
||||
}
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
|
||||
var canvas = this._createCanvas();
|
||||
// take into account the exterior ring to calculate the size
|
||||
var canvasSize = (st.lineWidth || 0) + pointSize*2;
|
||||
var ctx = canvas.getContext('2d');
|
||||
@ -97,7 +96,7 @@ var carto = require('carto');
|
||||
}
|
||||
prof.end(true);
|
||||
if (torque.flags.sprites_to_images) {
|
||||
var i = new Image();
|
||||
var i = this._createImage();
|
||||
i.src = canvas.toDataURL();
|
||||
return i;
|
||||
}
|
||||
@ -125,6 +124,18 @@ var carto = require('carto');
|
||||
prof.end(true);
|
||||
},
|
||||
|
||||
_createCanvas: function() {
|
||||
return this.options.canvasClass
|
||||
? new this.options.canvasClass()
|
||||
: document.createElement('canvas');
|
||||
},
|
||||
|
||||
_createImage: function() {
|
||||
return this.options.imageClass
|
||||
? new this.options.imageClass()
|
||||
: new Image();
|
||||
},
|
||||
|
||||
//
|
||||
// renders a tile in the canvas for key defined in
|
||||
// the torque tile
|
||||
|
Loading…
Reference in New Issue
Block a user