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); } /// /// /// /// 色相(0~180) /// 饱合度(0~255) /// 明度(0~255) public ZTHsvColor(byte h, byte s, byte v) { this.H = h; this.S = s; this.V = v; } /// /// /// /// 色相(0~1) /// 饱合度(0~1) /// 明度(0~1) public ZTHsvColor(double h, double s, double v) { this.H = (byte)(h * 180); this.S = (byte)(s * 255); this.V = (byte)(v * 255); } /// /// 色相(0~180) /// public byte H; /// /// 饱合度(0~255) /// public byte S; /// /// 明度(0~255) /// 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; } } }