编程语言

img flashvan

无聊的ColorTransform

发表于2004/10/28 17:25:00  2106人阅读

 
class com.flashvan.drawing.ColorTransform
{
        private var _color:Color;
        private var _target:MovieClip;
        
        public var ra,rb,ga,gb,ba,bb,aa,ab:Number;
        
        function ColorTransform(transform:Array,target:MovieClip)
        {
                _target = target;
                _color = new Color(_target);
                ra = transform[0];
                rb = transform[1];
                ga = transform[2];
                gb = transform[3];
                ba = transform[4];
                bb = transform[5];
                aa = transform[6];
                ab = transform[7];
        };
        
        public function run():Void
        {
                if(_target!= null)
                _color.setTransform(this);
        }
        
        public function reset():Void
        {
                Transform = [100,0,100,0,100,0,100,0];
                _color.setTransform(this);
        }
        
        public function get Target():MovieClip
        {
                return _target;
        }
        
        public function set Target(value:MovieClip):Void
        {
                _target = value;
                _color = new Color(_target);
        }
        
        public function set Transform(transform:Array):Void
        {
                ra = transform[0];
                rb = transform[1];
                ga = transform[2];
                gb = transform[3];
                ba = transform[4];
                bb = transform[5];
                aa = transform[6];
                ab = transform[7];
        }
        
        public function get Transform():Array
        {
                return [ra,rb,ga,gb,ba,bb,aa,ab];
        }
};
做效果用, 封装了一下, 省得麻烦 :D 另外还有一个ColorConverter.主要是RGBToHSB和HSBToRGB
用法:
 
import com.flashvan.drawing.ColorTransform;
var ct:ColorTransform = new ColorTransform([100, 244, 100, 0,100, 0,100, 0],mc);
ct.run();
阅读全文
0 0

相关文章推荐

img
取 消
img