Skip to content

Commit

Permalink
Renames parameter to background
Browse files Browse the repository at this point in the history
Adds more documentation
Changes to ES6
  • Loading branch information
chris.greening committed May 17, 2017
1 parent 70877e8 commit 4dc5bf8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/display/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,11 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() {
* @property {Object} canvasFactory - (optional) The factory that will be used
* when creating canvases. The default value is
* {DOMCanvasFactory}.
* @property {string} backgroundColor - (optional) Background color to use for
* the canvas. The default value is 'rgb(255,255,255)'.
* @property {Object} background - (optional) Background to use for the canvas.
* Can use any valid canvas.fillStyle: A DOMString parsed as
* CSS <color> value, a CanvasGradient object (a linear or
* radial gradient) or a CanvasPattern object (a repetitive
* image). The default value is 'rgb(255,255,255)'.
*/

/**
Expand Down Expand Up @@ -2134,7 +2137,7 @@ var InternalRenderTask = (function InternalRenderTaskClosure() {
transform: params.transform,
viewport: params.viewport,
transparency,
backgroundColor: params.backgroundColor,
background: params.background,
});
this.operatorListIdx = 0;
this.graphicsReady = true;
Expand Down
6 changes: 3 additions & 3 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -705,8 +705,8 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {

CanvasGraphics.prototype = {

beginDrawing: function CanvasGraphics_beginDrawing({
transform, viewport, transparency, backgroundColor = null,
beginDrawing({
transform, viewport, transparency, background = null,
}) {
// For pdfs that use blend modes we have to clear the canvas else certain
// blend modes can look wrong since we'd be blending with a white
Expand All @@ -717,7 +717,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
var height = this.ctx.canvas.height;

this.ctx.save();
this.ctx.fillStyle = backgroundColor || 'rgb(255, 255, 255)';
this.ctx.fillStyle = background || 'rgb(255, 255, 255)';
this.ctx.fillRect(0, 0, width, height);
this.ctx.restore();

Expand Down
2 changes: 1 addition & 1 deletion test/unit/custom_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('custom canvas rendering', function() {
page.render({
canvasContext: canvasAndCtx.context,
viewport,
backgroundColor: 'rgba(255,0,0,1.0)'
background: 'rgba(255,0,0,1.0)'
}).then(function() {
var { r, g, b, a } = getTopLeftPixel(canvasAndCtx.context);
CanvasFactory.destroy(canvasAndCtx);
Expand Down

0 comments on commit 4dc5bf8

Please sign in to comment.