Add option to define the fillStyle of the placeholder

This commit is contained in:
Philip Giuliani 2015-04-09 13:44:55 +02:00
parent 50e46b104e
commit 4523454ff1
4 changed files with 27 additions and 20 deletions

View File

@ -288,13 +288,13 @@ $.Drawer.prototype = /** @lends OpenSeadragon.Drawer.prototype */{
},
// private
drawPlaceholder: function(rect) {
drawPlaceholder: function(rect, fillStyle) {
if (!this.useCanvas) {
return;
}
this.context.fillStyle = fillStyle || "#FFFFFF";
this.context.fillRect(rect.x, rect.y, rect.width, rect.height);
this.context.fillStyle = "#000000";
},
// private

View File

@ -206,6 +206,9 @@
* @property {Number} [opacity=1]
* Opacity of the drawer (1=opaque, 0=transparent)
*
* @property {String|Object} [placeholderFillStyle=null]
* Draws a colored rectangle behind the tile if it is not loaded yet.
*
* @property {Number} [degrees=0]
* Initial rotation.
*
@ -1017,6 +1020,7 @@ window.OpenSeadragon = window.OpenSeadragon || function( options ){
// APPEARANCE
opacity: 1,
placeholderFillStyle: null,
//REFERENCE STRIP SETTINGS
showReferenceStrip: false,

View File

@ -65,6 +65,7 @@
* @param {Boolean} [options.alwaysBlend] - See {@link OpenSeadragon.Options}.
* @param {Number} [options.minPixelRatio] - See {@link OpenSeadragon.Options}.
* @param {Boolean} [options.debugMode] - See {@link OpenSeadragon.Options}.
* @param {String|Object} [options.placeholderFillStyle] - See {@link OpenSeadragon.Options}.
* @param {String|Boolean} [options.crossOriginPolicy] - See {@link OpenSeadragon.Options}.
*/
$.TiledImage = function( options ) {
@ -140,7 +141,8 @@ $.TiledImage = function( options ) {
alwaysBlend: $.DEFAULT_SETTINGS.alwaysBlend,
minPixelRatio: $.DEFAULT_SETTINGS.minPixelRatio,
debugMode: $.DEFAULT_SETTINGS.debugMode,
crossOriginPolicy: $.DEFAULT_SETTINGS.crossOriginPolicy
crossOriginPolicy: $.DEFAULT_SETTINGS.crossOriginPolicy,
placeholderFillStyle: $.DEFAULT_SETTINGS.placeholderFillStyle
}, options );
@ -1180,11 +1182,11 @@ function drawTiles( tiledImage, lastDrawn ){
needsRestore = true;
}
if ( lastDrawn.length === 0 ) {
if ( tiledImage.placeholderFillStyle && lastDrawn.length === 0 ) {
tiledImage._drawer.saveContext();
var placeholderRect = boxToDrawerRectangle( tiledImage.getBounds(true) );
tiledImage._drawer.drawPlaceholder(placeholderRect);
tiledImage._drawer.drawPlaceholder(placeholderRect, tiledImage.placeholderFillStyle);
needsRestore = true;
}

View File

@ -1294,7 +1294,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
alwaysBlend: _this.alwaysBlend,
minPixelRatio: _this.minPixelRatio,
crossOriginPolicy: _this.crossOriginPolicy,
debugMode: _this.debugMode
debugMode: _this.debugMode,
placeholderFillStyle: _this.placeholderFillStyle
});
_this.world.addItem( tiledImage, {