12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- using System;
- namespace LYFZ.OtherExpansion.Imaging
- {
- public class HSL
- {
- private int _hue;
- private double _saturation;
- private double _luminance;
- public int Hue
- {
- get
- {
- return this._hue;
- }
- set
- {
- if (value < 0)
- {
- this._hue = 0;
- return;
- }
- if (value <= 360)
- {
- this._hue = value;
- return;
- }
- this._hue = value % 360;
- }
- }
- public double Saturation
- {
- get
- {
- return this._saturation;
- }
- set
- {
- if (value < 0.0)
- {
- this._saturation = 0.0;
- return;
- }
- this._saturation = Math.Min(value, 1.0);
- }
- }
- public double Luminance
- {
- get
- {
- return this._luminance;
- }
- set
- {
- if (value < 0.0)
- {
- this._luminance = 0.0;
- return;
- }
- this._luminance = Math.Min(value, 1.0);
- }
- }
- public HSL()
- {
- }
- public HSL(int hue, double saturation, double luminance)
- {
- this.Hue = hue;
- this.Saturation = saturation;
- this.Luminance = luminance;
- }
- public override string ToString()
- {
- return string.Format("HSL [H={0}, S={1}, L={2}]", this._hue, this._saturation, this._luminance);
- }
- }
- }
|