From bcb709300c6a9a1d8641315e9bd156a0eecc1180 Mon Sep 17 00:00:00 2001 From: jdescottes Date: Thu, 26 Feb 2015 00:13:32 +0100 Subject: [PATCH] Added method to enable image smoothing on Canvas --- src/js/utils/CanvasUtils.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/js/utils/CanvasUtils.js b/src/js/utils/CanvasUtils.js index da3c1927..73553c2b 100644 --- a/src/js/utils/CanvasUtils.js +++ b/src/js/utils/CanvasUtils.js @@ -41,12 +41,20 @@ * @param {Canvas} canvas */ disableImageSmoothing : function (canvas) { + pskl.utils.CanvasUtils.setImageSmoothing(canvas, false); + }, + + enableImageSmoothing : function (canvas) { + pskl.utils.CanvasUtils.setImageSmoothing(canvas, true); + }, + + setImageSmoothing : function (canvas, smoothing) { var context = canvas.getContext('2d'); - context.imageSmoothingEnabled = false; - context.mozImageSmoothingEnabled = false; - context.oImageSmoothingEnabled = false; - context.webkitImageSmoothingEnabled = false; - context.msImageSmoothingEnabled = false; + context.imageSmoothingEnabled = smoothing; + context.mozImageSmoothingEnabled = smoothing; + context.oImageSmoothingEnabled = smoothing; + context.webkitImageSmoothingEnabled = smoothing; + context.msImageSmoothingEnabled = smoothing; }, clear : function (canvas) {