fix(ramp): Evenly distribute states (#1340)

Fixes #1328
This commit is contained in:
memeplex 2018-07-23 10:42:42 -03:00 committed by Patrick Ziegler
parent 934e277ccd
commit 1808ca3c51

View file

@ -14,7 +14,7 @@ namespace drawtypes {
} }
icon_t ramp::get_by_percentage(float percentage) { icon_t ramp::get_by_percentage(float percentage) {
size_t index = percentage * (m_icons.size() - 1) / 100.0f + 0.5f; size_t index = percentage * m_icons.size() / 100.0f;
return m_icons[math_util::cap<size_t>(index, 0, m_icons.size() - 1)]; return m_icons[math_util::cap<size_t>(index, 0, m_icons.size() - 1)];
} }