public virtual void UpdateDraggerWithHSV(HSV hsv)
        {
            // Set the position of the slider to the correct saturation and brightness
			var pos = new CCPoint(StartPos.X + boxPos + (boxSize * (1f - hsv.S)), StartPos.Y + boxPos + (boxSize * hsv.V));

            UpdateSliderPosition(pos);
        }
        public virtual void UpdateWithHSV(HSV hsv)
        {
            HSV hsvTemp;
			hsvTemp.S = 1;
			hsvTemp.H = hsv.H;
			hsvTemp.V = 1;

            RGBA rgb = CCControlUtils.RGBfromHSV(hsvTemp);
			Background.Color = new CCColor3B((byte) (rgb.R * 255.0f), (byte) (rgb.G * 255.0f),  (byte) (rgb.B * 255.0f));
        }
        public static RGBA RGBfromHSV(HSV value)
        {
            float hh, p, q, t, ff;
            long  i;
            RGBA  o;

            o.A = 1f;

            if (value.S <= 0.0f)             // < is bogus, just shuts up warnings
            {
                if (double.IsNaN(value.H))   // value.H == NAN
                {
                    o.R = value.V;
                    o.G = value.V;
                    o.B = value.V;
                    return(o);
                }

                // error - should never happen
                o.R = 0.0f;
                o.G = 0.0f;
                o.B = 0.0f;
                return(o);
            }

            hh = value.H;
            if (hh >= 360.0f)
            {
                hh = 0.0f;
            }
            hh /= 60.0f;
            i   = (long)hh;
            ff  = hh - i;
            p   = value.V * (1.0f - value.S);
            q   = value.V * (1.0f - (value.S * ff));
            t   = value.V * (1.0f - (value.S * (1.0f - ff)));

            switch (i)
            {
            case 0:
                o.R = value.V;
                o.G = t;
                o.B = p;
                break;

            case 1:
                o.R = q;
                o.G = value.V;
                o.B = p;
                break;

            case 2:
                o.R = p;
                o.G = value.V;
                o.B = t;
                break;

            case 3:
                o.R = p;
                o.G = q;
                o.B = value.V;
                break;

            case 4:
                o.R = t;
                o.G = p;
                o.B = value.V;
                break;

            case 5:
            default:
                o.R = value.V;
                o.G = p;
                o.B = q;
                break;
            }
            return(o);
        }
示例#4
0
		public static RGBA RGBfromHSV(HSV value)
		{
			float hh, p, q, t, ff;
			long i;
			RGBA o;
			o.A = 1f;
    
			if (value.S <= 0.0f) // < is bogus, just shuts up warnings
			{       
				if (double.IsNaN(value.H)) // value.H == NAN
				{   
					o.R = value.V;
					o.G = value.V;
					o.B = value.V;
					return o;
				}
        
				// error - should never happen
				o.R = 0.0f;
				o.G = 0.0f;
				o.B = 0.0f;
				return o;
			}
    
			hh = value.H;
			if(hh >= 360.0f) hh = 0.0f;
			hh /= 60.0f;
			i = (long)hh;
			ff = hh - i;
			p = value.V * (1.0f - value.S);
			q = value.V * (1.0f - (value.S * ff));
			t = value.V * (1.0f - (value.S * (1.0f - ff)));
    
			switch(i)
			{
				case 0:
					o.R = value.V;
					o.G = t;
					o.B = p;
					break;
				case 1:
					o.R = q;
					o.G = value.V;
					o.B = p;
					break;
				case 2:
					o.R = p;
					o.G = value.V;
					o.B = t;
					break;
            
				case 3:
					o.R = p;
					o.G = q;
					o.B = value.V;
					break;
				case 4:
					o.R = t;
					o.G = p;
					o.B = value.V;
					break;
				case 5:
				default:
					o.R = value.V;
					o.G = p;
					o.B = q;
					break;
			}
			return o;     
		}