mirror of
https://github.com/kkapsner/CanvasBlocker
synced 2025-07-04 12:36:37 +02:00
Added "constant" rng.
This commit is contained in:
parent
4cb91462f7
commit
9da251b14d
6 changed files with 49 additions and 4 deletions
|
@ -7,7 +7,7 @@ var settings = {
|
|||
blockMode: "fakeReadout",
|
||||
minFakeSize: 1,
|
||||
maxFakeSize: 0,
|
||||
rng: "nonPersistent",
|
||||
rng: "constant",
|
||||
persistentRndStorage: "",
|
||||
storePersistentRnd: false,
|
||||
askOnlyOnce: true,
|
||||
|
|
|
@ -25,6 +25,9 @@
|
|||
case "persistent":
|
||||
setRandomSupply(randomSupplies.persistent);
|
||||
break;
|
||||
case "constant":
|
||||
setRandomSupply(randomSupplies.constant);
|
||||
break;
|
||||
default:
|
||||
setRandomSupply(randomSupplies.nonPersistent);
|
||||
}
|
||||
|
|
|
@ -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