forked from GithubMirrors/cardconjurer
improved unstable margins / preserve opacity
This commit is contained in:
@@ -337,9 +337,11 @@ function drawFrames() {
|
||||
//manually blends colors, basing blending-alpha on the masks and desired draw-opacity, but preserving alpha
|
||||
for (var i = 0; i < existingPixels.length; i += 4) {
|
||||
const functionalAlpha = maskPixels[i + 3] * functionalAlphaMultiplier //functional alpha = alpha ignoring source image
|
||||
existingPixels[ i ] = existingPixels[ i ] * (1 - functionalAlpha) + newPixels[ i ] * functionalAlpha; //RED
|
||||
existingPixels[i + 1] = existingPixels[i + 1] * (1 - functionalAlpha) + newPixels[i + 1] * functionalAlpha; //GREEN
|
||||
existingPixels[i + 2] = existingPixels[i + 2] * (1 - functionalAlpha) + newPixels[i + 2] * functionalAlpha; //BLUE
|
||||
if (newPixels[i + 3] > 0) { //Only blend if the new image has alpha
|
||||
existingPixels[ i ] = existingPixels[ i ] * (1 - functionalAlpha) + newPixels[ i ] * functionalAlpha; //RED
|
||||
existingPixels[i + 1] = existingPixels[i + 1] * (1 - functionalAlpha) + newPixels[i + 1] * functionalAlpha; //GREEN
|
||||
existingPixels[i + 2] = existingPixels[i + 2] * (1 - functionalAlpha) + newPixels[i + 2] * functionalAlpha; //BLUE
|
||||
}
|
||||
}
|
||||
frameContext.putImageData(existingData, 0, 0);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user