summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-15 11:54:49 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-15 11:54:49 +0300
commit6a396b89dba22004820fe1089705b2a182de8412 (patch)
treefa3515bfd295bef588b34170ed6cf14ec1d3f391
parent2906bc28196a1b60406f10cb0c4ceed2366041b4 (diff)
downloadplus-6a396b89dba22004820fe1089705b2a182de8412.tar.gz
plus-6a396b89dba22004820fe1089705b2a182de8412.tar.bz2
plus-6a396b89dba22004820fe1089705b2a182de8412.tar.xz
plus-6a396b89dba22004820fe1089705b2a182de8412.zip
improve dye file.
-rw-r--r--src/resources/dye.cpp9
1 files changed, 5 insertions, 4 deletions
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<int>(mColors.size());
+ const int last = static_cast<int>(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<double>(mColors.size() - 1);
+ intensity *= static_cast<double>(mColors.size() - 1);
// Color indices
const int i = static_cast<int>(floor(intensity));