Skip to content

Commit 1869991

Browse files
committed
charts: Clamp gradient color x between 0 and 1
1 parent cfa3ac5 commit 1869991

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

libs/charts/iAChartFunctionTransfer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void iAChartTransferFunction::draw(QPainter &painter, QColor color, int lineWidt
6363
int y1 = opacity2PixelY(opacityTFValue[1]);
6464

6565
QColor c; c.setRgbF(colorTFValue[1], colorTFValue[2], colorTFValue[3], 0.588);
66-
m_gradient.setColorAt(static_cast<double>(x1) / gradientWidth, c);
66+
m_gradient.setColorAt(std::clamp(static_cast<double>(x1) / gradientWidth, 0.0, 1.0), c);
6767

6868
int lastX = x1;
6969
for ( int i = 1; i < m_tf->opacityTF()->GetSize(); i++)
@@ -108,7 +108,7 @@ void iAChartTransferFunction::draw(QPainter &painter, QColor color, int lineWidt
108108

109109
painter.setPen(pen);
110110
c.setRgbF(colorTFValue[1], colorTFValue[2], colorTFValue[3], 0.588);
111-
m_gradient.setColorAt(static_cast<double>(x2) / gradientWidth, c);
111+
m_gradient.setColorAt(std::clamp(static_cast<double>(x2) / gradientWidth, 0.0, 1.0), c);
112112
x1 = x2;
113113
y1 = y2;
114114
}

0 commit comments

Comments
 (0)