From 51150cb20d6bf788b10281ff855d97870d3be2cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Tue, 12 Feb 2013 15:57:02 -0800 Subject: [PATCH] Support CanvasProvider.get(width, height) arguments. --- src/color/Color.js | 2 +- src/core/PaperScope.js | 2 +- src/util/CanvasProvider.js | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/color/Color.js b/src/color/Color.js index d9cecfac..a608c32b 100644 --- a/src/color/Color.js +++ b/src/color/Color.js @@ -62,7 +62,7 @@ var Color = this.Color = Base.extend(new function() { // Use a canvas to draw to with the given name and then retrieve rgb // values from. Build a cache for all the used colors. if (!colorContext) { - var canvas = CanvasProvider.get(Size.create(1, 1)); + var canvas = CanvasProvider.get(1, 1); colorContext = canvas.getContext('2d'); colorContext.globalCompositeOperation = 'copy'; } diff --git a/src/core/PaperScope.js b/src/core/PaperScope.js index 4bad25b9..868add47 100644 --- a/src/core/PaperScope.js +++ b/src/core/PaperScope.js @@ -62,7 +62,7 @@ var PaperScope = this.PaperScope = Base.extend(/** @lends PaperScope# */{ if (!this.support) { // Set up paper.support, as an object containing properties that // describe the support of various features. - var canvas = CanvasProvider.get(Size.create(1, 1)), + var canvas = CanvasProvider.get(1, 1), ctx = canvas.getContext('2d'); PaperScope.prototype.support = { nativeDash: 'setLineDash' in ctx || 'mozDash' in ctx diff --git a/src/util/CanvasProvider.js b/src/util/CanvasProvider.js index 90d96bdd..90af2530 100644 --- a/src/util/CanvasProvider.js +++ b/src/util/CanvasProvider.js @@ -15,7 +15,8 @@ var CanvasProvider = { canvases: [], - get: function(size) { + get: function(width, height) { + var size = arguments.length == 2 ? Size.create(width, height) : width; if (this.canvases.length) { var canvas = this.canvases.pop(); // If they are not the same size, we don't need to clear them