diff --git a/build/concrete.js b/build/concrete.js index 07aad07..41f3f9e 100644 --- a/build/concrete.js +++ b/build/concrete.js @@ -2,7 +2,7 @@ * Concrete v3.0.4 * A lightweight Html5 Canvas framework that enables hit detection, layering, multi buffering, * pixel ratio management, exports, and image downloads - * Release Date: 4-21-2019 + * Release Date: 4-22-2019 * https://github.com/ericdrowell/concrete * Licensed under the MIT or GPL Version 2 licenses. * @@ -29,15 +29,8 @@ var Concrete = {}, idCounter = 0; -Concrete.PIXEL_RATIO = (function() { - // client browsers - if (window && window.navigator && window.navigator.userAgent && !/PhantomJS/.test(window.navigator.userAgent)) { - return 2; - } - // headless browsers - else { - return 1; - } +Concrete.PIXEL_RATIO = (function () { + return (window && window.devicePixelRatio) || 1; })(); Concrete.viewports = []; diff --git a/build/concrete.min.js b/build/concrete.min.js index d27b6d9..920a648 100644 --- a/build/concrete.min.js +++ b/build/concrete.min.js @@ -2,7 +2,7 @@ * Concrete v3.0.4 * A lightweight Html5 Canvas framework that enables hit detection, layering, multi buffering, * pixel ratio management, exports, and image downloads - * Release Date: 4-21-2019 + * Release Date: 4-22-2019 * https://github.com/ericdrowell/concrete * Licensed under the MIT or GPL Version 2 licenses. * @@ -26,4 +26,4 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ -var Concrete={},idCounter=0;Concrete.PIXEL_RATIO=window&&window.navigator&&window.navigator.userAgent&&!/PhantomJS/.test(window.navigator.userAgent)?2:1,Concrete.viewports=[],Concrete.Viewport=function(t){t||(t={}),this.container=t.container,this.layers=[],this.id=idCounter++,this.scene=new Concrete.Scene,this.setSize(t.width||0,t.height||0),t.container.innerHTML="",t.container.appendChild(this.scene.canvas),Concrete.viewports.push(this)},Concrete.Viewport.prototype={add:function(t){return this.layers.push(t),t.setSize(t.width||this.width,t.height||this.height),t.viewport=this},setSize:function(e,i){return this.width=e,this.height=i,this.scene.setSize(e,i),this.layers.forEach(function(t){t.setSize(e,i)}),this},getIntersection:function(t,e){var i,n,s=this.layers;for(i=s.length-1;0<=i;i--)if(0<=(n=s[i].hit.getIntersection(t,e)))return n;return-1},getIndex:function(){var t,e=Concrete.viewports,i=e.length,n=0;for(n=0;nthis.width||e>this.height)return-1;if("2d"===this.contextType){if(0===(i=n.getImageData(t,e,1,1).data)[3])return-1}else if(i=new Uint8Array(4),n.readPixels(t*Concrete.PIXEL_RATIO,(this.height-e-1)*Concrete.PIXEL_RATIO,1,1,n.RGBA,n.UNSIGNED_BYTE,i),255===i[0]&&255===i[1]&&255===i[2])return-1;return this.rgbToInt(i)},getColorFromIndex:function(t){var e=this.intToRGB(t);return"rgb("+e[0]+", "+e[1]+", "+e[2]+")"},rgbToInt:function(t){return(t[0]<<16)+(t[1]<<8)+t[2]},intToRGB:function(t){return[(16711680&t)>>16,(65280&t)>>8,255&t]}},function(t){"use strict";"function"==typeof define&&define.amd?define(function(){return Concrete}):"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=Concrete),exports.Concrete=Concrete):t.Concrete=Concrete}(this); \ No newline at end of file +var Concrete={},idCounter=0;Concrete.PIXEL_RATIO=window&&window.devicePixelRatio||1,Concrete.viewports=[],Concrete.Viewport=function(t){t||(t={}),this.container=t.container,this.layers=[],this.id=idCounter++,this.scene=new Concrete.Scene,this.setSize(t.width||0,t.height||0),t.container.innerHTML="",t.container.appendChild(this.scene.canvas),Concrete.viewports.push(this)},Concrete.Viewport.prototype={add:function(t){return this.layers.push(t),t.setSize(t.width||this.width,t.height||this.height),t.viewport=this},setSize:function(e,i){return this.width=e,this.height=i,this.scene.setSize(e,i),this.layers.forEach(function(t){t.setSize(e,i)}),this},getIntersection:function(t,e){var i,n,s=this.layers;for(i=s.length-1;0<=i;i--)if(0<=(n=s[i].hit.getIntersection(t,e)))return n;return-1},getIndex:function(){var t,e=Concrete.viewports,i=e.length,n=0;for(n=0;nthis.width||e>this.height)return-1;if("2d"===this.contextType){if(0===(i=n.getImageData(t,e,1,1).data)[3])return-1}else if(i=new Uint8Array(4),n.readPixels(t*Concrete.PIXEL_RATIO,(this.height-e-1)*Concrete.PIXEL_RATIO,1,1,n.RGBA,n.UNSIGNED_BYTE,i),255===i[0]&&255===i[1]&&255===i[2])return-1;return this.rgbToInt(i)},getColorFromIndex:function(t){var e=this.intToRGB(t);return"rgb("+e[0]+", "+e[1]+", "+e[2]+")"},rgbToInt:function(t){return(t[0]<<16)+(t[1]<<8)+t[2]},intToRGB:function(t){return[(16711680&t)>>16,(65280&t)>>8,255&t]}},function(t){"use strict";"function"==typeof define&&define.amd?define(function(){return Concrete}):"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=Concrete),exports.Concrete=Concrete):t.Concrete=Concrete}(this); \ No newline at end of file diff --git a/package.json b/package.json index 46b8d26..076edb6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "concretejs", - "version": "3.0.4", + "version": "3.0.5", "main": "build/concrete.min.js", "keywords": [ "html5", diff --git a/src/concrete.js b/src/concrete.js index ef604c9..4c16d5f 100644 --- a/src/concrete.js +++ b/src/concrete.js @@ -1,16 +1,9 @@ var Concrete = {}, idCounter = 0; -Concrete.PIXEL_RATIO = (function(win) { - // client browsers - if (win && win.navigator && win.navigator.userAgent && !/PhantomJS/.test(win.navigator.userAgent)) { - return 2; - } - // headless browsers - else { - return 1; - } -})(typeof window !== 'undefined' ? window : null); +Concrete.PIXEL_RATIO = (function () { + return (window && window.devicePixelRatio) || 1; +})(); Concrete.viewports = [];