Pass tiledImage and context to the placeholderFillStyle function

This commit is contained in:
Philip Giuliani 2015-04-15 13:32:41 +02:00
parent 6b1580824a
commit 21d32b59f5
3 changed files with 14 additions and 11 deletions

View File

@ -310,16 +310,10 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{
return;
}
this.saveContext();
if ( typeof fillStyle === "function" ) {
this.context.fillStyle = fillStyle(this.context);
}
else {
this.context.fillStyle = fillStyle;
}
this.context.save();
this.context.fillStyle = fillStyle;
this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
this.restoreContext();
this.context.restore();
},
// private

View File

@ -209,7 +209,7 @@
* @property {String|CanvasGradient|CanvasPattern|Function} [placeholderFillStyle=null]
* Draws a colored rectangle behind the tile if it is not loaded yet.
* You can pass a CSS color value like "#FF8800".
* When passing a function the canvas context is available as argument which is useful when you draw a gradient or pattern.
* When passing a function the tiledImage and canvas context are available as argument which is useful when you draw a gradient or pattern.
*
* @property {Number} [degrees=0]
* Initial rotation.

View File

@ -1172,7 +1172,16 @@ function drawTiles( tiledImage, lastDrawn ) {
if ( tiledImage.placeholderFillStyle && lastDrawn.length === 0 ) {
var placeholderRect = tiledImage._drawer.viewportToDrawerRectangle(tiledImage.getBounds(true));
tiledImage._drawer.drawPlaceholder(placeholderRect, tiledImage.placeholderFillStyle);
var fillStyle = null;
if ( typeof tiledImage.placeholderFillStyle === "function" ) {
fillStyle = tiledImage.placeholderFillStyle(tiledImage, tiledImage._drawer.context);
}
else {
fillStyle = tiledImage.placeholderFillStyle;
}
tiledImage._drawer.drawPlaceholder(placeholderRect, fillStyle);
}
for ( i = lastDrawn.length - 1; i >= 0; i-- ) {