public static EffectColor BlendColors(EffectColor background, EffectColor foreground, double percent) { EffectColor blend = new EffectColor(background); blend.BlendColors(foreground, percent); return(blend); }
public EffectColor(EffectColor color) { Red = color.Red; Green = color.Green; Blue = color.Blue; Alpha = color.Alpha; }
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 ); }
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); }
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); }
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 ); }