ActionScript 3 AS3:插值颜色

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 AS3:插值颜色相关的知识,希望对你有一定的参考价值。

//
//found at http://www.actionscript.org/forums/showpost.php3?p=794474&postcount=4
//
public static function interpolateColor(fromColor:uint, toColor:uint, progress:Number):uint
		{
			var q:Number = 1-progress;
			var fromA:uint = (fromColor >> 24) & 0xFF;
			var fromR:uint = (fromColor >> 16) & 0xFF;
			var fromG:uint = (fromColor >>  8) & 0xFF;
			var fromB:uint =  fromColor        & 0xFF;
			var toA:uint = (toColor >> 24) & 0xFF;
			var toR:uint = (toColor >> 16) & 0xFF;
			var toG:uint = (toColor >>  8) & 0xFF;
			var toB:uint =  toColor        & 0xFF;
			var resultA:uint = fromA*q + toA*progress;
			var resultR:uint = fromR*q + toR*progress;
			var resultG:uint = fromG*q + toG*progress;
			var resultB:uint = fromB*q + toB*progress;
			var resultColor:uint = resultA << 24 | resultR << 16 | resultG << 8 | resultB;
			return resultColor;
			}

以上是关于ActionScript 3 AS3:插值颜色的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 AS3 RGB颜色(对象)到HSB颜色(对象)

ActionScript 3 AS3 HSB颜色(对象)到RGB颜色(对象)

ActionScript 3 AS3获取图像的平均颜色

ActionScript 3 AS3 RGB颜色到十六进制颜色(uint)

ActionScript 3 AS3 CSS颜色(字符串)到RGB颜色(对象)

ActionScript 3 AS3十六进制颜色(uint)到RGB颜色(对象)