diff --git a/src/drawer.js b/src/drawer.js index eed97719..c904abbb 100644 --- a/src/drawer.js +++ b/src/drawer.js @@ -69,7 +69,7 @@ $.Drawer = function( options ) { this.viewer = options.viewer; this.viewport = options.viewport; - this.debugGridColor = options.debugGridColor || $.DEFAULT_SETTINGS.debugGridColor; + this.debugGridColor = typeof options.debugGridColor === 'string' ? [options.debugGridColor] : options.debugGridColor || $.DEFAULT_SETTINGS.debugGridColor; if (options.opacity) { $.console.error( "[Drawer] options.opacity is no longer accepted; set the opacity on the TiledImage instead" ); } @@ -490,12 +490,13 @@ $.Drawer.prototype = { return; } + var colorIndex = this.viewer.world.getIndexOfItem(tiledImage) % this.debugGridColor.length; var context = this.context; context.save(); context.lineWidth = 2 * $.pixelDensityRatio; context.font = 'small-caps bold ' + (13 * $.pixelDensityRatio) + 'px arial'; - context.strokeStyle = this.debugGridColor; - context.fillStyle = this.debugGridColor; + context.strokeStyle = this.debugGridColor[colorIndex]; + context.fillStyle = this.debugGridColor[colorIndex]; if ( this.viewport.degrees !== 0 ) { this._offsetForRotation({degrees: this.viewport.degrees}); @@ -581,8 +582,8 @@ $.Drawer.prototype = { var context = this.context; context.save(); context.lineWidth = 2 * $.pixelDensityRatio; - context.strokeStyle = this.debugGridColor; - context.fillStyle = this.debugGridColor; + context.strokeStyle = this.debugGridColor[0]; + context.fillStyle = this.debugGridColor[0]; context.strokeRect( rect.x * $.pixelDensityRatio, diff --git a/src/openseadragon.js b/src/openseadragon.js index ade8761d..de88f717 100644 --- a/src/openseadragon.js +++ b/src/openseadragon.js @@ -159,7 +159,9 @@ * @property {Boolean} [debugMode=false] * TODO: provide an in-screen panel providing event detail feedback. * - * @property {String} [debugGridColor='#437AB2'] + * @property {String} [debugGridColor=['#437AB2', '#1B9E77', '#D95F02', '#7570B3', '#E7298A', '#66A61E', '#E6AB02', '#A6761D', '#666666']] + * The colors of grids in debug mode. Each tiled image's grid uses a consecutive color. + * If there are more tiled images than provided colors, the color vector is recycled. * * @property {Number} [blendTime=0] * Specifies the duration of animation as higher or lower level tiles are @@ -1207,7 +1209,7 @@ function OpenSeadragon( options ){ //DEVELOPER SETTINGS debugMode: false, - debugGridColor: '#437AB2' + debugGridColor: ['#437AB2', '#1B9E77', '#D95F02', '#7570B3', '#E7298A', '#66A61E', '#E6AB02', '#A6761D', '#666666'] },