mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
26 lines
624 B
JavaScript
26 lines
624 B
JavaScript
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;
|
|
}
|