我必须在Qt C++中绘制圆锥渐变,但我无法使用QConicalGradient。我确实有一个线性渐变,但我不知道如何制作一个圆锥渐变。我不想完成代码,但我要求一个简单的算法。Qt中的圆锥渐变(不含QConicalGradient)
for(int y = 0; y < image.height(); y++){
QRgb *line = (QRgb *)image.scanLine(y);
for(int x = 0; x < image.width(); x++){
QPoint currentPoint(x, y);
QPoint relativeToCenter = currentPoint - centerPoint;
float angle = atan2(relativeToCenter.y(), relativeToCenter.x);
// I have a problem in this line because I don't know how to set a color:
float hue = map(-M_PI, angle, M_PI, 0, 255);
line[x] = (red << 16) + (grn << 8) + blue;
}
}
你能帮助我吗?
*为什么*你不能使用'QConicalGradient'? – ecatmur 2013-03-11 17:21:53
因为我们必须实现您自己的绘图圆锥渐变版本 – 2013-03-11 17:56:20