显示渐变上某个位置的颜色
我使用 Kinect 在桌子上测量双手的身高,并在屏幕上显示由身高比例确定的颜色。例如,如果 handProportion = 0.5,屏幕将为绿色。在任何其他比例下,屏幕都是红色的。但是,我需要绿色才能顺利过渡到红色。
我的第一直觉是颜色位移,但这听起来很复杂。如何编写一个函数,根据渐变中的位置值显示渐变中的颜色?
谢谢你!
Using the Kinect, I'm taking height measurements of both hands from a table, and displaying a color on the screen that's determined by the proportion of the heights. For example, if handProportion = .5, the screen would be green. At any other proportion, the screen is red. However, I need green to transition smoothly into red.
My first instinct is color bitshifting, but that sounds complicated. How can I write a function that displays a color from a gradient based on a position value in that gradient?
Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎您需要在给定比例的两种颜色之间进行插值:
.NET 中 3 种颜色之间的颜色插值
It seems like you need to interpolate between two colors given a ratio:
Color Interpolation Between 3 Colors in .NET