blob: 24b3a77a4c31399abbc1da7c201c0b12278092fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
function makePattern(len, start, inc) {
var pattern = [];
while (len) {
pattern.push(start);
start = (start + inc) % 256;
--len;
}
return pattern;
}
function setPattern(imageData, pattern) {
if (pattern.length != imageData.data.length) {
throw Error("Invalid pattern");
}
for (var i = 0; i < pattern.length; ++i) {
imageData.data[i] = pattern[i];
}
}
function checkPattern(imageData, pattern) {
if (pattern.length != imageData.data.length) {
throw Error("Invalid pattern");
}
for (var i = 0; i < pattern.length; ++i) {
if (imageData.data[i] != pattern[i]) {
return false;
}
}
return true;
}
|