我正试图与全球移民与发展公司一道执行从C++的平时起的梯度。 我不想使用全球发展指数+或任何其他图表框架。 我想梯度方向(任意角)。
我在假体编码中的算法:
For each pixel in x dirrection
For each pixel in the y direction
current position = current pixel - centre //translate origin
rotate this pixel according to the given angle
scalingFactor =( rotated pixel + centre ) / extentDistance //translate origin back
rgbColor = startColor + scalingFactor(endColor - startColor)
范围 距离是指从试金星中心穿过线的长度,梯度等于梯度的角。
Ok so far so good. I can draw this and it looks nice. BUT unfortunately because of the rotation bit the rectangle corners have the wrong color. The result is perfect only for angle which are multiples of 90 degrees. The problem appears to be that the scaling factor doesn t scale over the entire size of the rectangle.
我不敢肯定,如果你不视而不谈我的问题,那真是难以解释。
If anyone can help or redirect me to some helpful material I d be grateful.