ColorHSL.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace TEAMModelOS.Test.PPTX.ColorLibrary
  5. {
  6. /// <summary>
  7. /// 类 名:ColorHSL
  8. /// 功 能:H 色相 \ S 饱和度(纯度) \ L 亮度 颜色模型
  9. /// </summary>
  10. public class ColorHSL
  11. {
  12. public ColorHSL(int h, int s, int l)
  13. {
  14. this._h = h;
  15. this._s = s;
  16. this._l = l;
  17. }
  18. private int _h;
  19. private int _s;
  20. private int _l;
  21. /// <summary>
  22. /// 色相
  23. /// </summary>
  24. public int H
  25. {
  26. get { return this._h; }
  27. set
  28. {
  29. this._h = value;
  30. this._h = this._h > 360 ? 360 : this._h;
  31. this._h = this._h < 0 ? 0 : this._h;
  32. }
  33. }
  34. /// <summary>
  35. /// 饱和度(纯度)
  36. /// </summary>
  37. public int S
  38. {
  39. get { return this._s; }
  40. set
  41. {
  42. this._s = value;
  43. this._s = this._s > 255 ? 255 : this._s;
  44. this._s = this._s < 0 ? 0 : this._s;
  45. }
  46. }
  47. /// <summary>
  48. /// 饱和度
  49. /// </summary>
  50. public int L
  51. {
  52. get { return this._l; }
  53. set
  54. {
  55. this._l = value;
  56. this._l = this._l > 255 ? 255 : this._l;
  57. this._l = this._l < 0 ? 0 : this._l;
  58. }
  59. }
  60. }
  61. }