Algorithm: How do I fade from Red to Green via Yellow using RGB values?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I want to display a color based on a value from 0 to 100. At one end (100), it's pure Red, the other end (0), pure Green. In the middle (50), I want it to be yellow. And I want the colors to fade gradually from one to another, such that at 75, the color is half red and half yellow, etc. How do I program the RGB values to reflect this fading? Thanks. 回答1: The RGB values for the colors: Red 255, 0, 0 Yellow 255, 255, 0 Green 0, 255, 0 Between Red and Yellow, equally space your additions to the green channel until it reaches 255.