HSLColor.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ConsoleApplication
  7. {
  8. public class HSLColor
  9. {
  10. double _hue, _saturation, _luminance;
  11. public HSLColor()
  12. {
  13. _hue = 0;
  14. _saturation = 0;
  15. _luminance = 0;
  16. }
  17. public double Hue
  18. {
  19. get { return _hue; }
  20. set
  21. {
  22. _hue = value;
  23. _hue = _hue > 1 ? 1 : _hue < 0 ? 0 : _hue;
  24. }
  25. }
  26. public double Saturation
  27. {
  28. get { return _saturation; }
  29. set
  30. {
  31. _saturation = value;
  32. _saturation = _saturation > 1 ? 1 : _saturation < 0 ? 0 : _saturation;
  33. }
  34. }
  35. public double Luminance
  36. {
  37. get { return _luminance; }
  38. set
  39. {
  40. _luminance = value;
  41. _luminance = _luminance > 1 ? 1 : _luminance < 0 ? 0 : _luminance;
  42. }
  43. }
  44. public string toString()
  45. {
  46. return "\n H: " + Hue + "\n S: " + Saturation + "\n L: " + Luminance + "\n";
  47. }
  48. }
  49. }