diff options
| author | raysan5 <[email protected]> | 2020-06-20 23:32:32 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2020-06-20 23:32:32 +0200 |
| commit | e18c4c1158752ae29726eb164006d22de24a6c7e (patch) | |
| tree | 7c03ed6e9823d1b2e7581818f6c55e69f486d640 /src/textures.c | |
| parent | 6b94ce2204431c33f93cf4888092b725c3b402ec (diff) | |
| download | raylib-e18c4c1158752ae29726eb164006d22de24a6c7e.tar.gz raylib-e18c4c1158752ae29726eb164006d22de24a6c7e.zip | |
REVIEWED: ColorAlphaBlend(), support tint color
Diffstat (limited to 'src/textures.c')
| -rw-r--r-- | src/textures.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/textures.c b/src/textures.c index ee3f0ab4..8f93383e 100644 --- a/src/textures.c +++ b/src/textures.c @@ -3388,18 +3388,15 @@ Color ColorAlphaBlend(Color dst, Color src, Color tint) { Color out = WHITE; - // TODO: Compute tint color over source properly (before alpha blending) - + // Apply color tint to source color + src.r = (unsigned char)(((unsigned int)src.r*(unsigned int)tint.r) >> 8); + src.g = (unsigned char)(((unsigned int)src.g*(unsigned int)tint.g) >> 8); + src.b = (unsigned char)(((unsigned int)src.b*(unsigned int)tint.b) >> 8); + src.a = (unsigned char)(((unsigned int)src.a*(unsigned int)tint.a) >> 8); + //#define COLORALPHABLEND_FLOAT #define COLORALPHABLEND_INTEGERS #if defined(COLORALPHABLEND_INTEGERS) - // Apply color tint to source color - // NOTE: Some problems when aplying source tinting - //src.r = (unsigned char)(((unsigned int)src.r*(unsigned int)tint.r) >> 8); - //src.g = (unsigned char)(((unsigned int)src.g*(unsigned int)tint.g) >> 8); - //src.b = (unsigned char)(((unsigned int)src.b*(unsigned int)tint.b) >> 8); - //src.a = (unsigned char)(((unsigned int)src.a*255 + (unsigned int)tint.a*(255 - src.a)) >> 8); - if (src.a == 0) out = dst; else if (src.a == 255) out = src; else @@ -3416,9 +3413,6 @@ Color ColorAlphaBlend(Color dst, Color src, Color tint) } #endif #if defined(COLORALPHABLEND_FLOAT) - // Apply color tint to source color - //fsrc.x *= ftint.x; fsrc.y *= ftint.y; fsrc.z *= ftint.z; fsrc.w *= ftint.w; - if (src.a == 0) out = dst; else if (src.a == 255) out = src; else |
