mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-22 07:19:57 -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 = {
|
var CanvasProvider = {
|
||||||
canvases: [],
|
canvases: [],
|
||||||
|
|
||||||
getCanvas: function(width, height) {
|
getCanvas: function(width, height, pixelRatio) {
|
||||||
var canvas,
|
var canvas,
|
||||||
init = true;
|
init = true;
|
||||||
if (typeof width === 'object') {
|
if (typeof width === 'object') {
|
||||||
|
pixelRatio = height;
|
||||||
height = width.height;
|
height = width.height;
|
||||||
width = width.width;
|
width = width.width;
|
||||||
}
|
}
|
||||||
|
if (!pixelRatio) {
|
||||||
|
pixelRatio = 1;
|
||||||
|
} else if (pixelRatio !== 1) {
|
||||||
|
width *= pixelRatio;
|
||||||
|
height *= pixelRatio;
|
||||||
|
}
|
||||||
if (this.canvases.length) {
|
if (this.canvases.length) {
|
||||||
canvas = this.canvases.pop();
|
canvas = this.canvases.pop();
|
||||||
} else {
|
} else {
|
||||||
|
@ -45,11 +52,13 @@ var CanvasProvider = {
|
||||||
}
|
}
|
||||||
// We save on retrieval and restore on release.
|
// We save on retrieval and restore on release.
|
||||||
ctx.save();
|
ctx.save();
|
||||||
|
if (pixelRatio !== 1)
|
||||||
|
ctx.scale(pixelRatio, pixelRatio);
|
||||||
return canvas;
|
return canvas;
|
||||||
},
|
},
|
||||||
|
|
||||||
getContext: function(width, height) {
|
getContext: function(width, height, pixelRatio) {
|
||||||
return this.getCanvas(width, height).getContext('2d');
|
return this.getCanvas(width, height, pixelRatio).getContext('2d');
|
||||||
},
|
},
|
||||||
|
|
||||||
// release can receive either a canvas or a context.
|
// release can receive either a canvas or a context.
|
||||||
|
|
Loading…
Reference in a new issue