Beispiel #1
0
        public RGBColor GetRGB( )
        {
            RGBColor rgb_color = new RGBColor();


            if (this.Saturation == 0)
            {
                rgb_color.Set(this.Value, this.Value, this.Value);
            }
            else
            {
                if (this.Hue == HSVColor.MaxHue)
                {
                    this.Hue = HSVColor.MinHue;
                }

                double step = HSVColor.MaxHue / 6;

                double xh = this.Hue / step;
                int    i  = (int)System.Math.Floor(xh);
                double f  = xh - i;
                double p  = this.Value * (1 - this.Saturation);
                double q  = this.Value * (1 - (this.Saturation * f));
                double t  = this.Value * (1 - (this.Saturation * (1 - f)));

                switch (i)
                {
                case (0):
                {
                    rgb_color.Set(this.Value, t, p);
                    break;
                }

                case (1):
                {
                    rgb_color.Set(q, this.Value, p);
                    break;
                }

                case (2):
                {
                    rgb_color.Set(p, this.Value, t);
                    break;
                }

                case (3):
                {
                    rgb_color.Set(p, q, this.Value);
                    break;
                }

                case (4):
                {
                    rgb_color.Set(t, p, this.Value);
                    break;
                }

                case (5):
                {
                    rgb_color.Set(this.Value, p, q);
                    break;
                }

                default:
                {
                    throw new System.Exception("Unhandled Case");
                }
                }
            }

            return(rgb_color);
        }
Beispiel #2
0
		public RGBColor GetRGB( )
		{
			RGBColor rgb_color = new RGBColor();

			
			if (this.Saturation==0)
			{
				rgb_color.Set( this.Value, this.Value, this.Value);
			}
			else
			{
				
				if ( this.Hue  == HSVColor.MaxHue )
				{
					this.Hue = HSVColor.MinHue;
				}

				double step =  HSVColor.MaxHue / 6;

				double xh = this.Hue / step;
				int i = (int) System.Math.Floor( xh );
				double f = xh - i;
				double p = this.Value * ( 1 - this.Saturation );
				double q = this.Value * ( 1 - ( this.Saturation * f ) );
				double t = this.Value * ( 1 - ( this.Saturation * (1-f) ) );

				switch (i)
				{
					case (0) :
					{
						rgb_color.Set( this.Value, t, p );
						break;
					}
					case (1) :
					{
						rgb_color.Set( q, this.Value, p );
						break;
					}
					case (2) :
					{
						rgb_color.Set( p , this.Value, t);
						break;
					}
					case (3) :
					{
						rgb_color.Set( p, q, this.Value );
						break;
					}
					case (4) :
					{
						rgb_color.Set( t, p , this.Value );
						break;
					}
					case (5) :
					{
						rgb_color.Set( this.Value,  p, q );
						break;
					}
					default :
					{
						throw new System.Exception("Unhandled Case");
					}

				}
				
			}

			return rgb_color;

		}
Beispiel #3
0
        public string GetWebColorString()
        {
            RGBColor c = this.GetRGB();

            return(c.GetWebColorString());
        }