Skip to content

Commit 7f24f3c

Browse files
authored
fix gaussian-blur input data (#207)
The current buffer initialisation results in a 0-filled buffer. Changing the rand function to return a 32bit int solves the problem.
1 parent 79f1467 commit 7f24f3c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

SeaMonster/gaussian-blur.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class Benchmark {
225225
this.height = 450;
226226
this.radius = 15;
227227

228-
const rand = (function() {
228+
const randUint32 = (function() {
229229
let seed = 49734321;
230230
return function() {
231231
// Robert Jenkins' 32 bit integer hash function.
@@ -235,13 +235,13 @@ class Benchmark {
235235
seed = ((seed + 0xd3a2646c) ^ (seed << 9)) & 0xffffffff;
236236
seed = ((seed + 0xfd7046c5) + (seed << 3)) & 0xffffffff;
237237
seed = ((seed ^ 0xb55a4f09) ^ (seed >>> 16)) & 0xffffffff;
238-
return (seed & 0xfffffff) / 0x10000000;
238+
return (seed & 0xfffffff);
239239
};
240240
})();
241241

242242
const buffer = new Uint32Array(this.width * this.height);
243243
for (let i = 0; i < buffer.length; ++i)
244-
buffer[i] = rand();
244+
buffer[i] = randUint32();
245245

246246
this.buffer = buffer;
247247
}

0 commit comments

Comments
 (0)