1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2025-01-30 23:38:47 +01:00

constant rng did not work properly when protecting input

This commit is contained in:
kkapsner 2018-10-23 23:39:47 +02:00
parent 8b9197a68a
commit 045379c349
2 changed files with 19 additions and 9 deletions

View File

@ -127,15 +127,25 @@
var data2 = imageData2.data;
var l = data1.length;
if (l === data2.length){
var rng = randomSupply.getValueRng(l, window);
var rng = randomSupply.getPixelRng(l, window, {});
for (var i = 0; i < l; i += 1){
if (data1[i] > data2[i]){
data2[i] = data1[i] - rng(data1[i] - data2[i], i);
}
else if (data1[i] < data2[i]){
data2[i] = data1[i] + rng(data2[i] - data1[i], i);
}
for (var i = 0; i < l; i += 4){
const signR = data1[i + 0] > data2[i + 0]? -1: 1;
const signG = data1[i + 1] > data2[i + 1]? -1: 1;
const signB = data1[i + 2] > data2[i + 2]? -1: 1;
const signA = data1[i + 3] > data2[i + 3]? -1: 1;
var [deltaR, deltaG, deltaB, deltaA] = rng(
signR * (data2[i + 0] - data1[i + 0]),
signG * (data2[i + 1] - data1[i + 1]),
signB * (data2[i + 2] - data1[i + 2]),
signA * (data2[i + 3] - data1[i + 3]),
i / 4
);
data2[i + 0] = data1[i + 0] + signR * deltaR;
data2[i + 1] = data1[i + 1] + signG * deltaG;
data2[i + 2] = data1[i + 2] + signB * deltaB;
data2[i + 3] = data1[i + 3] + signA * deltaA;
}
}
return imageData2;

View File

@ -10,7 +10,7 @@ Version 0.5.6:
- added setting "protected canvas part" to decouple block mode from part
fixes:
-
- constant rng did not work properly when protecting input
known issues:
- if a data URL is blocked the page action button does not appear