示例#1
0
        private static DRColor.RGB attenuateStrip(DRColor.RGB clr)
        {
            float dim = 0.3f;

            DRColor.RGB new_clr = new DRColor.RGB((int)(clr.Red * dim), (int)(clr.Green * dim), (int)(clr.Blue * dim));
            return(new_clr);
        }
示例#2
0
        private void CalcCoordsAndUpdate(DRColor.HSV HSV)
        {
            // Convert color to real-world coordinates and then calculate
            // the various points. HSV.Hue represents the degrees (0 to 360),
            // HSV.Saturation represents the radius_norm.
            // This procedure doesn't draw anything--it simply
            // updates class-level variables. The UpdateDisplay
            // procedure uses these values to update the screen.

            // Given the angle (HSV.Hue), and distance from
            // the center (HSV.Saturation), and the center,
            // calculate the point corresponding to
            // the selected color, on the color wheel.
            colorPoint = GetPoint((double)HSV.Hue / 255 * 360,
                                  (double)HSV.Saturation / 255 * radius,
                                  centerPoint);

            // Given the brightness (HSV.value), calculate the
            // point corresponding to the brightness indicator.
            brightnessPoint = CalcBrightnessPoint(HSV.Value);

            // Store information about the selected color.
            brightness    = HSV.Value;
            selectedColor = DRColor.HSVtoColor(HSV);
            RGB           = new DRColor.RGB(HSV);

            // The full color is the same as HSV, except that the
            // brightness is set to full (255). This is the top-most
            // color in the brightness gradient.
            fullColor = DRColor.HSVtoColor(new DRColor.HSV(HSV.Hue, HSV.Saturation, 255));
        }
示例#3
0
        // Immediately updates the ardunio's buffer for the color
        private static bool sendClr(int pos, DRColor.RGB rgb, int strip)
        {
            posClamp(ref pos, 1);

            // Create color packet, add 64 for second led strip
            byte[] bytes = new byte[4];
            bytes[0] = (byte)pos;
            if (strip == 2)
            {
                bytes[0] += (byte)64;
            }
            bytes[1] = (byte)rgb.Red;
            bytes[2] = (byte)rgb.Green;
            bytes[3] = (byte)rgb.Blue;

            int       bytesWritten = 0;
            ErrorCode ec           = ErrorCode.None;

            if (Connected)
            {
                ec = writer.Write(bytes, 2000, out bytesWritten);
            }
            if (ec == ErrorCode.ResourceBusy)
            {
                return(true);
            }

            if (ec != ErrorCode.None)
            {
                throw new Exception(UsbDevice.LastErrorString);
            }

            return(true);
        }
示例#4
0
 public void Draw(Graphics g, DRColor.RGB RGB)
 {
     // Given RGB values, calculate HSV and then update the screen.
     this._g  = g;
     this.HSV = new DRColor.HSV(RGB);
     CalcCoordsAndUpdate(this.HSV);
     UpdateDisplay();
 }
示例#5
0
 public static DRColor.RGB ProperMix(DRColor.RGB a, DRColor.RGB b, double ratio)
 {
     DRColor.RGB result = new DRColor.RGB();
     result.Red   = properMixAlgo(b.Red, a.Red);
     result.Green = properMixAlgo(b.Green, a.Green);
     result.Blue  = properMixAlgo(b.Blue, a.Blue);
     return(result);
 }
示例#6
0
 public static DRColor.RGB ProperMix(DRColor.RGB a, DRColor.RGB b, double ratio)
 {
     DRColor.RGB result = new DRColor.RGB();
     result.Red = properMixAlgo(b.Red, a.Red);
     result.Green = properMixAlgo(b.Green, a.Green);
     result.Blue = properMixAlgo(b.Blue, a.Blue);
     return result;
 }
示例#7
0
 public void addColor(DRColor.RGB rgb)
 {
     if (mood.Color_List.Count == 10)
     {
         mood.Color_List.RemoveAt(0);
     }
     mood.Color_List.Add(rgb);
 }
示例#8
0
        // Set Color
        private void addClrBtn_Click(object sender, EventArgs e)
        {
            if (_chooser == null) return;
            DRColor.RGB clr = new DRColor.RGB(_chooser.ActiveColor);
            if (clr == null) return;

            currentMood.Color_List.Add(clr);
            current_moodSeqUI.Mood = currentMood;
            this.Invalidate();
        }
示例#9
0
        public void Animate()
        {
            // Color Generation
            DRColor.HSV color_gen = _huey.getNextColor((float)Slider1Value, (float)Slider2Value, (float)Slider3Value);
            DRColor.RGB new_color = new DRColor.RGB(color_gen);

            // Position Generation
            Rainbow.Kai[23] = new_color;
            Rainbow.Kai[24] = new_color;
            Push();
            RainbowUtils.update();
            Thread.Sleep(refreshRate);
        }
示例#10
0
        public void Animate()
        {
            // Color Generation
            DRColor.HSV color_gen = _huey.getNextColor((float)Slider1Value, (float)Slider2Value, (float)Slider3Value);
            DRColor.RGB new_color = new DRColor.RGB(color_gen);

            // Position Generation
            Rainbow.Kai[23] = new_color;
            Rainbow.Kai[24] = new_color;
            Push();
            RainbowUtils.update();
            Thread.Sleep(refreshRate);
        }
示例#11
0
        public static void fillBoth(DRColor.RGB rgb)
        {
            if (rgb == null)
            {
                return;
            }

            for (int i = 0; i < Globals.KaiLength; i++)
            {
                Rainbow.KaiSet(i, rgb);
            }
            update();
        }
示例#12
0
        public static DRColor.RGB MagicMix(DRColor.RGB a, DRColor.RGB b, double ratio)
        {
            DRColor.RGB result        = new DRColor.RGB();
            int         redDistance   = (b.Red - a.Red);
            int         greenDistance = (b.Green - a.Green);
            int         blueDistance  = (b.Blue - a.Blue);

            result.Red   = (int)(a.Red + redDistance * ratio);
            result.Green = (int)(a.Green + greenDistance * ratio);
            result.Blue  = (int)(a.Blue + blueDistance * ratio);

            return(result);
        }
示例#13
0
        public static DRColor.RGB MagicMix(DRColor.RGB a, DRColor.RGB b, double ratio)
        {
            DRColor.RGB result = new DRColor.RGB();
            int redDistance = (b.Red - a.Red);
            int greenDistance = (b.Green - a.Green);
            int blueDistance = (b.Blue - a.Blue);

            result.Red = (int)(a.Red + redDistance * ratio);
            result.Green = (int)(a.Green + greenDistance * ratio);
            result.Blue = (int)(a.Blue + blueDistance * ratio);

            return result;
        }
示例#14
0
        // Set Color
        private void addClrBtn_Click(object sender, EventArgs e)
        {
            if (_chooser == null)
            {
                return;
            }
            DRColor.RGB clr = new DRColor.RGB(_chooser.ActiveColor);
            if (clr == null)
            {
                return;
            }

            currentMood.Color_List.Add(clr);
            current_moodSeqUI.Mood = currentMood;
            this.Invalidate();
        }
示例#15
0
        // Creates static arrays and initializes to default color;
        static Rainbow()
        {
            _kai = new DRColor.RGB[Globals.KaiLength];
            _zen = new DRColor.RGB[Globals.ZenLength];

            _kaiBuffer = new DRColor.RGB[Globals.KaiLength];
            _zenBuffer = new DRColor.RGB[Globals.ZenLength];

            for (int i = 0; i < Globals.KaiLength; i++)
            {
                _kai[i] = new DRColor.RGB();
                _kaiBuffer[i] = new DRColor.RGB();
            }

            for (int i = 0; i < Globals.ZenLength; i++)
            {
                _zen[i] = new DRColor.RGB();
                _zenBuffer[i] = new DRColor.RGB();
            }
        }
示例#16
0
        // Creates static arrays and initializes to default color;
        static Rainbow()
        {
            _kai = new DRColor.RGB[Globals.KaiLength];
            _zen = new DRColor.RGB[Globals.ZenLength];

            _kaiBuffer = new DRColor.RGB[Globals.KaiLength];
            _zenBuffer = new DRColor.RGB[Globals.ZenLength];

            for (int i = 0; i < Globals.KaiLength; i++)
            {
                _kai[i]       = new DRColor.RGB();
                _kaiBuffer[i] = new DRColor.RGB();
            }

            for (int i = 0; i < Globals.ZenLength; i++)
            {
                _zen[i]       = new DRColor.RGB();
                _zenBuffer[i] = new DRColor.RGB();
            }
        }
示例#17
0
        // Clears the leds
        private static void clear(int strip)
        {
            DRColor.RGB blank = new DRColor.RGB(0, 0, 0);

            if (strip == 1)
            {
                for (int i = 0; i < Globals.KaiLength; i++)
                {
                    sendClr(i, blank, 1);
                }
                display(1);
            }
            else if (strip == 2)
            {
                for (int i = 0; i < Globals.ZenLength; i++)
                {
                    sendClr(i, blank, 2);
                }
                display(2);
            }
        }
示例#18
0
        public static void Demo()
        {
            DRColor.RGB red   = new DRColor.RGB(127, 0, 0);
            DRColor.RGB green = new DRColor.RGB(0, 0, 127);

            DRColor.RGB proper = Blender.ProperMix(red, green, 0.5);
            DRColor.RGB magic  = Blender.variableMix(red, green, 0.5);

            for (int i = 0; i < Globals.ZenLength; i++)
            {
                if (i < 5)
                {
                    Rainbow.Zen[i] = red;
                }
                else if (i >= 5 && i < 10)
                {
                    Rainbow.Zen[i] = proper;
                }
                else if (i >= 10 && i < 15)
                {
                    Rainbow.Zen[i] = green;
                }
                else if (i >= 20 && i < 25)
                {
                    Rainbow.Zen[i] = green;
                }
                else if (i >= 25 && i < 30)
                {
                    Rainbow.Zen[i] = magic;
                }
                else if (i >= 30 && i < 32)
                {
                    Rainbow.Zen[i] = red;
                }
            }

            Rainbow.ZenUpdate();
            Rainbow.ZenShow();
        }
示例#19
0
        public static void Demo()
        {
            DRColor.RGB red = new DRColor.RGB(127,0,0);
            DRColor.RGB green = new DRColor.RGB(0, 0, 127);

            DRColor.RGB proper = Blender.ProperMix(red, green, 0.5);
            DRColor.RGB magic = Blender.variableMix(red, green, 0.5);

            for(int i = 0; i < Globals.ZenLength; i++)
            {
                if (i < 5)
                {
                    Rainbow.Zen[i] = red;
                }
                else if ( i >= 5 && i < 10)
                {
                    Rainbow.Zen[i] = proper;
                }
                else if (i >= 10 && i < 15)
                {
                    Rainbow.Zen[i] = green;
                }
                else if (i >= 20 && i < 25)
                {
                    Rainbow.Zen[i] = green;
                }
                else if (i >= 25 && i < 30)
                {
                    Rainbow.Zen[i] = magic;
                }
                else if (i >= 30 && i < 32)
                {
                    Rainbow.Zen[i] = red;
                }
            }

            Rainbow.ZenUpdate();
            Rainbow.ZenShow();
        }
示例#20
0
        public void Animation()
        {
            List <DRColor.RGB> color_list = current_moodSeqUI.getColors();

            for (int i = 0; i < color_list.Count; i++)
            {
                DRColor.RGB cur  = color_list[i];
                DRColor.RGB next = color_list[(i + 1) % color_list.Count];

                // Smoothening effect
                double j = 1.0;
                while (j > 0.0)
                {
                    DRColor.RGB show_color = Blender.variableMix(cur, next, j);
                    RainbowUtils.fillBoth(show_color);
                    Thread.Sleep(speed);
                    if (halt)
                    {
                        return;
                    }
                    j -= 0.05;
                }
            }
        }
示例#21
0
        public void Draw(Graphics g, Point mousePoint)
        {
            // You've moved the mouse.
            // Now update the screen to match.

            double distance;
            int degrees;
            Point delta;
            Point newColorPoint;
            Point newBrightnessPoint;
            Point newPoint;

            // Keep track of the previous color pointer point,
            // so you can put the mouse there in case the
            // user has clicked outside the circle.
            newColorPoint = colorPoint;
            newBrightnessPoint = brightnessPoint;

            // Store this away for later use.
            this._g = g;

            if (currentState == MouseState.MouseUp)
            {
                if (!mousePoint.IsEmpty)
                {
                    if (_colorRegion.IsVisible(mousePoint))
                    {
                        // Is the mouse point within the color circle?
                        // If so, you just clicked on the color wheel.
                        currentState = MouseState.ClickOnColor;
                    }
                    else if (_brightnessRegion.IsVisible(mousePoint))
                    {
                        // Is the mouse point within the brightness area?
                        // You clicked on the brightness area.
                        currentState = MouseState.ClickOnBrightness;
                    }
                    else
                    {
                        // Clicked outside the color and the brightness
                        // regions. In that case, just put the
                        // pointers back where they were.
                        currentState = MouseState.ClickOutsideRegion;
                    }
                }
            }

            switch (currentState)
            {
                case MouseState.ClickOnBrightness:
                case MouseState.DragInBrightness:
                    // Calculate new color information
                    // based on the brightness, which may have changed.
                    newPoint = mousePoint;
                    if (newPoint.Y < brightnessMin)
                    {
                        newPoint.Y = brightnessMin;
                    }
                    else if (newPoint.Y > brightnessMax)
                    {
                        newPoint.Y = brightnessMax;
                    }
                    newBrightnessPoint = new Point(brightnessX, newPoint.Y);
                    brightness = (int)((brightnessMax - newPoint.Y) * brightnessScaling);
                    HSV.Value = brightness;
                    RGB = new DRColor.RGB(HSV);
                    break;

                case MouseState.ClickOnColor:
                case MouseState.DragInColor:
                    // Calculate new color information
                    // based on selected color, which may have changed.
                    newColorPoint = mousePoint;

                    // Calculate x and y distance from the center,
                    // and then calculate the angle corresponding to the
                    // new location.
                    delta = new Point(
                        mousePoint.X - centerPoint.X, mousePoint.Y - centerPoint.Y);
                    degrees = CalcDegrees(delta);

                    // Calculate distance from the center to the new point
                    // as angle fraction of the radius_norm. Use your old friend,
                    // the Pythagorean theorem, to calculate this value.
                    distance = Math.Sqrt(delta.X * delta.X + delta.Y * delta.Y) / radius;

                    if (currentState == MouseState.DragInColor)
                    {
                        if (distance > 1)
                        {
                            // Mouse is down, and outside the circle, but you
                            // were previously dragging in the color circle.
                            // What to do?
                            // In that case, move the point to the edge of the
                            // circle at the correct angle.
                            distance = 1;
                            newColorPoint = GetPoint(degrees, radius, centerPoint);
                        }
                    }

                    // Calculate the new HSV and RGB values.
                    HSV.Hue = (int)(degrees * 255 / 360);
                    HSV.Saturation = (int)(distance * 255);
                    HSV.Value = brightness;
                    RGB = new DRColor.RGB(HSV);
                    fullColor = DRColor.HSVtoColor(new DRColor.HSV(HSV.Hue, HSV.Saturation, 255));
                    break;
            }
            selectedColor = DRColor.HSVtoColor(HSV);

            // Raise an event back to the parent form,
            // so the form can update any UI it's using
            // to display selected color values.

            // On the way out, set the new state.
            switch (currentState)
            {
                case MouseState.ClickOnBrightness:
                    currentState = MouseState.DragInBrightness;
                    break;
                case MouseState.ClickOnColor:
                    currentState = MouseState.DragInColor;
                    break;
                case MouseState.ClickOutsideRegion:
                    currentState = MouseState.DragOutsideRegion;
                    break;
            }

            // Store away the current points for next time.
            colorPoint = newColorPoint;
            brightnessPoint = newBrightnessPoint;

            // Draw the gradients and points.
            UpdateDisplay();
            OnColorChanged(RGB, HSV);
        }
示例#22
0
 public static DRColor.RGB equalMix(DRColor.RGB a, DRColor.RGB b)
 {
     return(new DRColor.RGB((a.Red + b.Red) / 2, (a.Green + b.Green) / 2, (a.Blue + b.Blue) / 2));
 }
示例#23
0
 private static DRColor.RGB attenuateStrip(DRColor.RGB clr)
 {
     float dim = 0.3f;
     DRColor.RGB new_clr = new DRColor.RGB((int)(clr.Red * dim), (int)(clr.Green * dim), (int)(clr.Blue * dim));
     return new_clr;
 }
 public ColorChangedEventArgs(DRColor.RGB RGB, DRColor.HSV HSV)
 {
     mRGB = RGB;
     mHSV = HSV;
 }
示例#25
0
 public MoodSeq(DRColor.RGB rgb)
 {
     Color_List.Add(rgb);
 }
示例#26
0
 // Gurantees position isn't out of bounds
 public static void KaiSet(int pos, DRColor.RGB rgb)
 {
     posClamp(ref pos, 1);
     _kai[pos] = rgb;
 }
示例#27
0
 // a * perc + b * (1- perc)
 public static DRColor.RGB variableMix(DRColor.RGB a, DRColor.RGB b, double perc)
 {
     return(new DRColor.RGB((int)(a.Red * perc + b.Red * (1 - perc)), (int)(a.Green * perc + b.Green * (1 - perc)), (int)(a.Blue * perc + b.Blue * (1 - perc))));
 }
示例#28
0
 // If the R, G, or B values change, use this
 // code to update the HSV values and invalidate
 // the color wheel (so it updates the pointers).
 // Check the isInUpdate flag to avoid recursive events
 // when you update the NumericUpdownControls.
 private void HandleRGBScroll(object sender, ScrollEventArgs e)
 {
     _changeType = ChangeStyle.RGB;
     RGB = new DRColor.RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value);
     SetHSV(new DRColor.HSV(RGB));
     SetRGBLabels(RGB);
     this.Invalidate();
     RainbowUtils.fillBoth(RGB);
 }
示例#29
0
 public static DRColor.RGB increaseBrightness(DRColor.RGB rgb, int amt)
 {
     DRColor.HSV hsv = new DRColor.HSV(rgb);
     hsv.Value = hsv.Value + amt > 256 ? 256 : hsv.Value + amt;
     return(new DRColor.RGB(hsv));
 }
示例#30
0
        // Clears the leds
        private static void clear(int strip)
        {
            DRColor.RGB blank = new DRColor.RGB(0, 0, 0);

            if (strip == 1)
            {
                for (int i = 0; i < Globals.KaiLength; i++)
                {
                    sendClr(i, blank, 1);
                }
                display(1);
            }
            else if (strip == 2)
            {
                for (int i = 0; i < Globals.ZenLength; i++)
                {
                    sendClr(i, blank, 2);
                }
                display(2);
            }
        }
示例#31
0
            public HSV(DRColor.RGB rgb)
            {
                // In this function, R, G, and B values must be scaled
                // to be between 0 and 1.
                // HSV.Hue will be angle value between 0 and 360, and
                // HSV.Saturation and value are between 0 and 1.
                // The code must scale these to be between 0 and 255 for
                // the purposes of this application.
                double min;
                double max;
                double delta;

                double r = (double)rgb.Red / 128;
                double g = (double)rgb.Green / 128;
                double b = (double)rgb.Blue / 128;

                double h;
                double s;
                double v;

                min   = Math.Min(Math.Min(r, g), b);
                max   = Math.Max(Math.Max(r, g), b);
                v     = max;
                delta = max - min;
                if (max == 0 || delta == 0)
                {
                    // R, G, and B must be 0, or all the same.
                    // In this case, S is 0, and H is undefined.
                    // Using H = 0 is as good as any...
                    s = 0;
                    h = 0;
                }
                else
                {
                    s = delta / max;
                    if (r == max)
                    {
                        // Between Yellow and Magenta
                        h = (g - b) / delta;
                    }
                    else if (g == max)
                    {
                        // Between Cyan and Yellow
                        h = 2 + (b - r) / delta;
                    }
                    else
                    {
                        // Between Magenta and Cyan
                        h = 4 + (r - g) / delta;
                    }
                }
                // Scale height to be between 0 and 360.
                // This may require adding 360, if the value
                // is negative.
                h *= 60;
                if (h < 0)
                {
                    h += 360;
                }

                // Scale to the requirements of this
                // application. All values are between 0 and 255.
                Hue        = (int)(h / 360 * 255);
                Saturation = (int)(s * 255);
                Value      = (int)(v * 255);
            }
示例#32
0
        protected void OnColorChanged(DRColor.RGB RGB, DRColor.HSV HSV)
        {
            ColorChangedEventArgs e = new ColorChangedEventArgs(RGB, HSV);

            ColorChanged(this, e);
        }
示例#33
0
        public void Draw(Graphics g, Point mousePoint)
        {
            // You've moved the mouse.
            // Now update the screen to match.

            double distance;
            int    degrees;
            Point  delta;
            Point  newColorPoint;
            Point  newBrightnessPoint;
            Point  newPoint;

            // Keep track of the previous color pointer point,
            // so you can put the mouse there in case the
            // user has clicked outside the circle.
            newColorPoint      = colorPoint;
            newBrightnessPoint = brightnessPoint;

            // Store this away for later use.
            this._g = g;

            if (currentState == MouseState.MouseUp)
            {
                if (!mousePoint.IsEmpty)
                {
                    if (_colorRegion.IsVisible(mousePoint))
                    {
                        // Is the mouse point within the color circle?
                        // If so, you just clicked on the color wheel.
                        currentState = MouseState.ClickOnColor;
                    }
                    else if (_brightnessRegion.IsVisible(mousePoint))
                    {
                        // Is the mouse point within the brightness area?
                        // You clicked on the brightness area.
                        currentState = MouseState.ClickOnBrightness;
                    }
                    else
                    {
                        // Clicked outside the color and the brightness
                        // regions. In that case, just put the
                        // pointers back where they were.
                        currentState = MouseState.ClickOutsideRegion;
                    }
                }
            }

            switch (currentState)
            {
            case MouseState.ClickOnBrightness:
            case MouseState.DragInBrightness:
                // Calculate new color information
                // based on the brightness, which may have changed.
                newPoint = mousePoint;
                if (newPoint.Y < brightnessMin)
                {
                    newPoint.Y = brightnessMin;
                }
                else if (newPoint.Y > brightnessMax)
                {
                    newPoint.Y = brightnessMax;
                }
                newBrightnessPoint = new Point(brightnessX, newPoint.Y);
                brightness         = (int)((brightnessMax - newPoint.Y) * brightnessScaling);
                HSV.Value          = brightness;
                RGB = new DRColor.RGB(HSV);
                break;

            case MouseState.ClickOnColor:
            case MouseState.DragInColor:
                // Calculate new color information
                // based on selected color, which may have changed.
                newColorPoint = mousePoint;

                // Calculate x and y distance from the center,
                // and then calculate the angle corresponding to the
                // new location.
                delta = new Point(
                    mousePoint.X - centerPoint.X, mousePoint.Y - centerPoint.Y);
                degrees = CalcDegrees(delta);

                // Calculate distance from the center to the new point
                // as angle fraction of the radius_norm. Use your old friend,
                // the Pythagorean theorem, to calculate this value.
                distance = Math.Sqrt(delta.X * delta.X + delta.Y * delta.Y) / radius;

                if (currentState == MouseState.DragInColor)
                {
                    if (distance > 1)
                    {
                        // Mouse is down, and outside the circle, but you
                        // were previously dragging in the color circle.
                        // What to do?
                        // In that case, move the point to the edge of the
                        // circle at the correct angle.
                        distance      = 1;
                        newColorPoint = GetPoint(degrees, radius, centerPoint);
                    }
                }

                // Calculate the new HSV and RGB values.
                HSV.Hue        = (int)(degrees * 255 / 360);
                HSV.Saturation = (int)(distance * 255);
                HSV.Value      = brightness;
                RGB            = new DRColor.RGB(HSV);
                fullColor      = DRColor.HSVtoColor(new DRColor.HSV(HSV.Hue, HSV.Saturation, 255));
                break;
            }
            selectedColor = DRColor.HSVtoColor(HSV);

            // Raise an event back to the parent form,
            // so the form can update any UI it's using
            // to display selected color values.


            // On the way out, set the new state.
            switch (currentState)
            {
            case MouseState.ClickOnBrightness:
                currentState = MouseState.DragInBrightness;
                break;

            case MouseState.ClickOnColor:
                currentState = MouseState.DragInColor;
                break;

            case MouseState.ClickOutsideRegion:
                currentState = MouseState.DragOutsideRegion;
                break;
            }

            // Store away the current points for next time.
            colorPoint      = newColorPoint;
            brightnessPoint = newBrightnessPoint;

            // Draw the gradients and points.
            UpdateDisplay();
            OnColorChanged(RGB, HSV);
        }
示例#34
0
 public static void ZenSet(int pos, DRColor.RGB rgb)
 {
     posClamp(ref pos, 2);
     _zen[pos] = rgb;
 }
示例#35
0
        private void CalcCoordsAndUpdate(DRColor.HSV HSV)
        {
            // Convert color to real-world coordinates and then calculate
            // the various points. HSV.Hue represents the degrees (0 to 360),
            // HSV.Saturation represents the radius_norm.
            // This procedure doesn't draw anything--it simply
            // updates class-level variables. The UpdateDisplay
            // procedure uses these values to update the screen.

            // Given the angle (HSV.Hue), and distance from
            // the center (HSV.Saturation), and the center,
            // calculate the point corresponding to
            // the selected color, on the color wheel.
            colorPoint = GetPoint((double)HSV.Hue / 255 * 360,
                (double)HSV.Saturation / 255 * radius,
                centerPoint);

            // Given the brightness (HSV.value), calculate the
            // point corresponding to the brightness indicator.
            brightnessPoint = CalcBrightnessPoint(HSV.Value);

            // Store information about the selected color.
            brightness = HSV.Value;
            selectedColor = DRColor.HSVtoColor(HSV);
            RGB = new DRColor.RGB(HSV);

            // The full color is the same as HSV, except that the
            // brightness is set to full (255). This is the top-most
            // color in the brightness gradient.
            fullColor = DRColor.HSVtoColor(new DRColor.HSV(HSV.Hue, HSV.Saturation, 255));
        }
示例#36
0
 public static DRColor.RGB addHighest(DRColor.RGB a, DRColor.RGB b)
 {
     return(new DRColor.RGB(Math.Max(b.Red, a.Red), Math.Max(b.Green, a.Green), Math.Max(b.Blue, a.Blue)));
 }
示例#37
0
 private DRColor.RGB AdjustVal(DRColor.RGB rgb, double perc)
 {
     DRColor.HSV hsv = new DRColor.HSV(rgb);
     hsv.Value = (int)(hsv.Value * perc);
     return(new DRColor.RGB(hsv));
 }
 public ColorChangedEventArgs(DRColor.RGB RGB, DRColor.HSV HSV)
 {
     mRGB = RGB;
     mHSV = HSV;
 }