Ejemplo n.º 1
0
        public static EffectColor BlendColors(EffectColor background, EffectColor foreground, double percent)
        {
            EffectColor blend = new EffectColor(background);

            blend.BlendColors(foreground, percent);
            return(blend);
        }
Ejemplo n.º 2
0
 public EffectColor(EffectColor color)
 {
     Red   = color.Red;
     Green = color.Green;
     Blue  = color.Blue;
     Alpha = color.Alpha;
 }
Ejemplo n.º 3
0
        public bool Equals(EffectColor color)
        {
            if ((object)color == null)
            {
                return(false);
            }

            // Return true if the fields match:
            return(Red == color.Red &&
                   Green == color.Green &&
                   Blue == color.Blue &&
                   Alpha == color.Alpha
                   );
        }
Ejemplo n.º 4
0
        public void BlendColors(EffectColor foreground, double percent)
        {
            if (percent < 0.0)
            {
                percent = 0.0;
            }
            else if (percent > 1.0)
            {
                percent = 1.0;
            }

            this.Red   = (byte)Math.Min((Int32)foreground.Red * percent + (Int32)this.Red * (1.0 - percent), 255);
            this.Green = (byte)Math.Min((Int32)foreground.Green * percent + (Int32)this.Green * (1.0 - percent), 255);
            this.Blue  = (byte)Math.Min((Int32)foreground.Blue * percent + (Int32)this.Blue * (1.0 - percent), 255);
            this.Alpha = (byte)Math.Min((Int32)foreground.Alpha * percent + (Int32)this.Alpha * (1.0 - percent), 255);
        }
Ejemplo n.º 5
0
        public static EffectColor operator +(EffectColor color1, EffectColor color2)
        {
            if ((object)color1 == null)
            {
                return(color2);
            }

            if ((object)color2 == null)
            {
                return(color1);
            }

            EffectColor blend = new EffectColor(color1);

            blend.BlendColors(color2, color2.Alpha / 255.0);
            return(blend);
        }
Ejemplo n.º 6
0
        public override bool Equals(System.Object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            EffectColor col = obj as EffectColor;

            if ((System.Object)col == null)
            {
                return(false);
            }

            return(Red == col.Red &&
                   Green == col.Green &&
                   Blue == col.Blue &&
                   Alpha == col.Alpha
                   );
        }