mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Bring back accidentally removed support for pixelRatio in CanvasProvider.
This commit is contained in:
parent
09d90a21bc
commit
3dae48acf4
1 changed files with 12 additions and 3 deletions
|
@ -15,13 +15,20 @@
|
|||
var CanvasProvider = {
|
||||
canvases: [],
|
||||
|
||||
getCanvas: function(width, height) {
|
||||
getCanvas: function(width, height, pixelRatio) {
|
||||
var canvas,
|
||||
init = true;
|
||||
if (typeof width === 'object') {
|
||||
pixelRatio = height;
|
||||
height = width.height;
|
||||
width = width.width;
|
||||
}
|
||||
if (!pixelRatio) {
|
||||
pixelRatio = 1;
|
||||
} else if (pixelRatio !== 1) {
|
||||
width *= pixelRatio;
|
||||
height *= pixelRatio;
|
||||
}
|
||||
if (this.canvases.length) {
|
||||
canvas = this.canvases.pop();
|
||||
} else {
|
||||
|
@ -45,11 +52,13 @@ var CanvasProvider = {
|
|||
}
|
||||
// We save on retrieval and restore on release.
|
||||
ctx.save();
|
||||
if (pixelRatio !== 1)
|
||||
ctx.scale(pixelRatio, pixelRatio);
|
||||
return canvas;
|
||||
},
|
||||
|
||||
getContext: function(width, height) {
|
||||
return this.getCanvas(width, height).getContext('2d');
|
||||
getContext: function(width, height, pixelRatio) {
|
||||
return this.getCanvas(width, height, pixelRatio).getContext('2d');
|
||||
},
|
||||
|
||||
// release can receive either a canvas or a context.
|
||||
|
|
Loading…
Reference in a new issue