Fix fillRect alpha on canvas-based image (close #638)

This commit is contained in:
Joshua Granick
2017-06-01 21:38:58 -07:00
parent 1a5462b93f
commit 74dc959012

View File

@@ -283,8 +283,18 @@ class ImageCanvasUtil {
} }
image.buffer.__srcContext.fillStyle = 'rgba(' + r + ', ' + g + ', ' + b + ', ' + (a / 255) + ')'; if (a < 255) {
image.buffer.__srcContext.fillRect (rect.x + image.offsetX, rect.y + image.offsetY, rect.width + image.offsetX, rect.height + image.offsetY);
image.buffer.__srcContext.clearRect (rect.x + image.offsetX, rect.y + image.offsetY, rect.width + image.offsetX, rect.height + image.offsetY);
}
if (a > 0) {
image.buffer.__srcContext.fillStyle = 'rgba(' + r + ', ' + g + ', ' + b + ', ' + (a / 255) + ')';
image.buffer.__srcContext.fillRect (rect.x + image.offsetX, rect.y + image.offsetY, rect.width + image.offsetX, rect.height + image.offsetY);
}
image.dirty = true; image.dirty = true;
image.version++; image.version++;