Merge pull request #10506 from hpvb/fix-10501

Fix color_ramp indexing negative elements
This commit is contained in:
Rémi Verschelde 2017-08-21 22:27:34 +02:00 committed by GitHub
commit bb41e1427e

View file

@ -149,7 +149,7 @@ void Gradient::set_offset(int pos, const float offset) {
}
float Gradient::get_offset(int pos) const {
if (points.size() > pos)
if (points.size() && points.size() > pos)
return points[pos].offset;
return 0; //TODO: Maybe throw some error instead?
}
@ -164,7 +164,7 @@ void Gradient::set_color(int pos, const Color &color) {
}
Color Gradient::get_color(int pos) const {
if (points.size() > pos)
if (points.size() && points.size() > pos)
return points[pos].color;
return Color(0, 0, 0, 1); //TODO: Maybe throw some error instead?
}