using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace RichCreator.Utility.Structs
|
{
|
public struct ZTHsvColor
|
{
|
public ZTHsvColor(ZTColor color)
|
{
|
float h, s, v;
|
ColorUtils.RGBtoHSV(color.Red, color.Green, color.Blue, out h, out s, out v);
|
this.H = (byte)(h * 180);
|
this.S = (byte)(s * 255);
|
this.V = (byte)(v * 255);
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="h">色相(0~180)</param>
|
/// <param name="s">饱合度(0~255)</param>
|
/// <param name="v">明度(0~255)</param>
|
public ZTHsvColor(byte h, byte s, byte v)
|
{
|
this.H = h;
|
this.S = s;
|
this.V = v;
|
}
|
|
/// <summary>
|
///
|
/// </summary>
|
/// <param name="h">色相(0~1)</param>
|
/// <param name="s">饱合度(0~1)</param>
|
/// <param name="v">明度(0~1)</param>
|
public ZTHsvColor(double h, double s, double v)
|
{
|
this.H = (byte)(h * 180);
|
this.S = (byte)(s * 255);
|
this.V = (byte)(v * 255);
|
}
|
|
/// <summary>
|
/// 色相(0~180)
|
/// </summary>
|
public byte H;
|
|
/// <summary>
|
/// 饱合度(0~255)
|
/// </summary>
|
public byte S;
|
|
/// <summary>
|
/// 明度(0~255)
|
/// </summary>
|
public byte V;
|
|
|
public bool IsBetween(ZTHsvColor min, ZTHsvColor max)
|
{
|
if (this.H >= min.H && this.S >= min.S && this.V >= min.V &&
|
this.H <= max.H && this.S <= max.S && this.V <= max.V)
|
{
|
return true;
|
}
|
return false;
|
}
|
}
|
}
|