1
0
Fork 0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-07-03 12:06:31 +02:00

Changed rng interface to use colors instead of separate channels.

This commit is contained in:
kkapsner 2017-08-07 08:49:49 +02:00
parent 26457b2a7f
commit 921c7dbd5f
2 changed files with 60 additions and 6 deletions

View file

@ -68,6 +68,22 @@
// XOR the bit and the value to alter the last bit of it... or not
return value ^ bit;
};
},
getPixelRng: function(length, window, ignoredColors){
var rng = this.getRng(length, window);
return function(r, g, b, a, i){
var index = String.fromCharCode(r, g, b, a);
if (ignoredColors[index]){
return [r, g, b, a];
}
var baseIndex = i * 4;
return [
rng(r, baseIndex + 0),
rng(g, baseIndex + 1),
rng(b, baseIndex + 2),
rng(a, baseIndex + 3)
];
}
}
};
@ -92,6 +108,22 @@
// XOR the last bit to alter it... or not
return value ^ (rnd & 0x01);
};
},
getPixelRng: function(length, window, ignoredColors){
var rng = this.getRng(length, window);
return function(r, g, b, a, i){
var index = String.fromCharCode(r, g, b, a);
if (ignoredColors[index]){
return [r, g, b, a];
}
var baseIndex = i * 4;
return [
rng(r, baseIndex + 0),
rng(g, baseIndex + 1),
rng(b, baseIndex + 2),
rng(a, baseIndex + 3)
];
}
}
};
}());