diff --git a/CHANGELOG b/CHANGELOG index cdc1f8e..db17284 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ -= 1.0.8 += 1.0.9 + * True fix for issue with lineWidth handling in stroke (#14) + += 1.0.8 (broken) * Fix issue with lineWidth handling in stroke (#14) = 1.0.7 diff --git a/bower.json b/bower.json index cc86695..785a604 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "hidpi-canvas", - "version": "1.0.8", + "version": "1.0.9", "homepage": "https://github.com/jondavidjohn/hidpi-canvas-polyfill", "authors": [ "Jonathan Johnson " diff --git a/dist/hidpi-canvas.js b/dist/hidpi-canvas.js index 156c951..2f94a38 100644 --- a/dist/hidpi-canvas.js +++ b/dist/hidpi-canvas.js @@ -1,5 +1,5 @@ /** - * HiDPI Canvas Polyfill (1.0.8) + * HiDPI Canvas Polyfill (1.0.9) * * Author: Jonathan D. Johnson (http://jondavidjohn.com) * Homepage: https://github.com/jondavidjohn/hidpi-canvas-polyfill @@ -70,12 +70,13 @@ }); // Stroke lineWidth adjustment - prototype.stroke = (function(_super) { - var args = Array.prototype.slice.call(arguments); - this.lineWidth *= pixelRatio; - _super.apply(this, args); - this.lineWidth /= pixelRatio; - })(prototype.stroke); + prototype.stroke = (function(_super) { + return function() { + this.lineWidth *= pixelRatio; + _super.apply(this, arguments); + this.lineWidth /= pixelRatio; + }; + })(prototype.stroke); // Text // diff --git a/dist/hidpi-canvas.min.js b/dist/hidpi-canvas.min.js index 0e9e614..687149e 100644 --- a/dist/hidpi-canvas.min.js +++ b/dist/hidpi-canvas.min.js @@ -1,9 +1,9 @@ /** - * HiDPI Canvas Polyfill (1.0.8) + * HiDPI Canvas Polyfill (1.0.9) * * Author: Jonathan D. Johnson (http://jondavidjohn.com) * Homepage: https://github.com/jondavidjohn/hidpi-canvas-polyfill * Issue Tracker: https://github.com/jondavidjohn/hidpi-canvas-polyfill/issues * License: Apache 2.0 */ -!function(a){var b=function(a){var b=a.backingStorePixelRatio||a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/b}(a),c=function(a,b){for(var c in a)a.hasOwnProperty(c)&&b(a[c],c)},d={fillRect:"all",clearRect:"all",strokeRect:"all",moveTo:"all",lineTo:"all",arc:[0,1,2],arcTo:"all",bezierCurveTo:"all",isPointinPath:"all",isPointinStroke:"all",quadraticCurveTo:"all",rect:"all",translate:"all",createRadialGradient:"all",createLinearGradient:"all"};1!==b&&(c(d,function(c,d){a[d]=function(a){return function(){var d,e,f=Array.prototype.slice.call(arguments);if("all"===c)f=f.map(function(a){return a*b});else if(Array.isArray(c))for(d=0,e=c.length;e>d;d++)f[c[d]]*=b;return a.apply(this,f)}}(a[d])}),a.stroke=function(a){var c=Array.prototype.slice.call(arguments);this.lineWidth*=b,a.apply(this,c),this.lineWidth/=b}(a.stroke),a.fillText=function(a){return function(){var c=Array.prototype.slice.call(arguments);c[1]*=b,c[2]*=b,this.font=this.font.replace(/(\d+)(px|em|rem|pt)/g,function(a,c,d){return c*b+d}),a.apply(this,c),this.font=this.font.replace(/(\d+)(px|em|rem|pt)/g,function(a,c,d){return c/b+d})}}(a.fillText),a.strokeText=function(a){return function(){var c=Array.prototype.slice.call(arguments);c[1]*=b,c[2]*=b,this.font=this.font.replace(/(\d+)(px|em|rem|pt)/g,function(a,c,d){return c*b+d}),a.apply(this,c),this.font=this.font.replace(/(\d+)(px|em|rem|pt)/g,function(a,c,d){return c/b+d})}}(a.strokeText))}(CanvasRenderingContext2D.prototype),function(a){a.getContext=function(a){return function(b){var c,d,e=a.call(this,b);return"2d"===b&&(c=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1,d=(window.devicePixelRatio||1)/c,d>1&&(this.style.height=this.height+"px",this.style.width=this.width+"px",this.width*=d,this.height*=d)),e}}(a.getContext)}(HTMLCanvasElement.prototype); \ No newline at end of file +!function(a){var b=function(a){var b=a.backingStorePixelRatio||a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/b}(a),c=function(a,b){for(var c in a)a.hasOwnProperty(c)&&b(a[c],c)},d={fillRect:"all",clearRect:"all",strokeRect:"all",moveTo:"all",lineTo:"all",arc:[0,1,2],arcTo:"all",bezierCurveTo:"all",isPointinPath:"all",isPointinStroke:"all",quadraticCurveTo:"all",rect:"all",translate:"all",createRadialGradient:"all",createLinearGradient:"all"};1!==b&&(c(d,function(c,d){a[d]=function(a){return function(){var d,e,f=Array.prototype.slice.call(arguments);if("all"===c)f=f.map(function(a){return a*b});else if(Array.isArray(c))for(d=0,e=c.length;e>d;d++)f[c[d]]*=b;return a.apply(this,f)}}(a[d])}),a.stroke=function(a){return function(){this.lineWidth*=b,a.apply(this,arguments),this.lineWidth/=b}}(a.stroke),a.fillText=function(a){return function(){var c=Array.prototype.slice.call(arguments);c[1]*=b,c[2]*=b,this.font=this.font.replace(/(\d+)(px|em|rem|pt)/g,function(a,c,d){return c*b+d}),a.apply(this,c),this.font=this.font.replace(/(\d+)(px|em|rem|pt)/g,function(a,c,d){return c/b+d})}}(a.fillText),a.strokeText=function(a){return function(){var c=Array.prototype.slice.call(arguments);c[1]*=b,c[2]*=b,this.font=this.font.replace(/(\d+)(px|em|rem|pt)/g,function(a,c,d){return c*b+d}),a.apply(this,c),this.font=this.font.replace(/(\d+)(px|em|rem|pt)/g,function(a,c,d){return c/b+d})}}(a.strokeText))}(CanvasRenderingContext2D.prototype),function(a){a.getContext=function(a){return function(b){var c,d,e=a.call(this,b);return"2d"===b&&(c=e.backingStorePixelRatio||e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1,d=(window.devicePixelRatio||1)/c,d>1&&(this.style.height=this.height+"px",this.style.width=this.width+"px",this.width*=d,this.height*=d)),e}}(a.getContext)}(HTMLCanvasElement.prototype); \ No newline at end of file diff --git a/package.json b/package.json index 76b0cd4..94f91de 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "hidpi-canvas", "description": "A JavaScript drop-in module to polyfill consistent and automatic HiDPI Canvas support.", - "version": "1.0.8", + "version": "1.0.9", "license": "Apache 2.0", "homepage": "https://github.com/jondavidjohn/hidpi-canvas-polyfill", "bugs": "https://github.com/jondavidjohn/hidpi-canvas-polyfill/issues", diff --git a/src/CanvasRenderingContext2D.js b/src/CanvasRenderingContext2D.js index 1347942..ac077c1 100644 --- a/src/CanvasRenderingContext2D.js +++ b/src/CanvasRenderingContext2D.js @@ -62,12 +62,13 @@ }); // Stroke lineWidth adjustment - prototype.stroke = (function(_super) { - var args = Array.prototype.slice.call(arguments); - this.lineWidth *= pixelRatio; - _super.apply(this, args); - this.lineWidth /= pixelRatio; - })(prototype.stroke); + prototype.stroke = (function(_super) { + return function() { + this.lineWidth *= pixelRatio; + _super.apply(this, arguments); + this.lineWidth /= pixelRatio; + }; + })(prototype.stroke); // Text //