Optimized lasso tool selection

This commit is contained in:
Nicola
2022-01-05 12:20:51 +01:00
parent e139a6cc41
commit 4179393e91
2 changed files with 14 additions and 13 deletions

View File

@ -86,4 +86,13 @@ class Util {
static toggle(elementId) {
Util.getElement(elementId).classList.toggle('selected');
}
static getPixelColor(data, x, y, dataWidth) {
let pos = (y * dataWidth + x) * 4;
return [data[pos], data[pos+1], data[pos+2], data[pos + 3]];
}
static isPixelTransparent(data, x, y, dataWidth) {
return this.getPixelColor(data, x, y, dataWidth)[3] == 255;
}
}