ColorHSV.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace HTEXLib
  5. {
  6. /// <summary>
  7. /// 类 名:ColorHSV
  8. /// 功 能:H 色相 \ S 饱和度(纯度) \ V 明度 颜色模型
  9. /// </summary>
  10. public class ColorHSV
  11. {
  12. /// <summary>
  13. /// 构造方法
  14. /// </summary>
  15. /// <param name="h"></param>
  16. /// <param name="s"></param>
  17. /// <param name="v"></param>
  18. public ColorHSV(int h, int s, int v)
  19. {
  20. this._h = h;
  21. this._s = s;
  22. this._v = v;
  23. }
  24. private int _h;
  25. private int _s;
  26. private int _v;
  27. /// <summary>
  28. /// 色相
  29. /// </summary>
  30. public int H
  31. {
  32. get { return this._h; }
  33. set
  34. {
  35. this._h = value;
  36. this._h = this._h > 360 ? 360 : this._h;
  37. this._h = this._h < 0 ? 0 : this._h;
  38. }
  39. }
  40. /// <summary>
  41. /// 饱和度(纯度)
  42. /// </summary>
  43. public int S
  44. {
  45. get { return this._s; }
  46. set
  47. {
  48. this._s = value;
  49. this._s = this._s > 255 ? 255 : this._s;
  50. this._s = this._s < 0 ? 0 : this._s;
  51. }
  52. }
  53. /// <summary>
  54. /// 明度
  55. /// </summary>
  56. public int V
  57. {
  58. get { return this._v; }
  59. set
  60. {
  61. this._v = value;
  62. this._v = this._v > 255 ? 255 : this._v;
  63. this._v = this._v < 0 ? 0 : this._v;
  64. }
  65. }
  66. }
  67. }