我必須在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