Skip to content

Commit 77cf6fb

Browse files
committed
fixed global color sensing - workaround for Chrome v119's canvas clipping bug
1 parent 0cda302 commit 77cf6fb

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

morphic.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,7 +1306,7 @@
13061306

13071307
/*jshint esversion: 11, bitwise: false*/
13081308

1309-
var morphicVersion = '2023-July-13';
1309+
var morphicVersion = '2023-November-07';
13101310
var modules = {}; // keep track of additional loaded modules
13111311
var useBlurredShadows = true;
13121312

@@ -12228,12 +12228,14 @@ WorldMorph.prototype.initRetina = function () {
1222812228

1222912229
WorldMorph.prototype.getGlobalPixelColor = function (point) {
1223012230
// answer the color at the given point.
12231-
var dta = this.worldCanvas.getContext('2d').getImageData(
12232-
point.x,
12233-
point.y,
12234-
1,
12235-
1
12236-
).data;
12231+
// first, create a new temporary canvas representing the fullImage
12232+
// and sample that one instead of the actual world canvas
12233+
// this slows things down but keeps Chrome from crashing
12234+
// in v119 in the Fall of 2023
12235+
var dta = Morph.prototype.fullImage.call(this)
12236+
.getContext('2d')
12237+
.getImageData(point.x, point.y, 1, 1)
12238+
.data;
1223712239
return new Color(dta[0], dta[1], dta[2]);
1223812240
};
1223912241

0 commit comments

Comments
 (0)