Skip to content

Commit

Permalink
Merge pull request #23 from arceusVen1/better_alpha_handler
Browse files Browse the repository at this point in the history
better_alpha_handler
  • Loading branch information
arceusVen1 authored Apr 20, 2024
2 parents 37dce30 + 8c5bcf0 commit f945dd1
Showing 1 changed file with 9 additions and 29 deletions.
38 changes: 9 additions & 29 deletions lib/classes/texture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,40 +59,20 @@ class ModelTexture {

void applyAttributesToTexture(
img.Image imageToProcess, Color fillingColor, Color? partyColor) {
if (attribute.useHardAlpha) {
for (final frame in imageToProcess.frames) {
for (final p in frame) {
p.a = p.a < 127 ? 0 : p.a;

for (final frame in imageToProcess.frames) {
for (final p in frame) {
if (attribute.useHardAlpha) {
p.a = p.a <= 126 ? 0 : 255;
}
}
}
if (!attribute.useSoftAlpha && !attribute.useHardAlpha) {
for (final frame in imageToProcess.frames) {
for (final p in frame) {
if (p.r == 0 && p.g == 0 && p.b == 0) {
p.setRgba(
fillingColor.red,
fillingColor.green,
fillingColor.blue,
fillingColor.alpha,
);
} else {
p.a = p.a > 0 ? 255 : 0;
}
if (!attribute.useSoftAlpha && !attribute.useHardAlpha) {
p.a = 255;
}
}
}

if (attribute.usePlayerColor && partyColor != null) {
for (final frame in imageToProcess.frames) {
for (final p in frame) {
if (p.r == 0 && p.g == 0 && p.b == 0) {
continue;
}

if (attribute.usePlayerColor && partyColor != null && p.a != 0) {
p.r = partyColor.red;
p.g = partyColor.green;
p.b = partyColor.blue;
p.a = partyColor.alpha;
}
}
}
Expand Down

0 comments on commit f945dd1

Please sign in to comment.