From 27c74225156bece1511140a69318823e465c082f Mon Sep 17 00:00:00 2001 From: bessw <56679598+bessw@users.noreply.github.com> Date: Tue, 2 Mar 2021 20:31:31 +0100 Subject: [PATCH 1/2] fixed clear() if window.devicePixelRatio isn't 1 fixed clear() in Scene and Hit to clear the full canvas also in case window.devicePixelRatio isn't 1 --- build/concrete.js | 8 ++++---- build/concrete.min.js | 6 +++--- src/concrete.js | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build/concrete.js b/build/concrete.js index 2842bce..5dfc2b4 100644 --- a/build/concrete.js +++ b/build/concrete.js @@ -2,11 +2,11 @@ * Concrete v3.0.6 * A lightweight Html5 Canvas framework that enables hit detection, layering, multi buffering, * pixel ratio management, exports, and image downloads - * Release Date: 6-29-2020 + * Release Date: 3-2-2021 * https://github.com/ericdrowell/concrete * Licensed under the MIT or GPL Version 2 licenses. * - * Copyright (C) 2020 Eric Rowell @ericdrowell + * Copyright (C) 2021 Eric Rowell @ericdrowell * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -367,7 +367,7 @@ Concrete.Scene.prototype = { clear: function() { var context = this.context; if (this.contextType === '2d') { - context.clearRect(0, 0, this.width * Concrete.PIXEL_RATIO, this.height * Concrete.PIXEL_RATIO); + context.clearRect(0, 0, this.width, this.height); } // webgl or webgl2 else { @@ -480,7 +480,7 @@ Concrete.Hit.prototype = { clear: function() { var context = this.context; if (this.contextType === '2d') { - context.clearRect(0, 0, this.width * Concrete.PIXEL_RATIO, this.height * Concrete.PIXEL_RATIO); + context.clearRect(0, 0, this.width, this.height); } // webgl or webgl2 else { diff --git a/build/concrete.min.js b/build/concrete.min.js index 978719c..e63b866 100644 --- a/build/concrete.min.js +++ b/build/concrete.min.js @@ -2,11 +2,11 @@ * Concrete v3.0.6 * A lightweight Html5 Canvas framework that enables hit detection, layering, multi buffering, * pixel ratio management, exports, and image downloads - * Release Date: 6-29-2020 + * Release Date: 3-2-2021 * https://github.com/ericdrowell/concrete * Licensed under the MIT or GPL Version 2 licenses. * - * Copyright (C) 2020 Eric Rowell @ericdrowell + * Copyright (C) 2021 Eric Rowell @ericdrowell * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -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.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((i=n.getImageData(t,e,1,1).data)[3]<255)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((i=n.getImageData(t,e,1,1).data)[3]<255)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/src/concrete.js b/src/concrete.js index 0c6347f..17fcb0f 100644 --- a/src/concrete.js +++ b/src/concrete.js @@ -339,7 +339,7 @@ Concrete.Scene.prototype = { clear: function() { var context = this.context; if (this.contextType === '2d') { - context.clearRect(0, 0, this.width * Concrete.PIXEL_RATIO, this.height * Concrete.PIXEL_RATIO); + context.clearRect(0, 0, this.width, this.height); } // webgl or webgl2 else { @@ -452,7 +452,7 @@ Concrete.Hit.prototype = { clear: function() { var context = this.context; if (this.contextType === '2d') { - context.clearRect(0, 0, this.width * Concrete.PIXEL_RATIO, this.height * Concrete.PIXEL_RATIO); + context.clearRect(0, 0, this.width, this.height); } // webgl or webgl2 else { From 4edb797cd990ccc3f25a528f018c58c197459dde Mon Sep 17 00:00:00 2001 From: bessw <56679598+bessw@users.noreply.github.com> Date: Wed, 3 Mar 2021 15:14:57 +0100 Subject: [PATCH 2/2] v3.0.7 --- build/concrete.js | 4 ++-- build/concrete.min.js | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build/concrete.js b/build/concrete.js index 5dfc2b4..71e938d 100644 --- a/build/concrete.js +++ b/build/concrete.js @@ -1,8 +1,8 @@ /* - * Concrete v3.0.6 + * Concrete v3.0.7 * A lightweight Html5 Canvas framework that enables hit detection, layering, multi buffering, * pixel ratio management, exports, and image downloads - * Release Date: 3-2-2021 + * Release Date: 3-3-2021 * https://github.com/ericdrowell/concrete * Licensed under the MIT or GPL Version 2 licenses. * diff --git a/build/concrete.min.js b/build/concrete.min.js index e63b866..bf229fe 100644 --- a/build/concrete.min.js +++ b/build/concrete.min.js @@ -1,8 +1,8 @@ /* - * Concrete v3.0.6 + * Concrete v3.0.7 * A lightweight Html5 Canvas framework that enables hit detection, layering, multi buffering, * pixel ratio management, exports, and image downloads - * Release Date: 3-2-2021 + * Release Date: 3-3-2021 * https://github.com/ericdrowell/concrete * Licensed under the MIT or GPL Version 2 licenses. * diff --git a/package.json b/package.json index ca75fe0..68c3e0f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "concretejs", - "version": "3.0.6", + "version": "3.0.7", "main": "build/concrete.min.js", "keywords": [ "html5",