Support CanvasProvider.get(width, height) arguments.

This commit is contained in:
Jürg Lehni 2013-02-12 15:57:02 -08:00
parent 9600fdb512
commit 51150cb20d
3 changed files with 4 additions and 3 deletions

View file

@ -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';
}

View file

@ -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

View file

@ -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