From 4f07a73303f316f617dc73a75a144f09a170516c Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Fri, 8 Aug 2014 16:40:01 -0500 Subject: [PATCH 1/9] Fixed incorrect usage of it's Tiny grammar fix. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ddd2905..3e7db0a 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ without having to modify any of your canvas code. Currently this plugin handles most general cross browser drawing functions, but feel free to send Pull Requests as you find functions you need supported. -If the function simply needs all or some of it's arguments multiplied by the ratio, +If the function simply needs all or some of its arguments multiplied by the ratio, it should simply require you to add it to the `ratioArgs` object, following the proper pattern. From 34db1afd3fd2b8392015c2ebaedda6248e6416b0 Mon Sep 17 00:00:00 2001 From: Dawid Karabin Date: Fri, 23 Sep 2016 16:09:16 +0200 Subject: [PATCH 2/9] Fix accessing webkitBackingStorePixelRatio of context on iOS10 (#26) On iOS 10 webkitBackingStorePixelRatio can be accessed only by using instance of CanvasRenderingContext2D. Using Object.create(prototype) in that case doesn't work so the only way to access that property is by getting context 2d from canvas element. --- .gitignore | 1 + dist/hidpi-canvas.js | 18 ++++++++++-------- dist/hidpi-canvas.min.js | 2 +- src/CanvasRenderingContext2D.js | 18 ++++++++++-------- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/.gitignore b/.gitignore index 07e6e47..727118b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules +npm-debug.log \ No newline at end of file diff --git a/dist/hidpi-canvas.js b/dist/hidpi-canvas.js index 2f94a38..7f92def 100644 --- a/dist/hidpi-canvas.js +++ b/dist/hidpi-canvas.js @@ -8,16 +8,18 @@ */ (function(prototype) { - var pixelRatio = (function(context) { - var backingStore = context.backingStorePixelRatio || - context.webkitBackingStorePixelRatio || - context.mozBackingStorePixelRatio || - context.msBackingStorePixelRatio || - context.oBackingStorePixelRatio || - context.backingStorePixelRatio || 1; + var pixelRatio = (function() { + var canvas = document.createElement('canvas'), + context = canvas.getContext('2d'), + backingStore = context.backingStorePixelRatio || + context.webkitBackingStorePixelRatio || + context.mozBackingStorePixelRatio || + context.msBackingStorePixelRatio || + context.oBackingStorePixelRatio || + context.backingStorePixelRatio || 1; return (window.devicePixelRatio || 1) / backingStore; - })(prototype), + })(), forEach = function(obj, func) { for (var p in obj) { diff --git a/dist/hidpi-canvas.min.js b/dist/hidpi-canvas.min.js index 687149e..286a23a 100644 --- a/dist/hidpi-canvas.min.js +++ b/dist/hidpi-canvas.min.js @@ -6,4 +6,4 @@ * 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){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 +!function(a){var b=function(){var a=document.createElement("canvas"),b=a.getContext("2d"),c=b.backingStorePixelRatio||b.webkitBackingStorePixelRatio||b.mozBackingStorePixelRatio||b.msBackingStorePixelRatio||b.oBackingStorePixelRatio||b.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/c}(),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/src/CanvasRenderingContext2D.js b/src/CanvasRenderingContext2D.js index ac077c1..8399e97 100644 --- a/src/CanvasRenderingContext2D.js +++ b/src/CanvasRenderingContext2D.js @@ -1,15 +1,17 @@ (function(prototype) { - var pixelRatio = (function(context) { - var backingStore = context.backingStorePixelRatio || - context.webkitBackingStorePixelRatio || - context.mozBackingStorePixelRatio || - context.msBackingStorePixelRatio || - context.oBackingStorePixelRatio || - context.backingStorePixelRatio || 1; + var pixelRatio = (function() { + var canvas = document.createElement('canvas'), + context = canvas.getContext('2d'), + backingStore = context.backingStorePixelRatio || + context.webkitBackingStorePixelRatio || + context.mozBackingStorePixelRatio || + context.msBackingStorePixelRatio || + context.oBackingStorePixelRatio || + context.backingStorePixelRatio || 1; return (window.devicePixelRatio || 1) / backingStore; - })(prototype), + })(), forEach = function(obj, func) { for (var p in obj) { From 2185f070c54aa2c42241b79efe38b25000fe857b Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 23 Sep 2016 09:17:49 -0500 Subject: [PATCH 3/9] update to use npm scripts --- CONTRIBUTING.md | 12 ++++++------ package.json | 4 +++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6e170e7..bd51bf7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -5,7 +5,7 @@ Yay, you're interested in helping this thing suck less. Good for you! Some things you should be familiar with before getting started - Unit testing (with [QUnit](http://qunitjs.com)) - - [Grunt](http://gruntjs.org) (available via `npm install -g grunt-cli`) + - [Grunt](http://gruntjs.org) - [Node/NPM](https://npmjs.org/) (available via homebrew) ## Project Layout @@ -17,15 +17,15 @@ Some things you should be familiar with before getting started ## Development -Once you have NPM and Grunt installed, clone the repository (with `--recursive` to also clone all submodules) and install all dependencies +Once you have npm installed, clone the repository (with `--recursive` to also clone all submodules) and install all dependencies git clone git@.....hidpi-canvas-polyfill.git --recursive cd hidpi-canvas-polyfill npm install -Then to build a distribution run this grunt task +Then to build a distribution run - grunt dist + npm run build This will generate the compiled (and minified) sourc in your `dist/` directory along with a distributable zip archive. @@ -35,7 +35,7 @@ need to re-run this command. You can also use - grunt watch + npm run watch to automatically reconcat the unminified file everytime you change any of the `src/**/*.js` files. @@ -49,7 +49,7 @@ sure to organize and produce tests that fit the patterns present. ### Running Tests - grunt test + npm test ## On Contribution diff --git a/package.json b/package.json index 94f91de..4b6dcb5 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,8 @@ }, "scripts": { "test": "grunt", - "prepublish": "grunt dist" + "watch": "grunt watch", + "build": "grunt dist", + "prepublish": "npm run build" } } From b2202331886b02bc4628c1e69ebf3f7c56280abc Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 23 Sep 2016 09:20:27 -0500 Subject: [PATCH 4/9] add travis config --- .travis.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..587bd3e --- /dev/null +++ b/.travis.yml @@ -0,0 +1 @@ +language: node_js From 34a06660fd06578920cac45846f44ad176b25893 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 23 Sep 2016 09:24:22 -0500 Subject: [PATCH 5/9] convert qunit submodule to pull via https (public) --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 5b5ce9c..3948f8c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "test/qunit"] path = test/qunit - url = git@github.com:jquery/qunit.git + url = https://github.com/jquery/qunit.git From 20c79047d14e43cdbb6a849c7029850ef8439e13 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 23 Sep 2016 09:28:05 -0500 Subject: [PATCH 6/9] add build badge to readme (SO IMPORTANT) --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3e7db0a..613efe5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # HiDPI Canvas Polyfill +[![Build Status](https://travis-ci.org/jondavidjohn/hidpi-canvas-polyfill.svg?branch=master)](https://travis-ci.org/jondavidjohn/hidpi-canvas-polyfill) + This is a drop-in polyfill to scale canvas appropriately to maintain sharpness in browsers that currently do not provide the appropriately scaled backing store to do this automatically. From a29ee9e952880f541ad858be172cfa46ac6c85c2 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 23 Sep 2016 09:28:29 -0500 Subject: [PATCH 7/9] update license to SPDX --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4b6dcb5..c604fcc 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "hidpi-canvas", "description": "A JavaScript drop-in module to polyfill consistent and automatic HiDPI Canvas support.", "version": "1.0.9", - "license": "Apache 2.0", + "license": "Apache-2.0", "homepage": "https://github.com/jondavidjohn/hidpi-canvas-polyfill", "bugs": "https://github.com/jondavidjohn/hidpi-canvas-polyfill/issues", "repository": { From 2aef9eca2d1b0a87cb4920d92f64f39910fcdb68 Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 23 Sep 2016 09:28:43 -0500 Subject: [PATCH 8/9] fixup indentation formatting --- dist/hidpi-canvas.js | 14 +++++++------- dist/hidpi-canvas.min.js | 9 --------- src/CanvasRenderingContext2D.js | 14 +++++++------- 3 files changed, 14 insertions(+), 23 deletions(-) delete mode 100644 dist/hidpi-canvas.min.js diff --git a/dist/hidpi-canvas.js b/dist/hidpi-canvas.js index 7f92def..60d0545 100644 --- a/dist/hidpi-canvas.js +++ b/dist/hidpi-canvas.js @@ -10,13 +10,13 @@ var pixelRatio = (function() { var canvas = document.createElement('canvas'), - context = canvas.getContext('2d'), - backingStore = context.backingStorePixelRatio || - context.webkitBackingStorePixelRatio || - context.mozBackingStorePixelRatio || - context.msBackingStorePixelRatio || - context.oBackingStorePixelRatio || - context.backingStorePixelRatio || 1; + context = canvas.getContext('2d'), + backingStore = context.backingStorePixelRatio || + context.webkitBackingStorePixelRatio || + context.mozBackingStorePixelRatio || + context.msBackingStorePixelRatio || + context.oBackingStorePixelRatio || + context.backingStorePixelRatio || 1; return (window.devicePixelRatio || 1) / backingStore; })(), diff --git a/dist/hidpi-canvas.min.js b/dist/hidpi-canvas.min.js deleted file mode 100644 index 286a23a..0000000 --- a/dist/hidpi-canvas.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/** - * 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(){var a=document.createElement("canvas"),b=a.getContext("2d"),c=b.backingStorePixelRatio||b.webkitBackingStorePixelRatio||b.mozBackingStorePixelRatio||b.msBackingStorePixelRatio||b.oBackingStorePixelRatio||b.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/c}(),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/src/CanvasRenderingContext2D.js b/src/CanvasRenderingContext2D.js index 8399e97..589abc8 100644 --- a/src/CanvasRenderingContext2D.js +++ b/src/CanvasRenderingContext2D.js @@ -2,13 +2,13 @@ var pixelRatio = (function() { var canvas = document.createElement('canvas'), - context = canvas.getContext('2d'), - backingStore = context.backingStorePixelRatio || - context.webkitBackingStorePixelRatio || - context.mozBackingStorePixelRatio || - context.msBackingStorePixelRatio || - context.oBackingStorePixelRatio || - context.backingStorePixelRatio || 1; + context = canvas.getContext('2d'), + backingStore = context.backingStorePixelRatio || + context.webkitBackingStorePixelRatio || + context.mozBackingStorePixelRatio || + context.msBackingStorePixelRatio || + context.oBackingStorePixelRatio || + context.backingStorePixelRatio || 1; return (window.devicePixelRatio || 1) / backingStore; })(), From c60a54ba600a769c28ddf2f40784afd3a4bd6fee Mon Sep 17 00:00:00 2001 From: Jonathan Johnson Date: Fri, 23 Sep 2016 09:34:45 -0500 Subject: [PATCH 9/9] bump n' build --- CHANGELOG | 5 +++++ bower.json | 4 ++-- dist/hidpi-canvas.js | 4 ++-- dist/hidpi-canvas.min.js | 9 +++++++++ package.json | 2 +- 5 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 dist/hidpi-canvas.min.js diff --git a/CHANGELOG b/CHANGELOG index db17284..e652d2b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,8 @@ += 1.0.10 + * Fixed iOS 10 API deprication (#17) + * Add Travis CI + * Include minified build in release + = 1.0.9 * True fix for issue with lineWidth handling in stroke (#14) diff --git a/bower.json b/bower.json index 785a604..eb4e3b9 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "hidpi-canvas", - "version": "1.0.9", + "version": "1.0.10", "homepage": "https://github.com/jondavidjohn/hidpi-canvas-polyfill", "authors": [ "Jonathan Johnson " @@ -13,7 +13,7 @@ "polyfill" ], "main": "dist/hidpi-canvas.js", - "license": "Apache 2.0", + "license": "Apache-2.0", "ignore": [ "**/.*", "node_modules", diff --git a/dist/hidpi-canvas.js b/dist/hidpi-canvas.js index 60d0545..3d1f1ba 100644 --- a/dist/hidpi-canvas.js +++ b/dist/hidpi-canvas.js @@ -1,10 +1,10 @@ /** - * HiDPI Canvas Polyfill (1.0.9) + * HiDPI Canvas Polyfill (1.0.10) * * 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 + * License: Apache-2.0 */ (function(prototype) { diff --git a/dist/hidpi-canvas.min.js b/dist/hidpi-canvas.min.js new file mode 100644 index 0000000..5447c71 --- /dev/null +++ b/dist/hidpi-canvas.min.js @@ -0,0 +1,9 @@ +/** + * HiDPI Canvas Polyfill (1.0.10) + * + * 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(){var a=document.createElement("canvas"),b=a.getContext("2d"),c=b.backingStorePixelRatio||b.webkitBackingStorePixelRatio||b.mozBackingStorePixelRatio||b.msBackingStorePixelRatio||b.oBackingStorePixelRatio||b.backingStorePixelRatio||1;return(window.devicePixelRatio||1)/c}(),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 c604fcc..b20aee3 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.9", + "version": "1.0.10", "license": "Apache-2.0", "homepage": "https://github.com/jondavidjohn/hidpi-canvas-polyfill", "bugs": "https://github.com/jondavidjohn/hidpi-canvas-polyfill/issues",