基于自定义范围的色标?以十六进制表示?
如何以十六进制理想方式创建自定义色标?比如说从黄色到红色,取决于物体的高度?这是实现此目的的正确方法还是有更好的方法而无需最后进行转换?:
var r:int = 255;
var b:int = 0;
var maxHeight:int = 52;
var minHeight:int = 21;
var scale:int = 255 / (maxHeight-minHeight);
var g:int = 255 - ((object.height-minHeight) * scale);
var hexColor:uint = RGBtoHEX(r,g,b);
private function RGBtoHEX(r:int, g:int, b:int) :uint
{
return r << 16 | g << 8 | b;
}
How do I create a custom colour scale ideally in Hex? say from yellow to red, depending on the height of an object? is this a correct way to achieve this or is there a better way without having to convert it at the end?:
var r:int = 255;
var b:int = 0;
var maxHeight:int = 52;
var minHeight:int = 21;
var scale:int = 255 / (maxHeight-minHeight);
var g:int = 255 - ((object.height-minHeight) * scale);
var hexColor:uint = RGBtoHEX(r,g,b);
private function RGBtoHEX(r:int, g:int, b:int) :uint
{
return r << 16 | g << 8 | b;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个函数,可让您根据 0-1 范围查找其他两个颜色值之间的颜色值。我认为它会满足你的需求
Here is a function that allows you to find a colour value between two others based on a range of 0-1. I think it will meet your needs