/// <summary> /// Returns true if both colors are the same. /// </summary> /// <param name="obj"></param> /// <returns></returns> public override bool Equals(object obj) { if (!(obj is THSLColor)) { return(false); } THSLColor o = (THSLColor)obj; return(FHue == o.FHue && FSat == o.FSat && FLum == o.FLum); }
private Color ApplyTint(Color aColor) { if (Tint == 0) { return(aColor); //so we don't create a new one. } THSLColor Hsl = aColor; double NewBrightness = THSLColor.ApplyTint(Hsl.Lum, Tint); return(new THSLColor(Hsl.Hue, Hsl.Sat, NewBrightness)); }
/// <summary> /// Returns -1 if obj is more than color, 0 if both colors are the same, and 1 if obj is less than color. /// </summary> /// <param name="obj"></param> /// <returns></returns> public int CompareTo(object obj) { if (!(obj is THSLColor)) { return(-1); } THSLColor o2 = (THSLColor)obj; int c; c = FHue.CompareTo(o2.FHue); if (c != 0) { return(c); } c = FSat.CompareTo(o2.FSat); if (c != 0) { return(c); } c = FLum.CompareTo(o2.FLum); if (c != 0) { return(c); } return(0); }