public override void Solve(Dictionary<string, Attribute> Attributes)
        {
            HSB hsb = new HSB(Attributes["Hue"].Value * 360.0, Attributes["Saturation"].Value, 1f);
            RGB rgb = ColorSpaceHelper.HSBtoRGB(hsb);

            double minDistance = ColorSpaceHelper.GetColorDistance(1, 1, 1, 0, 0, 0);
            ColorWheelEntry closestEntry = ColorWheel.First();

            foreach (ColorWheelEntry entry in ColorWheel)
            {
                double distance = ColorSpaceHelper.GetColorDistance(rgb, entry.Color);
                if(distance < minDistance)
                {
                    closestEntry = entry;
                    minDistance = distance;
                }
            }

            var closestValueDMX = (closestEntry.Min + closestEntry.Max) / 2;
            var closestValue = closestValueDMX / 255f;
            Attributes["ColorWheel"].Value = closestValue;

            if(Attributes["Master"] != null)
            {
                Attributes["Master"].Value = Attributes["Brightness"].Value;
            }
        }
 public override void Solve(Dictionary<string, Attribute> Attributes)
 {
     HSB hsb = new HSB(Attributes["Hue"].Value * 360.0, Attributes["Saturation"].Value, Attributes["Brightness"].Value);
     RGB rgb = ColorSpaceHelper.HSBtoRGB(hsb);
     
     Attributes["Red"].Value = rgb.Red / 255f;
     Attributes["Green"].Value = rgb.Green / 255f;
     Attributes["Blue"].Value = rgb.Blue / 255f;
 }
		/// <summary>
		/// Converts HSB to Color.
		/// </summary>
		/// <param name="hsv">the HSB structure to convert.</param>
		public static RGB HSBtoColor(HSB hsb) 
		{
			RGB rgb = HSBtoRGB(hsb);

			return new Color.RGB(rgb.Red, rgb.Green, rgb.Blue);
		}
		/// <summary>
		/// Converts HSB to RGB.
		/// </summary>
		/// <param name="hsv">The HSB structure to convert.</param>
		public static RGB HSBtoRGB(HSB hsb) 
		{
			double r = 0;
			double g = 0;
			double b = 0;

			if(hsb.Saturation == 0) 
			{
				r = g = b = hsb.Brightness;
			} 
			else 
			{
				// the color wheel consists of 6 sectors. Figure out which sector you're in.
				double sectorPos = hsb.Hue / 60.0;
				int sectorNumber = (int)(Math.Floor(sectorPos));
				// get the fractional part of the sector
				double fractionalSector = sectorPos - sectorNumber;

				// calculate values for the three axes of the color. 
				double p = hsb.Brightness * (1.0 - hsb.Saturation);
				double q = hsb.Brightness * (1.0 - (hsb.Saturation * fractionalSector));
				double t = hsb.Brightness * (1.0 - (hsb.Saturation * (1 - fractionalSector)));

				// assign the fractional colors to r, g, and b based on the sector the angle is in.
				switch (sectorNumber) 
				{
					case 0:
						r = hsb.Brightness;
						g = t;
						b = p;
						break;
					case 1:
						r = q;
						g = hsb.Brightness;
						b = p;
						break;
					case 2:
						r = p;
						g = hsb.Brightness;
						b = t;
						break;
					case 3:
						r = p;
						g = q;
						b = hsb.Brightness;
						break;
					case 4:
						r = t;
						g = p;
						b = hsb.Brightness;
						break;
					case 5:
						r = hsb.Brightness;
						g = p;
						b = q;
						break;
				}
			}
			
			return new RGB(
				Convert.ToInt32( Double.Parse(String.Format("{0:0.00}", r*255.0)) ),
				Convert.ToInt32( Double.Parse(String.Format("{0:0.00}", g*255.0)) ),
				Convert.ToInt32( Double.Parse(String.Format("{0:0.00}", b*255.0)) )
				);
		}