From 6a396b89dba22004820fe1089705b2a182de8412 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 15 Apr 2013 11:54:49 +0300 Subject: improve dye file. --- src/resources/dye.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/resources/dye.cpp') diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp index 13b635d45..bfe9145bc 100644 --- a/src/resources/dye.cpp +++ b/src/resources/dye.cpp @@ -94,12 +94,13 @@ void DyePalette::getColor(const int intensity, int color[3]) const return; } - int last = static_cast(mColors.size()); + const int last = static_cast(mColors.size()); if (last == 0) return; - const int i = intensity * last / 255; - const int t = intensity * last % 255; + const int intLast = intensity * last; + const int i = intLast / 255; + const int t = intLast % 255; int j = t != 0 ? i : i - 1; @@ -148,7 +149,7 @@ void DyePalette::getColor(double intensity, int color[3]) const intensity = 0.0; // Scale up - intensity = intensity * static_cast(mColors.size() - 1); + intensity *= static_cast(mColors.size() - 1); // Color indices const int i = static_cast(floor(intensity)); -- cgit v1.2.3-70-g09d2