1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-06-01 10:58:05 +02:00

Changed the way the random indices are chosen

Only the offset is random. The indices are then spaced evenly.
This commit is contained in:
kkapsner 2018-06-30 23:34:59 +02:00
parent b4a8507140
commit 22fda1eac7
2 changed files with 10 additions and 5 deletions

View File

@ -65,16 +65,21 @@
} }
function forEachIndex(array, prefs, callback){ function forEachIndex(array, prefs, callback){
var l = array.length; var length = array.length;
var rate = getAudioFakeRate(array, prefs); var rate = getAudioFakeRate(array, prefs);
var indexRng = randomSupply.getIndexRng(rate, l, window);
var start = 0; var start = 0;
forEachFixedIndex(prefs, function(index){ forEachFixedIndex(prefs, function(index){
callback(index, start); callback(index, start);
start += 1; start += 1;
}); });
for (var i = start; i < rate; i += 1){ if (start < rate){
callback(indexRng(i), i); var delta = Math.floor(length / (rate - start));
var indexRng = randomSupply.getIndexRng(1, length - delta * (rate - start - 1), window);
var offset = indexRng(0);
for (var i = start; i < rate; i += 1){
callback(offset, i);
offset += delta;
}
} }
} }

View File

@ -169,7 +169,7 @@
}, },
{ {
name: "audioFakeRate", name: "audioFakeRate",
defaultValue: "10", defaultValue: "100",
options: ["1", "10", "100", "1000", "0.1%", "1%"] options: ["1", "10", "100", "1000", "0.1%", "1%"]
}, },
{ {