Skip to content

Commit

Permalink
drawString color should use color alpha
Browse files Browse the repository at this point in the history
  • Loading branch information
brendan-duncan committed Apr 21, 2024
1 parent 8889d7e commit 78a7ffd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/src/draw/draw_pixel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ Image drawPixel(Image image, int x, int y, Color c,
var overlayB =
filter != null ? c.bNormalized * filter.bNormalized : c.bNormalized;

final overlayA = (alpha ?? (c.length < 4 ? 1.0 : c.aNormalized)) * msk;
final a = (c.length < 4 ? 1.0 : c.aNormalized) *
((filter == null || filter.length < 4) ? 1.0 : filter.aNormalized);

final overlayA = (alpha ?? a) * msk;

if (overlayA == 0) {
return image;
Expand Down
2 changes: 1 addition & 1 deletion test/draw/draw_string_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void main() {
test('drawString', () {
final i0 = Image(width: 256, height: 256)..clear(ColorRgb8(128, 128, 0));
drawString(i0, "Hello",
font: arial24, x: 50, y: 50, color: ColorRgba8(255, 0, 0, 255));
font: arial24, x: 50, y: 50, color: ColorRgba8(255, 0, 0, 128));
drawString(i0, "Right Justified",
font: arial24, x: 200, y: 80, rightJustify: true);
drawString(i0, "Centered", font: arial24);
Expand Down

0 comments on commit 78a7ffd

Please sign in to comment.