Exemplo n.º 1
0
    public static HSV FromColor(Color color)
    {
        HSV ret = new HSV(0f, 0f, 0f, color.a);
        float r = color.r;
        float g = color.g;
        float b = color.b;
        float K = 0f;

        if (g < b)
        {
            swap(ref g, ref b);
            K = -1f;
        }

        if (r < g)
        {
            swap(ref r, ref g);
            K = -2f / 6f - K;
        }

        float chroma = r - Mathf.Min(g, b);
        ret.h = Mathf.Abs(K + (g - b) / (6f * chroma + 1e-20f));
        ret.s = chroma / (r + 1e-20f);
        ret.v = r;
        return ret;
    }
Exemplo n.º 2
0
    public static HSV GetHSV(this Color self)
    {
        HSV hsv = new HSV();
        float min = Mathf.Min(self.r, self.g, self.b);
        float max = Mathf.Max(self.r, self.g, self.b);

        hsv.v = max;               // v
        
        if (max != 0)
        {
            float delta = max - min;
            hsv.s = delta / max;       // s
            
            if (self.r == max)
                hsv.h = (self.g - self.b) / delta;       // between yellow & magenta
            else if (self.g == max)
                hsv.h = 2 + (self.b - self.r) / delta;   // between cyan & yellow
            else
                hsv.h = 4 + (self.r - self.g) / delta;   // between magenta & cyan

            hsv.h *= 60;               // degrees
            if (hsv.h < 0)
                hsv.h += 360;
        }
        else
        {
            // r = g = b = 0		// s = 0, h is undefined
            hsv.s = 0;
            hsv.h = -1;
        }

        return hsv;
    }
Exemplo n.º 3
0
        /// <summary>
        /// Colour Blending: http://www.stuartdenman.com/improved-color-blending/
        /// Where blend value is [0-1]
        /// </summary>
        private HSV BlendColour(HSV one, HSV two, double blendvalue)
        {
            HSV blend = new HSV();

            double invBlendValue = 1.0f - blendvalue;
            blend.Saturation = (one.Saturation * invBlendValue) + (two.Saturation * blendvalue);
            blend.Value = (one.Value * invBlendValue) + (two.Value * blendvalue);

            double hue1 = one.Hue;
            double hue2 = two.Hue;
            double difference = hue2 - hue1;

            if (hue1 > hue2)
            {
                hue2 = one.Hue;
                hue1 = two.Hue;

                blendvalue = invBlendValue;
                difference = -difference;
            }

            if(difference > 180)
            {
                hue1 += 360.0f;
                blend.Hue = ((int)(hue1 + (blendvalue * (hue2 - hue1)))) % 360;
            }
            else
            {
                blend.Hue = hue1 + (blendvalue * difference);
            }

            return blend;
        }
Exemplo n.º 4
0
        public static Color HSVtoColor(HSV hsv)
        {
            if (hsv == null)
                return Color.Blue;

            DRColor.RGB RGB = new RGB(hsv);
            return Color.FromArgb(RGB.Red, RGB.Green, RGB.Blue);
        }
Exemplo n.º 5
0
        public PixelRope(Pixel1D logicalDevice)
            : base(logicalDevice)
        {
            logicalDevice.PixelChanged += (sender, e) =>
                {
                    // Handles brightness as well

                    var hsv = new HSV(e.NewColor);
                    hsv.Value = hsv.Value * e.NewBrightness;
                    var color = hsv.Color;

                    if (System.Threading.Monitor.TryEnter(lockObject))
                    {
                        try
                        {
                            PixelOutputPort.SendPixelValue(e.Channel, color.R, color.G, color.B);
                        }
                        finally
                        {
                            System.Threading.Monitor.Exit(lockObject);
                        }
                    }
                    else
                        Console.WriteLine("Missed PixelChanged in PixelRobe");
                };

            logicalDevice.MultiPixelChanged += (sender, e) =>
                {
                    byte[] values = new byte[e.NewValues.Length * 4 - 1];
                    for (int i = 0; i < e.NewValues.Length; i++)
                    {
                        var hsv = new HSV(e.NewValues[i].Color);
                        hsv.Value = hsv.Value * e.NewValues[i].Brightness;
                        var color = hsv.Color;

                        values[i * 4 + 0] = color.R;
                        values[i * 4 + 1] = color.G;
                        values[i * 4 + 2] = color.B;
                        if (i < e.NewValues.Length - 1)
                            values[i * 4 + 3] = 32;     // Delimiter
                    }

                    if (System.Threading.Monitor.TryEnter(lockObject))
                    {
                        try
                        {
                            PixelOutputPort.SendPixelsValue(e.StartChannel, values);
                        }
                        finally
                        {
                            System.Threading.Monitor.Exit(lockObject);
                        }
                    }
                    else
                        Console.WriteLine("Missed send to PixelRope");
                };
        }
Exemplo n.º 6
0
        public static HSV GetHSV(Color color)
        {
            HSV hsv = new HSV();

            int max = Math.Max(color.R, Math.Max(color.G, color.B));
            int min = Math.Min(color.R, Math.Min(color.G, color.B));

            hsv.H = color.GetHue();
            hsv.S = (max == 0) ? 0 : 1d - (1d * min / max);
            hsv.V = max / 255d;

            return hsv;
        }
Exemplo n.º 7
0
        public PixelRGB(ColorDimmer logicalDevice, int channel)
            : base(logicalDevice)
        {
            logicalDevice.ColorChanged += (sender, e) =>
                {
                    // Handles brightness as well

                    var hsv = new HSV(e.NewColor);
                    hsv.Value = hsv.Value * e.NewBrightness;
                    var color = hsv.Color;

                    PixelOutputPort.SendPixelValue(channel, color.R, color.G, color.B);
                };
        }
Exemplo n.º 8
0
        public RGBStrobe(ColorDimmer logicalDevice, int dmxChannel)
            : base(logicalDevice)
        {
            logicalDevice.ColorChanged += (sender, e) =>
                {
                    // Handles brightness as well

                    var hsv = new HSV(e.NewColor);
                    hsv.Value = hsv.Value * e.NewBrightness;
                    var color = hsv.Color;

                    DmxOutputPort.SendDimmerValues(dmxChannel, color.R, color.G, color.B);
                };
        }
Exemplo n.º 9
0
        public static Color Blend(Color cur_color, Color next)
        {
            // convert to HSL, combine H
            HSV cur_hsv = new HSV()
            {
                h = cur_color.GetHue(), s = cur_color.GetSaturation(), v = Brightness(cur_color)
            };
            HSV new_hsv = new HSV()
            {
                h = next.GetHue(), s = next.GetSaturation(), v = Brightness(next)
            };
            HSV combined = new HSV()
            {
                h = (cur_hsv.h + new_hsv.h) / 2.0f, s = (cur_hsv.s + new_hsv.s) / 2.0f, v = (cur_hsv.v + new_hsv.v) / 2.0f
            };
            Color new_color = ColorFromHSL(combined);

            return(new_color);
        }
Exemplo n.º 10
0
    public static HSV LerpTo(this HSV self, HSV target, float t, float duration)
    {
        float hDiff = target.h - self.h;

        if (hDiff > 180.0f)
        {
            hDiff -= 360.0f;
        }
        else if (hDiff < -180.0f)
        {
            hDiff += 360.0f;
        }

        return(new HSV(
                   Easing.Linear(t, self.h, hDiff, duration),
                   Easing.Linear(t, self.s, target.s - self.s, duration),
                   Easing.Linear(t, self.v, target.v - self.v, duration)
                   ));
    }
Exemplo n.º 11
0
        private double [] GetColor(float col, string path)
        {
            string sMax       = System.IO.File.ReadAllText(Path.GetDirectoryName(path) + @"\test.color");
            double Max        = double.Parse(sMax.Replace(',', '.'));
            double OnePercent = Max / 100;
            double colorvalue = ((col / OnePercent) / 100) * 240;
            double fls        = 20;
            HSV    hsv        = new HSV(240 - colorvalue, 1, 5);
            RGB    rgb        = HSVToRGB(hsv);

            RR        = rgb.R / 255;
            GG        = rgb.G / 255;
            BB        = rgb.B / 255;
            Vcolor    = new double[3];
            Vcolor[0] = RR;
            Vcolor[1] = GG;
            Vcolor[2] = BB;
            return(Vcolor);
        }
Exemplo n.º 12
0
        private void DrawCurtainVertical(bool topEdge, int ylimit, List <int> swagArray, IPixelFrameBuffer frameBuffer,
                                         double level, int width)
        {
            int   i, x, y;
            Color col;

            for (i = 0; i < ylimit; i++)
            {
                col = Color.GetColorAt((double)i / width);
                if (level < 1)
                {
                    HSV hsv = HSV.FromRGB(col);
                    hsv.V *= level;
                    col    = hsv.ToRGB();
                }
                y = topEdge ? BufferHt - i - 1 : i;
                for (x = BufferWi - 1; x >= 0; x--)
                {
                    frameBuffer.SetPixel(x, y, col);
                }
            }

            // swag
            for (i = 0; i < swagArray.Count(); i++)
            {
                y   = ylimit + i;
                col = Color.GetColorAt((double)y / width);
                if (level < 1)
                {
                    HSV hsv = HSV.FromRGB(col);
                    hsv.V *= level;
                    col    = hsv.ToRGB();
                }
                if (topEdge)
                {
                    y = BufferHt - y - 1;
                }
                for (x = BufferWi - 1; x > swagArray[i]; x--)
                {
                    frameBuffer.SetPixel(x, y, col);
                }
            }
        }
Exemplo n.º 13
0
        private void DrawCurtain(bool leftEdge, int xlimit, List <int> swagArray, IPixelFrameBuffer frameBuffer, double level, int width)
        {
            Color col;

            for (int i = 0; i < xlimit; i++)
            {
                col = Color.GetColorAt((double)i / width);
                if (level < 1)
                {
                    HSV hsv = HSV.FromRGB(col);
                    hsv.V *= level;
                    col    = hsv.ToRGB();
                }

                int x = leftEdge ? BufferWi - i - 1 : i;
                for (int y = BufferHt - 1; y >= 0; y--)
                {
                    frameBuffer.SetPixel(x, y, col);
                }
            }

            // swag
            for (int i = 0; i < swagArray.Count; i++)
            {
                int x = xlimit + i;
                col = Color.GetColorAt((double)x / width);
                if (level < 1)
                {
                    HSV hsv = HSV.FromRGB(col);
                    hsv.V *= level;
                    col    = hsv.ToRGB();
                }

                if (leftEdge)
                {
                    x = BufferWi - x - 1;
                }
                for (int y = BufferHt - 1; y > swagArray[i]; y--)
                {
                    frameBuffer.SetPixel(x, y, col);
                }
            }
        }
Exemplo n.º 14
0
        protected override void RenderEffect(int frame, IPixelFrameBuffer frameBuffer)
        {
            if (_f == null)
            {
                return;
            }
            long fileLength = _f.Length;

            int seqNumPeriods = (int)(fileLength / _seqNumChannels);

            if (frame == 0)
            {
                if (MovementType == MovementType.Iterations)
                {
                    _position = seqNumPeriods / (TimeSpan.TotalMilliseconds / FrameTime) * Iterations;               //Iterations
                }
                else
                {
                    _position = Speed;                     //Speed
                }
            }

            _speed += _position;
            int period = (int)_speed % seqNumPeriods;
            int offset = _seqNumChannels * period;

            _f.Seek(offset, SeekOrigin.Begin);
            long readcnt = _f.Read(_glediatorFrameBuffer, 0, _seqNumChannels);

            for (int j = 0; j < readcnt; j += 3)
            {
                // Loop thru all channels
                Color color = Color.FromArgb(255, _glediatorFrameBuffer[j], _glediatorFrameBuffer[j + 1], _glediatorFrameBuffer[j + 2]);
                int   x     = (j % (BufferWi * 3)) / 3;
                int   y     = (BufferHt - 1) - (j / (BufferWi * 3));
                var   hsv   = HSV.FromRGB(color);
                hsv.V = hsv.V * LevelCurve.GetValue(GetEffectTimeIntervalPosition(frame) * 100) / 100;
                if (x < BufferWi && y < BufferHt && y >= 0)
                {
                    frameBuffer.SetPixel(x, y, hsv);
                }
            }
        }
Exemplo n.º 15
0
        public override void Handle(IIntentState <RGBValue> obj)
        {
            RGBValue value = obj.GetValue();

            // if we're not mixing colors, we need to compare the input color against the filter color -- but only the
            // hue and saturation components; ignore the intensity.
            if (Math.Abs(value.FullColor.R - _breakdownItem.Color.R) < Tolerance &&
                Math.Abs(value.FullColor.G - _breakdownItem.Color.G) < Tolerance &&
                Math.Abs(value.FullColor.B - _breakdownItem.Color.B) < Tolerance)
            {
                var i = HSV.VFromRgb(value.FullColor);
                //the value types are structs, so modify our copy and then set it back
                _intensityValue = i;
            }
            else
            {
                _intensityValue = 0;
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// check similar color or not
        /// </summary>
        /// <param name="c1"></param>
        /// <param name="c2"></param>
        /// <returns></returns>
        public static bool IsNearColor(Color c1, Color c2)
        {
            var hsv1 = HSV.FromColor(c1);
            var hsv2 = HSV.FromColor(c2);
            var dh   = Math.Abs(hsv1.H - hsv2.H);

            if (dh > 180)
            {
                dh = Math.Abs(dh - 360);
            }
            if (dh < 45)
            {
                if (Math.Abs(hsv1.V - hsv2.V) < 64)
                {
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 17
0
        public void TestHSVAndRGB()
        {
            //因为float精度问题不能直接比较,经过人工测试,没有问题;
            var image = Util.ImageFile.LoadBmpImage("..\\..\\..\\TestImages\\直方图均衡测试图片color3.bmp");
            ColorEqualization colorEqualization = new ColorEqualization(image);
            RGB rgb1 = new RGB {
                R = 240, G = 248, B = 255
            };
            HSV hsv1 = new HSV {
                H = (int)(0.5778 * 360), S = 0.0588F, V = 1.0000F
            };
            //Assert.Equal(rgb1,colorEqualization.HSV2RGB(hsv1));
            //Assert.Equal(hsv1, colorEqualization.RGB2HSV(rgb1));


            RGB rgb2 = new RGB {
                R = 139, G = 130, B = 119
            };
            HSV hsv2 = new HSV {
                H = (int)(0.0965 * 360), S = 0.1367F, V = 0.5451F
            };
            //Assert.Equal(rgb2,colorEqualization.HSV2RGB(hsv2));
            //Assert.Equal(hsv2, colorEqualization.RGB2HSV(rgb2));

            RGB rgb3 = new RGB {
                R = 255, G = 255, B = 255
            };
            HSV hsv3 = new HSV {
                H = 0, S = 0.0F, V = 1.0000F
            };
            //Assert.Equal(rgb3, colorEqualization.HSV2RGB(hsv3));
            //Assert.Equal(hsv3, colorEqualization.RGB2HSV(rgb3));

            RGB rgb4 = new RGB {
                R = 162, G = 205, B = 90
            };
            HSV hsv4 = new HSV {
                H = (int)(0.2290 * 360), S = 0.5610F, V = 0.8039F
            };
            //Assert.Equal(rgb4,colorEqualization.HSV2RGB(hsv4));
            //Assert.Equal(hsv4, colorEqualization.RGB2HSV(rgb4));
        }
Exemplo n.º 18
0
        //彩度を変化させた色相環作成
        private BitmapSource MakeHueRountRect2(int width, int height)
        {
            var wb = new WriteableBitmap(width, height, 96, 96, PixelFormats.Rgb24, null);
            //色情報用のバイト配列作成
            int stride = wb.BackBufferStride;              //横一列のバイト数、24bit = 8byteに横ピクセル数をかけた値

            byte[] pixels = new byte[height * stride * 8]; //*8はbyteをbitにするから

            //100x100のとき中心は50,50
            //ピクセル位置と画像の中心との差
            int    xDiff = width / 2;
            int    yDiff = height / 2;
            double distance;                    //中心からの距離
            double saturasion;                  //彩度
            int    p = 0;                       //今のピクセル位置の配列での位置

            for (int y = 0; y < height; y++)    //y座標
            {
                for (int x = 0; x < width; x++) //x座標
                {
                    distance   = Math.Sqrt(Math.Pow(y - yDiff, 2.0) + Math.Pow(x - xDiff, 2.0));
                    saturasion = distance / xDiff;
                    if (saturasion > 1.0)
                    {
                        saturasion = 1.0;
                    }
                    //今の位置の角度を取得、これが色相になる
                    double radian = Math.Atan2(y - yDiff, x - xDiff);
                    double kakudo = Degrees(radian);
                    //色相をColorに変換
                    Color c = HSV.HSV2Color(kakudo, saturasion, 1.0);
                    //バイト配列に色情報を書き込み
                    p             = y * stride + x * 3;
                    pixels[p]     = c.R;
                    pixels[p + 1] = c.G;
                    pixels[p + 2] = c.B;
                }
            }
            //バイト配列をBitmapに書き込み
            wb.WritePixels(new Int32Rect(0, 0, width, height), pixels, stride, 0);
            return(wb);
        }
Exemplo n.º 19
0
        /// <summary>
        /// make color from value between range
        /// </summary>
        /// <param name="value"></param>
        /// <param name="range"></param>
        /// <returns></returns>
        public static Color GetColorByNumber(int value, int range)
        {
            if (value < 0)
            {
                value = -value;
            }

            if (range <= 10)
            {
                switch (value % 10)
                {
                case 0: return(Color.FromArgb(255, 8, 8, 8));    // 黒い礼(0)服

                case 1: return(Colors.Brown);                    // 茶を一杯

                case 2: return(Colors.Red);                      // 赤いに(2)んじん

                case 3: return(Colors.Orange);                   // 第(橙)三者

                case 4: return(Colors.Yellow);                   // 岸(黄4)恵子

                case 5: return(Colors.Green);                    // 緑子(5)

                case 6: return(Colors.Blue);                     // ろく(6)でなしの青二才

                case 7: return(Colors.Purple);                   // 紫式(7)部

                case 8: return(Colors.Gray);                     // ハイ(灰)ヤー(8)

                case 9: return(Colors.White);                    // ホワイトク(9)リスマス
                }
                return(Colors.DarkGray);
            }
            else
            {
                var h   = (value * 129) % 360; // 120 cycle
                var s   = (value / 120) % 20;  // 20 step
                var v   = (value / 2400) % 20; // 20 step
                var hsv = new HSV(h, 1f - (float)s / 20, 1f - (float)v / 20);
                return(hsv.ToColor());         // 48000 color cycle
            }
        }
Exemplo n.º 20
0
        private void CreateExplosions(int ii, int x75, int x25, int y75, int y25)
        {
            HSV hsv = new HSV();

            if (ColorType == FireworksColorType.Random)
            {
                hsv.H = (float)(Rand() % 1000) / 1000.0f;
                hsv.S = 1.0f;
                hsv.V = 1.0f;
            }
            int start = EnableAudio ? ii : (int)(Rand01() * GetNumberFrames());

            int startX;
            int startY;

            if ((x75 - x25) > 0)
            {
                startX = x25 + Rand() % (x75 - x25);
            }
            else
            {
                startX = 0;
            }
            if ((y75 - y25) > 0)
            {
                startY = y25 + Rand() % (y75 - y25);
            }
            else
            {
                startY = 0;
            }

            int colorLocation = Rand() % ColorGradients.Count;

            int randomParticles = RandomParticles ? _random.Next(MinParticles, MaxParticles) : Particles;

            for (int i = 0; i < randomParticles; i++)
            {
                int velocity = RandomVelocity ? _random.Next(MinVelocity, MaxVelocity) : Velocity;
                _fireworkBursts[_explosion * randomParticles + i].Reset(startX, startY, false, velocity, hsv, start, colorLocation);
            }
        }
Exemplo n.º 21
0
        public Color[,] RenderEffect(Color[,] buffer, Color[] palette, int eventToRender)
        {
            const int speedFactor  = 200;
            var       bufferHeight = buffer.GetLength(Utils.IndexRowsOrHeight);
            var       bufferWidth  = buffer.GetLength(Utils.IndexColsOrWidth);

            Color color;
            var   hsv2     = new HSV();
            var   colorcnt = palette.Length;
            var   cycleLen = colorcnt * speedFactor;
            var   count    = tbCount.Value;

            if (eventToRender > (colorcnt - 1) * speedFactor * count && count < 10)
            {
                color = palette.GetMultiColorBlend(count % 2, false);
            }
            else
            {
                color = palette.GetMultiColorBlend(eventToRender % cycleLen / (double)cycleLen, true);
            }
            var hsv        = color.ToHSV();
            var halfHeight = (bufferHeight - 1) / 2.0;
            var halfWidth  = (bufferWidth - 1) / 2.0;

            for (var col = 0; col < bufferWidth; col++)
            {
                for (var row = 0; row < bufferHeight; row++)
                {
                    hsv2.SetToHSV(hsv);
                    if (chkBoxHFade.Checked)
                    {
                        hsv2.Value *= (float)(1.0 - Math.Abs(halfWidth - col) / halfWidth);
                    }
                    if (chkBoxVFade.Checked)
                    {
                        hsv2.Value *= (float)(1.0 - Math.Abs(halfHeight - row) / halfHeight);
                    }
                    buffer[row, col] = hsv2.ToColor();
                }
            }
            return(buffer);
        }
Exemplo n.º 22
0
        public void ColorExplorer_Match()
        {
            var hsv       = new HSV(213, 46, 49);
            var algorithm = new ColorExplorer();
            var actual    = algorithm.Match(hsv);
            var expected  = new Blend()
            {
                Colors = new[]
                {
                    new HSV(213, 46, 49),
                    new HSV(213, 14, 64),
                    new HSV(153, 55, 24),
                    new HSV(153, 46, 49),
                    new HSV(153, 0, 99),
                    new HSV(153, 0, 49)
                }
            };

            Assert.Equal(expected, actual, new BlendEqualityComparer());
        }
Exemplo n.º 23
0
        public void Square_Match()
        {
            var hsv       = new HSV(213, 46, 49);
            var algorithm = new Square();
            var actual    = algorithm.Match(hsv);
            var expected  = new Blend()
            {
                Colors = new[]
                {
                    new HSV(213, 46, 49),
                    new HSV(333, 46, 49),
                    new HSV(47, 46, 49),
                    new HSV(107, 46, 49),
                    new HSV(107, 0, 49),
                    new HSV(107, 0, 51)
                }
            };

            Assert.Equal(expected, actual, new BlendEqualityComparer());
        }
Exemplo n.º 24
0
        public void Triadic_Match()
        {
            var hsv       = new HSV(213, 46, 49);
            var algorithm = new Triadic();
            var actual    = algorithm.Match(hsv);
            var expected  = new Blend()
            {
                Colors = new[]
                {
                    new HSV(213, 46, 49),
                    new HSV(213, 46, 51),
                    new HSV(7, 46, 49),
                    new HSV(7, 46, 51),
                    new HSV(87, 46, 49),
                    new HSV(87, 46, 51)
                }
            };

            Assert.Equal(expected, actual, new BlendEqualityComparer());
        }
Exemplo n.º 25
0
        public void Analogue_Match()
        {
            var hsv       = new HSV(213, 46, 49);
            var algorithm = new Analogue();
            var actual    = algorithm.Match(hsv);
            var expected  = new Blend()
            {
                Colors = new[]
                {
                    new HSV(213, 46, 49),
                    new HSV(253, 46, 49),
                    new HSV(293, 46, 49),
                    new HSV(0, 0, 51),
                    new HSV(0, 0, 64),
                    new HSV(0, 0, 38)
                }
            };

            Assert.Equal(expected, actual, new BlendEqualityComparer());
        }
Exemplo n.º 26
0
        public void Classic_Match()
        {
            var hsv       = new HSV(213, 46, 49);
            var algorithm = new Classic();
            var actual    = algorithm.Match(hsv);
            var expected  = new Blend()
            {
                Colors = new[]
                {
                    new HSV(213, 46, 49),
                    new HSV(213, 46, 79),
                    new HSV(53, 46, 49),
                    new HSV(43, 46, 79),
                    new HSV(0, 0, 51),
                    new HSV(0, 0, 49)
                }
            };

            Assert.Equal(expected, actual, new BlendEqualityComparer());
        }
Exemplo n.º 27
0
 //360度を6分割した範囲ごとのピクセル数をカウント
 private int[] Hue6Count(byte[] pixels)
 {
     int[] table = new int[6];
     for (int i = 0; i < pixels.Length; i += 4)
     {
         double ihsv = HSV.Color2HSV(pixels[i + 2], pixels[i + 1], pixels[i]).Hue;
         if (ihsv == 360.0)
         {
             continue;
         }                               //色相360は無彩色なのでパス
         var aa = ihsv / 60.0;
         var bb = (int)Math.Round(aa, MidpointRounding.AwayFromZero);
         if (bb == 6)
         {
             bb = 0;
         }
         table[bb]++;
     }
     return(table);
 }
 private void SetPixelColor()
 {
     if (manualFader.Value)
     {
         pixelsRoofEdge.SetAll(GetFaderColor(), faderBright.Value);
     }
     else
     {
         if (hoursSmall.IsOpen)
         {
             pixelsRoofEdge.SetAll(
                 HSV.ColorFromRGB(0.73333333333333328, 0, 1),
                 0.16470588235294117);
         }
         else
         {
             pixelsRoofEdge.SetAll(Color.Black, 0.0);
         }
     }
 }
Exemplo n.º 29
0
        private void InitFirePalette(float hue)
        {
            _firePalette = new Color[200];
            var hsv = new HSV {
                Hue = hue, Saturation = 1.0f
            };

            for (var i = 0; i < 100; i++)
            {
                hsv.Value       = i / 100.0f;
                _firePalette[i] = hsv.ToColor();
            }

            hsv.Value = 1.0f;
            for (var i = 0; i < 100; i++)
            {
                _firePalette[i + 100] = hsv.ToColor();
                hsv.Hue = (hsv.Hue + 0.00166666f) % 1f;
            }
        }
Exemplo n.º 30
0
        public void Transformation()
        {
            SV = new float[level];
            int size = oldData.Width * oldData.Height;

            for (int i = 0; i < level; i++)
            {
                SV[i] = (histV_acc[i] * 1.0F) / size;
            }

            for (int i = 0; i < Image.Data.Width; i++)
            {
                for (int k = 0; k < Image.Data.Height; k++)
                {
                    HSV oldHsv = HSVAndRGB.RGB2HSV(oldData.GetRGBDataAt(i, k));
                    oldHsv.V = SV[(int)(oldHsv.V * 255)];
                    Image.Data.SetRGBDataAt(i, k, HSVAndRGB.HSV2RGB(oldHsv));
                }
            }
        }
Exemplo n.º 31
0
        public void SplitComplementary_Match()
        {
            var hsv       = new HSV(213, 46, 49);
            var algorithm = new SplitComplementary();
            var actual    = algorithm.Match(hsv);
            var expected  = new Blend()
            {
                Colors = new[]
                {
                    new HSV(213, 46, 49),
                    new HSV(27, 46, 49),
                    new HSV(67, 46, 49),
                    new HSV(67, 0, 46),
                    new HSV(67, 0, 49),
                    new HSV(67, 0, 51)
                }
            };

            Assert.Equal(expected, actual, new BlendEqualityComparer());
        }
Exemplo n.º 32
0
        void Blend(Tuple <int, int> loc, Color next)
        {
            // convert to HSL, combine H
            Color cur_color = bmp.GetPixel(loc.Item1, loc.Item2);
            HSV   cur_hsv   = new HSV()
            {
                h = cur_color.GetHue(), s = cur_color.GetSaturation(), v = getBrightness(cur_color)
            };
            HSV new_hsv = new HSV()
            {
                h = next.GetHue(), s = next.GetSaturation(), v = getBrightness(next)
            };
            HSV combined = new HSV()
            {
                h = (cur_hsv.h + new_hsv.h) / 2.0f, s = (cur_hsv.s + new_hsv.s) / 2.0f, v = (cur_hsv.v + new_hsv.v) / 2.0f
            };
            Color new_color = ColorFromHSL(combined);

            bmp.SetPixel(loc.Item1, loc.Item2, new_color);
        }
Exemplo n.º 33
0
        //rgb変更時
        private void UpDownRGB_MyValueChanged(object sender, MyValueChangedEventArgs e)
        {
            IsRgbChanging = true;
            if (IsHsvChanging != true)
            {
                var iHsv = HSV.Color2HSV(R, G, B);
                if (UpDownH.Value != (int)iHsv.Hue)
                {
                    UpDownH.Value = (int)iHsv.Hue;
                    SetImageSV(iHsv.Hue);
                }
                UpDownS.Value = (int)(iHsv.Saturation * ImageSize);
                UpDownV.Value = (int)(iHsv.Value * ImageSize);


                Canvas.SetLeft(ThumbPicker, UpDownS.Value - ThumbSize / 2f);
                Canvas.SetTop(ThumbPicker, UpDownV.Value - ThumbSize / 2f);
            }
            IsRgbChanging = false;
        }
Exemplo n.º 34
0
        private void ColorChooser_Load(object sender, System.EventArgs e)
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.DoubleBuffer, true);
            pnlSelectedColor.Visible = false;
            pnlBrightness.Visible    = false;
            pnlColor.Visible         = false;

            var SelectedColorRectangle = new Rectangle(pnlSelectedColor.Location, pnlSelectedColor.Size);
            var BrightnessRectangle    = new Rectangle(pnlBrightness.Location, pnlBrightness.Size);
            var ColorRectangle         = new Rectangle(pnlColor.Location, pnlColor.Size);

            var startColor = new HSV(127, 256, 82);

            _colorWheel = new ColorWheel(ColorRectangle, BrightnessRectangle, SelectedColorRectangle, startColor);
            _colorWheel.ColorChanged += new ColorWheel.ColorChangedEventHandler(colorWheel_Changed);
            SetRGB(startColor.toRGB());
            SetHSV(startColor);
        }
Exemplo n.º 35
0
        // the Color Converter
        static public Color ColorFromHSL(HSV hsl)
        {
            if (hsl.s == 0)
            {
                int L = (int)hsl.v; return(Color.FromArgb(255, L, L, L));
            }

            double min, max, h;

            h = hsl.h / 360d;

            max = hsl.v < 0.5d ? hsl.v * (1 + hsl.s) : (hsl.v + hsl.s) - (hsl.v * hsl.s);
            min = (hsl.v * 2d) - max;

            Color c = Color.FromArgb(255, (int)(255 * RGBChannelFromHue(min, max, h + 1 / 3d)),
                                     (int)(255 * RGBChannelFromHue(min, max, h)),
                                     (int)(255 * RGBChannelFromHue(min, max, h - 1 / 3d)));

            return(c);
        }
Exemplo n.º 36
0
        public void SingleHue_Match()
        {
            var hsv       = new HSV(213, 46, 49);
            var algorithm = new SingleHue();
            var actual    = algorithm.Match(hsv);
            var expected  = new Blend()
            {
                Colors = new[]
                {
                    new HSV(213, 46, 49),
                    new HSV(213, 46, 69),
                    new HSV(213, 46, 89),
                    new HSV(213, 66, 49),
                    new HSV(213, 86, 49),
                    new HSV(213, 86, 89)
                }
            };

            Assert.Equal(expected, actual, new BlendEqualityComparer());
        }
Exemplo n.º 37
0
        private void CreateHSVBoard()
        {
            HSV hsv = new HSV(Hvalue, 0.0f, 1.0f);

            float stepW = 1.0f / ((float)bmp_hsv_board.Width - 1.0f);
            float stepH = 1.0f / ((float)bmp_hsv_board.Height - 1.0f);

            try
            {
                bmp_hsv_board.Lock();
                unsafe
                {
                    int *pStart = (int *)bmp_hsv_board.BackBuffer;

                    for (int y = 0; y < bmp_hsv_board.PixelHeight; ++y)
                    {
                        hsv.s = 0.0f;

                        for (int x = 0; x < bmp_hsv_board.PixelWidth; ++x)
                        {
                            RGB rgb   = LusColor.Color.Convert(hsv);
                            int pixel = 0;
                            pixel |= rgb.r << 16;  // R
                            pixel |= rgb.g << 8;   // G
                            pixel |= rgb.b << 0;   // B

                            *(pStart) = pixel;

                            pStart++;
                            hsv.s += stepW;
                        }
                        hsv.v -= stepH;
                    }
                    bmp_hsv_board.AddDirtyRect(new Int32Rect(0, 0, bmp_hsv_board.PixelWidth, bmp_hsv_board.PixelHeight));
                }
            }
            finally
            {
                bmp_hsv_board.Unlock();
            }
        }
Exemplo n.º 38
0
    public static Color     HSVToRGB(HSV hsv)
    {
        int   sel;
        float fl;
        float m, n;
        Color color = Color.black;

        float h = Mathf.Repeat(hsv.h, 360.0f);
        float s = hsv.s;
        float v = hsv.v;

        sel = Mathf.FloorToInt(h / 60.0f);

        fl = (h / 60.0f) - (float)sel;

        if (sel % 2 == 0)
        {
            fl = 1.0f - fl;
        }

        m = v * (1.0f - s);
        n = v * (1.0f - s * fl);

        switch (sel)
        {
        default:
        case 0: color.r = v;    color.g = n;    color.b = m;    break;

        case 1: color.r = n;    color.g = v;    color.b = m;    break;

        case 2: color.r = m;    color.g = v;    color.b = n;    break;

        case 3: color.r = m;    color.g = n;    color.b = v;    break;

        case 4: color.r = n;    color.g = m;    color.b = v;    break;

        case 5: color.r = v;    color.g = m;    color.b = n;    break;
        }

        return(color);
    }
Exemplo n.º 39
0
    public static HSV Lerp(HSV a, HSV b, float t)
    {
        float h, s;

        //check special case black (color.b==0): interpolate neither hue nor saturation!
        //check special case grey (color.s==0): don't interpolate hue!
        if (a.v == 0)
        {
            h = b.h;
            s = b.s;
        }
        else if (b.v == 0)
        {
            h = a.h;
            s = a.s;
        }
        else
        {
            if (a.s == 0)
            {
                h = b.h;
            }
            else if (b.s == 0)
            {
                h = a.h;
            }
            else
            {
                // works around bug with LerpAngle
                float angle = Mathf.LerpAngle(a.h * 360f, b.h * 360f, t);
                while (angle < 0f)
                    angle += 360f;
                while (angle > 360f)
                    angle -= 360f;
                h = angle / 360f;
            }
            s = Mathf.Lerp(a.s, b.s, t);
        }
        return new HSV(h, s, Mathf.Lerp(a.v, b.v, t), Mathf.Lerp(a.a, b.a, t));
    }
Exemplo n.º 40
0
        public static System.Drawing.Color GetColorFromColorBrightness(ColorBrightness colorBrightness)
        {
            var hsv = new HSV(colorBrightness.Color);

            double whiteOut = Executor.Current.Whiteout.Value;

            // Adjust brightness
            double adjustedValue = (hsv.Value * colorBrightness.Brightness) + whiteOut;

            // Adjust for WhiteOut
            HSV baseHsv;
            if (colorBrightness.Brightness == 0 && whiteOut > 0)
                // Base it on black instead
                baseHsv = HSV.Black;
            else
                baseHsv = hsv;

            hsv.Saturation = baseHsv.Saturation + (HSV.White.Saturation - baseHsv.Saturation) * whiteOut;
            hsv.Value = adjustedValue.Limit(0, 1) * (1 - Executor.Current.Blackout.Value);

            return hsv.Color;
        }
Exemplo n.º 41
0
 public static Color HSVToColor(HSV hsv, int alpha = 255)
 {
     return ColorFromHSV (hsv.H, hsv.S, hsv.V, alpha);
 }
Exemplo n.º 42
0
 public static Color addv(this Color c, float v)
 {
     HSV hsv = new HSV(c);
     return hsv.V(v + hsv.v).ToColor();
 }
Exemplo n.º 43
0
        private Color GetColorFromColorAndBrightness(Color input, double brightness)
        {
            var hsv = new HSV(input);

            // Adjust brightness
            double adjustedValue = hsv.Value * brightness;

            hsv.Value = adjustedValue.Limit(0, 1);

            return hsv.Color;
        }
Exemplo n.º 44
0
 public static Color addh(this Color c, float h)
 {
     HSV hsv = new HSV(c);
     return hsv.RotateH((h + hsv.h) % 1f).ToColor();
 }
Exemplo n.º 45
0
 public static Color adds(this Color c, float s)
 {
     HSV hsv = new HSV(c);
     return hsv.S(s + hsv.s).ToColor();
 }
Exemplo n.º 46
0
        /// <summary>
        /// Converts a HSV color values to an RGB color
        /// </summary>
        /// <param name="hsv">HSV color to convert</param>
        /// <returns>RGB color equivalent</returns>
        public static ARGB HSVtoRGB(HSV hsv)
        {
            double r = 0.0d, g = 0.0d, b = 0.0d;
            var h = ((double)hsv.Hue / 255 * 360) % 360;
            var s = (double)hsv.Saturation / 255;
            var v = (double)hsv.Value / 255;

            if (Equals(s, 0.0d))
            {
                r = v;
                g = v;
                b = v;
            }
            else
            {
                var sectorPos = h / 60;
                var sectorNumber = (int)(Math.Floor(sectorPos));
                var fractionalSector = sectorPos - sectorNumber;
                var p = v * (1 - s);
                var q = v * (1 - (s * fractionalSector));
                var t = v * (1 - (s * (1 - fractionalSector)));
                switch (sectorNumber)
                {
                    case 0:
                        r = v;
                        g = t;
                        b = p;
                        break;

                    case 1:
                        r = q;
                        g = v;
                        b = p;
                        break;

                    case 2:
                        r = p;
                        g = v;
                        b = t;
                        break;

                    case 3:
                        r = p;
                        g = q;
                        b = v;
                        break;

                    case 4:
                        r = t;
                        g = p;
                        b = v;
                        break;

                    case 5:
                        r = v;
                        g = p;
                        b = q;
                        break;
                }
            }
            return new ARGB(hsv.Alpha, (int)(r * 255), (int)(g * 255), (int)(b * 255));
        }
Exemplo n.º 47
0
            public static HSV RGB2HSV(double r, double b, double g)
            {
                double delta, min;
                double h = 0, s, v;

                min = Math.Min(Math.Min(r, g), b);
                v = Math.Max(Math.Max(r, g), b);
                delta = v - min;

                if (v == 0.0)
                {
                    s = 0;

                }
                else
                    s = delta / v;

                if (s == 0)
                    h = 0.0f;

                else
                {
                    if (r == v)
                        h = (g - b) / delta;
                    else if (g == v)
                        h = 2 + (b - r) / delta;
                    else if (b == v)
                        h = 4 + (r - g) / delta;

                    h *= 60;
                    if (h < 0.0)
                        h = h + 360;

                }

                HSV hsvColor = new HSV();
                hsvColor.h = h;
                hsvColor.s = s;
                hsvColor.v = v / 255;

                return hsvColor;
            }
Exemplo n.º 48
0
        /// <summary>
        /// Converting HSV-RGB: http://www.poynton.com/PDFs/coloureq.pdf p15
        /// Where h is [0,360] and sv is [0,1]
        /// </summary>
        private RGB ConvertColour(HSV hsv)
        {
            RGB rgb = new RGB();

            double hex = hsv.Hue / 60.0f;
            int primary = (int)Math.Floor(hex);
            double secondary = hex - primary;
            double a = (1.0f - hsv.Saturation) * hsv.Value;
            double b = (1.0f - (hsv.Saturation * secondary)) * hsv.Value;
            double c = (1.0f - (hsv.Saturation * (1.0f - secondary))) * hsv.Value;

            switch(primary)
            {
            case 0:
                rgb.Red = hsv.Value;
                rgb.Green = c;
                rgb.Blue = a;
                break;
            case 1:
                rgb.Red = b;
                rgb.Green = hsv.Value;
                rgb.Blue = a;
                break;
            case 2:
                rgb.Red = a;
                rgb.Green = hsv.Value;
                rgb.Blue = c;
                break;
            case 3:
                rgb.Red = a;
                rgb.Green = b;
                rgb.Blue = hsv.Value;
                break;
            case 4:
                rgb.Red = c;
                rgb.Green = a;
                rgb.Blue = hsv.Value;
                break;
            case 5:
                rgb.Red = hsv.Value;
                rgb.Green = a;
                rgb.Blue = b;
                break;
            case 6:
                rgb.Red = hsv.Value;
                rgb.Green = c;
                rgb.Blue = a;
                break;
            }

            return rgb;
        }
Exemplo n.º 49
0
        /// <summary>
        /// Converting RGB-HSV: http://www.poynton.com/PDFs/coloureq.pdf p15
        /// Where rgb is [0,1]
        /// </summary>
        private HSV ConvertColour(RGB rgb)
        {
            HSV hsv = new HSV();

            double min = Math.Min(Math.Min(rgb.Red, rgb.Blue), rgb.Green);
            double max = Math.Max(Math.Max(rgb.Red, rgb.Blue), rgb.Green);
            hsv.Saturation = max == 0.0f ? 0.0f : (max - min) / max;
            hsv.Value = max;

            double red = (max - rgb.Red) / (max - min);
            double green = (max - rgb.Green) / (max - min);
            double blue = (max - rgb.Blue) / (max - min);

            if (hsv.Saturation != 0)
            {
                if (rgb.Red == max && rgb.Green == min)
                {
                    hsv.Hue = 5.0f + blue;
                }
                else if (rgb.Red == max && rgb.Green != min)
                {
                    hsv.Hue = 1.0f - green;
                }
                else if (rgb.Green == max && rgb.Blue == min)
                {
                    hsv.Hue = 1.0f + red;
                }
                else if (rgb.Green == max && rgb.Blue != min)
                {
                    hsv.Hue = 3.0f - blue;
                }
                else if (rgb.Red == max || rgb.Red == min)
                {
                    hsv.Hue = 3.0f + green;
                }
                else
                {
                    hsv.Hue = 5.0f - red;
                }
            }

            hsv.Hue *= 60.0f;
            return hsv;
        }
Exemplo n.º 50
0
 public void SetColorRGB(int R, int G, int B)
 {
     this.rgbColor = Color.FromArgb(R, G, B);
     this.hsvColor = GetHSV(this.rgbColor);
     this.colorRbox.Value = this.rgbColor.R;
     this.colorGbox.Value = this.rgbColor.G;
     this.colorBbox.Value = this.rgbColor.B;
     this.colorBox.BackColor = this.rgbColor;
     this.UpdatePalette();
 }
Exemplo n.º 51
0
 public void SetColor(Color c)
 {
     this.rgbColor = c;
     this.hsvColor = GetHSV(this.rgbColor);
     this.colorRbox.Value = this.rgbColor.R;
     this.colorGbox.Value = this.rgbColor.G;
     this.colorBbox.Value = this.rgbColor.B;
     this.colorBox.BackColor = this.rgbColor;
     this.UpdatePalette();
 }
Exemplo n.º 52
0
            public static Color HSVToColor(HSV hsv)
            {
                int hi = 0;
                double f = 0;

                {
                    hi = Convert.ToInt32(Math.Floor(hsv.Hue / 60)) % 6;
                    f = hsv.Hue / 60 - Math.Floor(hsv.Hue / 60);
                    hsv.Value = hsv.Value * 255;
                    int v = Convert.ToInt32(hsv.Value);
                    int p = Convert.ToInt32(hsv.Value * (1 - hsv.Saturation));
                    int q = Convert.ToInt32(hsv.Value * (1 - f * hsv.Saturation));
                    int t = Convert.ToInt32(hsv.Value * (1 - (1 - f) * hsv.Saturation));

                    if (hi == 0)
                    {
                        return Color.FromArgb(255, v, t, p);
                    }
                    else if (hi == 1)
                    {
                        return Color.FromArgb(255, q, v, p);
                    }
                    else if (hi == 2)
                    {
                        return Color.FromArgb(255, p, v, t);
                    }
                    else if (hi == 3)
                    {
                        return Color.FromArgb(255, p, q, v);
                    }
                    else if (hi == 4)
                    {
                        return Color.FromArgb(255, t, p, v);
                    }
                    else
                    {
                        return Color.FromArgb(255, v, p, q);
                    }
                }
            }
Exemplo n.º 53
0
 public static HSV ColorToHSV(Color color)
 {
     int max = Math.Max(color.R, Math.Max(color.G, color.B));
     int min = Math.Min(color.R, Math.Min(color.G, color.B));
     HSV result = new HSV();
     {
         result.Hue = color.GetHue();
         result.Saturation = (max == 0) ? 0 : 1.0 - (1.0 * min / max);
         result.Value = max / 255.0;
     }
     return result;
 }
Exemplo n.º 54
0
 public static Color HSVtoColor(HSV hsv)
 {
     RGB RGB = HSVtoRGB(hsv);
             return Color.FromArgb(RGB.Alpha, RGB.Red, RGB.Green, RGB.Blue);
 }
Exemplo n.º 55
0
        public static ARGB HSVtoRGB(HSV HSV)
        {
            // HSV contains values scaled as in the color wheel:
            // that is, all from 0 to 255.

            // for ( this code to work, HSV.Hue needs
            // to be scaled from 0 to 360 (it//s the angle of the selected
            // point within the circle). HSV.Saturation and HSV.value must be
            // scaled to be between 0 and 1.

            double h;
            double s;
            double v;

            double r = 0;
            double g = 0;
            double b = 0;

            // Scale Hue to be between 0 and 360. Saturation
            // and value scale to be between 0 and 1.
            h = ((double) HSV.Hue/255*360)%360;
            s = (double) HSV.Saturation/255;
            v = (double) HSV.Value/255;

            if (s == 0)
            {
                // If s is 0, all colors are the same.
                // This is some flavor of gray.
                r = v;
                g = v;
                b = v;
            }
            else
            {
                // The color wheel consists of 6 sectors.
                // Figure out which sector you//re in.
                double sectorPos = h/60;
                int sectorNumber = (int) (Math.Floor(sectorPos));

                // get the fractional part of the sector.
                // That is, how many degrees into the sector
                // are you?
                double fractionalSector = sectorPos - sectorNumber;

                // Calculate values for the three axes
                // of the color.
                double p = v*(1 - s);
                double q = v*(1 - (s*fractionalSector));
                double t = v*(1 - (s*(1 - fractionalSector)));

                // Assign the fractional colors to r, g, and b
                // based on the sector the angle is in.
                switch (sectorNumber)
                {
                    case 0:
                        r = v;
                        g = t;
                        b = p;
                        break;

                    case 1:
                        r = q;
                        g = v;
                        b = p;
                        break;

                    case 2:
                        r = p;
                        g = v;
                        b = t;
                        break;

                    case 3:
                        r = p;
                        g = q;
                        b = v;
                        break;

                    case 4:
                        r = t;
                        g = p;
                        b = v;
                        break;

                    case 5:
                        r = v;
                        g = p;
                        b = q;
                        break;
                }
            }
            // return an RGB structure, with values scaled
            // to be between 0 and 255.
            return new ARGB(HSV.Alpha, (int) (r*255), (int) (g*255), (int) (b*255));
        }
Exemplo n.º 56
0
 public bool Contains(HSV hsv)
 {
     return skinHSV.Contains(hsv);
 }
Exemplo n.º 57
0
 /// <summary>
 /// Converts a HSV color to a System.Drawing.Color
 /// </summary>
 /// <param name="hsv">HSV color to convert</param>
 /// <returns>System.Drawing.Color equivalent</returns>
 public static Color HSVtoColor(HSV hsv)
 {
     var argb = HSVtoRGB(hsv);
     return Color.FromArgb(argb.Alpha, argb.Red, argb.Green, argb.Blue);
 }
Exemplo n.º 58
0
        public void ShowBuffer()
        {
            var output = new Color[PixelWidth, PixelHeight];

            for (int x = 0; x < PixelWidth; x++)
                for (int y = 0; y < PixelHeight; y++)
                {
                    var hsv = new HSV(this.color[x, y]);
                    hsv.Value = hsv.Value * this.brightness[x, y] * this.globalBrightness.Value;

                    output[x, y] = hsv.Color;
                }

            this.showBuffer.OnNext(output);
        }
Exemplo n.º 59
0
        public Pixel1D FadeToUsingHSV(int channel, Color color, double brightness, TimeSpan duration)
        {
            if (channel < 0 || channel >= this.pixelCount)
                throw new ArgumentOutOfRangeException();

            if (this.color[channel].GetBrightness() == 0)
            {
                this.color[channel] = color;
                this.brightness[channel] = 0;
            }

            if (color.GetBrightness() == 0)
            {
                color = this.color[channel];
                brightness = 0;
            }

            var startHSV = new HSV(this.color[channel]);
            var endHSV = new HSV(color);
            double startBrightness = this.brightness[channel];

            // 10 steps per second
            int steps = (int)(duration.TotalMilliseconds / 100);

            double position = 0;
            for (int i = 0; i < steps; i++)
            {
                double newBrightness = startBrightness + (brightness - startBrightness) * position;

                double hue = startHSV.Hue + (endHSV.Hue - startHSV.Hue) * position;
                double sat = startHSV.Saturation + (endHSV.Saturation - startHSV.Saturation) * position;
                double val = startHSV.Value + (endHSV.Value - startHSV.Value) * position;
                Color newColor = HSV.ColorFromHSV(hue, sat, val);

                SetColor(channel, newColor, newBrightness);

                System.Threading.Thread.Sleep(100);

                position += 1.0 / (steps - 1);
            }

            return this;
        }
Exemplo n.º 60
0
 public static Color HSV2RGB(HSV color)
 {
     return HSV2RGB(color.h, color.s, color.v);
 }