mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-03 03:56:26 +02:00
Added "constant" rng.
This commit is contained in:
parent
4cb91462f7
commit
9da251b14d
6 changed files with 49 additions and 4 deletions
|
@ -75,7 +75,7 @@
|
|||
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),
|
||||
|
@ -87,6 +87,36 @@
|
|||
}
|
||||
};
|
||||
|
||||
scope.constant = {
|
||||
getRng: function(length, window){
|
||||
return scope.nonPersistent.getRng(length, window);
|
||||
},
|
||||
getPixelRng: (function(){
|
||||
var colors = Object.create(null);
|
||||
return function getConstantPixelRng(length, window, ignoredColors){
|
||||
var rng = scope.nonPersistent.getRng(1024, 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 color = colors[index];
|
||||
if (!color){
|
||||
color = [
|
||||
rng(r, 0),
|
||||
rng(g, 0),
|
||||
rng(b, 0),
|
||||
rng(a, 0)
|
||||
];
|
||||
colors[index] = color;
|
||||
}
|
||||
return color;
|
||||
};
|
||||
};
|
||||
}())
|
||||
};
|
||||
|
||||
scope.nonPersistent = {
|
||||
getRng: function(length, window){
|
||||
// Initialize the random number batch creation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue