Exemple #1
0
        private void mandelbrot() // calculate all points
        {
            int   x, y;
            float h, b, alt = 0.0f;

            action = false;
            Color color = Color.Black;
            Pen   myPen = new Pen(color);

            for (x = 0; x < x1; x += 2)
            {
                for (y = 0; y < y1; y++)
                {
                    h = pointcolour(xstart + xzoom * (double)x, ystart + yzoom * (double)y);
                    if (h != alt)
                    {
                        b = 1.0f - h * h; //brightness

                        color = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255));

                        myPen = new Pen(color);
                        alt   = h;
                    }
                    g1.DrawLine(myPen, x, y, x + 1, y);
                }
            }
            action = true;
        }
Exemple #2
0
        private void mandelbrot() // calculate all points
        {
            Pen   tempPen = null;
            int   x, y;
            float h, b, alt = 0.0f;

            action      = false;
            this.Cursor = Cursors.WaitCursor; //setCursor(c1);

            for (x = 0; x < x1; x += 2)
            {
                for (y = 0; y < y1; y++)
                {
                    h = pointcolour(xstart + xzoom * (double)x, ystart + yzoom * (double)y); // color value
                    if (h != alt)
                    {
                        b = 1.0f - h * h;                                                   // brightness

                        col = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255)); // draws the fractal

                        tempPen = new Pen(col);
                        //djm
                        alt = h;
                    }
                    g1.DrawLine(tempPen, x, y, x + 1, y);
                }
            }

            this.Cursor = Cursors.Cross; //setCursor(c2);
            action      = true;
        }
        protected void OnDialerDragDelta(object sender, ManipulationDeltaRoutedEventArgs e)
        {
            double accumatedDist;

            if (Math.Abs(e.Cumulative.Translation.X) > Math.Abs(e.Cumulative.Translation.Y))
            {
                accumatedDist = e.Cumulative.Translation.X;
            }
            else
            {
                accumatedDist = e.Cumulative.Translation.Y;
            }

            double angle = startAngle + accumatedDist * rotateScaleFactor;

            DialerTransform.Angle = angle;
            if (angle > 360)
            {
                angle = angle % 360;
            }

            CurrentValue = (int)((angle / 360.0f) * Light.MaxHue);

            Color currentColor = HSBColor.FromHSB(CurrentValue, (int)HSBColorSource.S, (int)HSBColorSource.B);

            ColorIndicatorBrush.Color = currentColor;

            if (ValueChanging != null)
            {
                ValueChanging(this, null);
            }
        }
Exemple #4
0
        private Color GetInversColor(Color color)
        {
            HSBColor hsbColor = ConverterColor.ToHSBColor(color);
            //return (hsbColor.B > 127) ? Colors.White : Colors.Black;
            var newBlack      = (hsbColor.B > 127) ? hsbColor.B - 125 : hsbColor.B + 125;
            var newSaturation = (hsbColor.S > 127) ? hsbColor.S - 125 : hsbColor.S + 125;

            return(HSBColor.FromHSB(hsbColor.A, hsbColor.H, newSaturation, newBlack));
        }
Exemple #5
0
        private void BrightnessSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
        {
            HSBColorSource.B = (float)BrightnessSlider.Value;
            SaturationSliderHighlightBrush.Color = HSBColor.FromHSB(HSBColorSource);

            if (ValueChanged != null)
            {
                ValueChanged(this, null);
            }
        }
Exemple #6
0
        /// <summary>
        /// 按比例,获取指定色以比例为饱和度的色
        /// </summary>
        /// <param name="scale">比例, 0-1</param>
        /// <param name="orgcolor">原始色</param>
        /// <returns></returns>
        public static Color getColorSaturation(double scale, Color orgcolor)
        {
            Color color;

            System.Drawing.Color cOrg = System.Drawing.Color.FromArgb(orgcolor.A, orgcolor.R, orgcolor.G, orgcolor.B);
            //color = FromAhsb(255, cOrg.GetHue(), (float)scale, 0.5f);
            System.Drawing.Color dc = HSBColor.FromHSB(new HSBColor(255, cOrg.GetHue(), (float)scale * 255, 255f));
            color = Color.FromArgb(dc.A, dc.R, dc.G, dc.B);
            return(color);
        }
        public Color Tint(Color color)
        {
            HSBColor h = HSBColor.FromColor(color);
            HSBColor t = HSBColor.FromColor(_tint);

            h.H = t.H;
            //h.B -= 50;

            return(HSBColor.FromHSB(h));
        }
        protected virtual void OnHSBColorSourceChanged()
        {
            // Rotate to current value
            CurrentValue = (int)HSBColorSource.H;
            RotateToCurrentValue();

            Color currentColor = HSBColor.FromHSB(HSBColorSource);

            ColorIndicatorBrush.Color = currentColor;
        }
        private void BrightnessSlider_ValueChanged(object sender, RangeBaseValueChangedEventArgs e)
        {
            LightSource.Brightness = (int)BrightnessSlider.Value;
            BridgeManager.Instance.InvalidateLightProperties(LightSource);

            SaturationSliderHighlightBrush.Color = HSBColor.FromHSB(LightSource.Hue, LightSource.Saturation, LightSource.Brightness);

            var attrs = new { bri = LightSource.Brightness };

            UpdateLightStateAsync(attrs);
        }
        private void OnHueValueChanged(object sender, EventArgs e)
        {
            LightSource.Hue = HueDialer.CurrentValue;
            BridgeManager.Instance.InvalidateLightProperties(LightSource);

            var attrs = new { hue = HueDialer.CurrentValue };

            UpdateLightStateAsync(attrs);

            SaturationSliderHighlightBrush.Color = HSBColor.FromHSB(LightSource.Hue, LightSource.Saturation, LightSource.Brightness);
        }
Exemple #11
0
        private void mandelbrot() // calculate all points
        {
            int   x, y;
            float h, b, alt = 0.0f;

            //Pen pen = new Pen(Color.White);

            action = false;
            if (cursorUpdate)
            {
                Cursor.Current = c1;
            }
            //showStatus("Mandelbrot-Set will be produced - please wait...");
            statusLbl.Text = "Mandelbrot - Set will be produced - please wait...";
            for (x = 0; x < x1; x += 2)
            {
                for (y = 0; y < y1; y++)
                {
                    h = pointcolour(xstart + xzoom * (double)x, ystart + yzoom * (double)y); // color value
                    //HSBcol = new HSBColor(h, 0.8f, b);
                    //Pen pen = new Pen(HSBcol.Color);
                    if (h != alt)
                    {
                        b = 1.0f - h * h; // brightnes
                        ///djm added
                        ///HSBcol.fromHSB(h,0.8f,b); //convert hsb to rgb then make a Java Color
                        ///Color col = new Color(0,HSBcol.rChan,HSBcol.gChan,HSBcol.bChan);
                        ///g1.setColor(col);
                        //djm end
                        //djm added to convert to RGB from HSB
                        Color col = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255));

                        pen = new Pen(col);

                        //djm test
                        //Color col = Color.getHSBColor(h, 0.8f, b);
                        //int red = col.getRed();
                        //int green = col.getGreen();
                        //int blue = col.getBlue();
                        //djm
                        alt = h;
                    }
                    g1.DrawLine(pen, x, y, x + 1, y);
                }
            }
            //showStatus("Mandelbrot-Set ready - please select zoom area with pressed mouse.");
            statusLbl.Text = "Mandelbrot - Set ready - please select zoom area with pressed mouse.";
            if (cursorUpdate)
            {
                Cursor.Current = c2;
            }
            action = true;
        }
 private void UpdateDisplayList()
 {
     if (LightSource.IsOn)
     {
         Color rgbColor = HSBColor.FromHSB(LightSource.Hue, LightSource.Saturation, LightSource.Brightness);
         ColorIndicator.Fill = new SolidColorBrush(rgbColor);
     }
     else
     {
         ColorIndicator.Fill = offFill;
     }
 }
Exemple #13
0
        private void UpdateDisplayList()
        {
            if (HSBColorSource == null)
            {
                return;
            }

            Color rgbColor = HSBColor.FromHSB((int)HSBColorSource.H, (int)HSBColorSource.S, (int)HSBColorSource.B);

            ColorIndicator.Fill = new SolidColorBrush(rgbColor);

            NameLabel.Text = HSBColorSource.ToRGBString();
        }
Exemple #14
0
        private void UpdateColorPreview()
        {
            Color fillColor = HSBColor.FromHSB(HSBColorSource);

            ColorNameLabel.Text = HSBColorSource.ToRGBString();

            double maxSize     = PreviewBorder.Width - 15;
            double previewSize = maxSize * (HSBColorSource.B / Light.MaxBrightness);

            ThumbnailView.Width  = previewSize;
            ThumbnailView.Height = previewSize;
            ThumbnailFill.Color  = fillColor;
        }
Exemple #15
0
        /// <summary>
        /// 按比例,获取两个色之间的色
        /// </summary>
        /// <param name="scale">比例, 0-1之间的数据</param>
        /// <param name="colorStart">开始颜色</param>
        /// <param name="colorEnd">结束颜色</param>
        /// <returns></returns>
        public static Color getColorBetween(double scale, Color colorStart, Color colorEnd)
        {
            Color color;

            System.Drawing.Color cStart = System.Drawing.Color.FromArgb(colorStart.A, colorStart.R, colorStart.G, colorStart.B);
            System.Drawing.Color cEnd   = System.Drawing.Color.FromArgb(colorEnd.A, colorEnd.R, colorEnd.G, colorEnd.B);
            float hstart = cStart.GetHue();
            float hend   = cEnd.GetHue();
            float hue    = hstart + (hend - hstart) * (float)scale;

            System.Drawing.Color dc = HSBColor.FromHSB(new HSBColor(255, hue * 255 / 360, 255f, 255f));
            color = Color.FromArgb(dc.A, dc.R, dc.G, dc.B);
            return(color);
        }
Exemple #16
0
        /// <summary>
        /// Constructor
        /// </summary>
        public LightOverviewControl()
        {
            this.InitializeComponent();

            var stops = 7;
            var step  = Light.MaxHue / stops;

            for (int i = 0; i < stops; i++)
            {
                var gs = new GradientStop();
                gs.Offset = (float)i / stops;
                gs.Color  = HSBColor.FromHSB(i * step, 100, 255);
                HueGradient.GradientStops.Add(gs);
            }
        }
        protected override void OnHSBColorSourceChanged()
        {
            HueDialer.HSBColorSource = HSBColorSource;

            // Set slider thumb positions
            SaturationSliderHighlightBrush.Color = HSBColor.FromHSB(HueDialer.CurrentValue, 255, 255);

            if (SaturationSlider.Value != HSBColorSource.S)
            {
                SaturationSlider.Value = HSBColorSource.S;
            }

            if (BrightnessSlider.Value != HSBColorSource.B)
            {
                BrightnessSlider.Value = HSBColorSource.B;
            }
        }
Exemple #18
0
        /// <summary>
        /// Called when [rgbValue changed].
        /// </summary>
        protected virtual void OnValueChanged()
        {
            if (mode == ColorSheme.HSB)
            {
                rgbValue = HSBColor.FromHSB(trackBar1.Value, trackBar2.Value, trackBar3.Value);
            }
            else
            {
                rgbValue = Color.FromArgb(trackBar1.Value, trackBar2.Value, trackBar3.Value);
            }
            resultPanel.BackColor = rgbValue;

            if (ValueChanged != null)
            {
                ValueChanged(this, new EventArgs());
            }
        }
Exemple #19
0
        private void mandelbrot() // calculate all points
        {
            int   x, y;
            float h, b, alt = 0.0f;
            Pen   pen;
            Color color;

            action          = false;
            this.Cursor     = c1;
            messageBox.Text = "Mandelbrot-Set will be produced - Please wait...";
            messageBox.Refresh();
            for (x = 0; x < x1; x += 2)
            {
                for (y = 0; y < y1; y++)
                {
                    if (cycle)
                    {
                        h = pointcolour(xstart + xzoom * x, ystart + yzoom * y) + (float)cycleValue;
                    }
                    else
                    {
                        h = pointcolour(xstart + xzoom * x, ystart + yzoom * y); // color value
                    }

                    if (h != alt)
                    {
                        b     = 1.0f - h * h; // brightnes
                        color = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255));
                        pen   = new Pen(color);
                        g1.DrawLine(pen, x, y, x + 1, y);
                        alt = h;
                    }
                    b     = 1.0f - h * h; // brightnes
                    color = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255));
                    pen   = new Pen(color);
                    g1.DrawLine(pen, x, y, x + 1, y);
                }
            }
            messageBox.Text = "Mandelbrot-Set ready - Please select zoom area";
            messageBox.Refresh();
            this.Cursor = c2;
            action      = true;
        }
        private void UpdateDisplayList()
        {
            if (LightSource.IsOn)
            {
                NameLabel.Foreground = onLabelBrush;

                Color rgbColor = HSBColor.FromHSB(LightSource.Hue, LightSource.Saturation, LightSource.Brightness);
                ColorIndicator.Fill   = new SolidColorBrush(rgbColor);
                ColorIndicator.Stroke = onStroke;
            }
            else
            {
                NameLabel.Foreground = offLabelBrush;

                ColorIndicator.Fill   = offFill;
                ColorIndicator.Stroke = offStroke;
            }

            NameLabel.Text = LightSource.Name;
        }
Exemple #21
0
        private void mandelbrot() // calculate all points
        {
            Pen   tempPen = null;
            Color col;
            int   x, y;
            float h, b, alt = 0.0f;

            action         = false;
            Cursor.Current = Cursors.WaitCursor; //setCursor(c1);

            for (x = 0; x < x1; x += 2)
            {
                for (y = 0; y < y1; y++)
                {
                    h = pointcolour(xstart + xzoom * (double)x, ystart + yzoom * (double)y); // color value
                    if (h != alt)
                    {
                        b = 1.0f - h * h; // brightness

                        /*HSB.fromHSB(h * 255, 0.8f * 255, b * 255);
                        *  int red = Convert.ToInt32(HSB.rChan); //.getRed();
                        *  int green = Convert.ToInt32(HSB.gChan); //.getGreen();
                        *  int blue = Convert.ToInt32(HSB.bChan); //.getBlue();
                        *
                        *  col = Color.FromArgb(0, red, green, blue);*/

                        col = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255));

                        tempPen = new Pen(col);
                        //djm
                        alt = h;
                    }
                    g1.DrawLine(tempPen, x, y, x + 1, y);
                }
            }

            Cursor.Current = Cursors.Cross; //setCursor(c2);
            action         = true;
        }
Exemple #22
0
        protected override void OnHSBColorSourceChanged()
        {
            if (HSBColorSource == null)
            {
                return;
            }

            int stops = 7;

            HueGradient.GradientStops.Clear();
            for (int i = 0; i <= stops; i++)
            {
                GradientStop gs = new GradientStop();
                gs.Offset = (float)i / stops;

                int hue = (int)Math.Floor(Light.MaxHue * gs.Offset);
                gs.Color = HSBColor.FromHSB(hue, (int)HSBColorSource.S / 2, (int)HSBColorSource.B);
                HueGradient.GradientStops.Add(gs);
            }

            SaturationSliderHighlightBrush.Color = HSBColor.FromHSB(HSBColorSource);

            // Set slider thumb positions
            if (HueSlider.Value != HSBColorSource.H)
            {
                HueSlider.Value = HSBColorSource.H;
            }

            if (SaturationSlider.Value != HSBColorSource.S)
            {
                SaturationSlider.Value = HSBColorSource.S;
            }

            if (BrightnessSlider.Value != HSBColorSource.B)
            {
                BrightnessSlider.Value = HSBColorSource.B;
            }
        }
Exemple #23
0
        private void Mandelbrot() // calculate all points
        {
            int   x, y;
            float h, b;//, alt = 0.0f;

            action = false;
            //setCursor(c1);
            //showStatus("Mandelbrot-Set will be produced - please wait...");
            for (x = 0; x < x1; x += 2)
            {
                for (y = 0; y < y1; y++)
                {
                    h = pointcolour(xstart + xzoom * (double)x, ystart + yzoom * (double)y);
                    b = 1.0f - h * h; //brightness of the mandelbrot
                    Color color = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255));
                    Pen   pen   = new Pen(color);

                    // Is essentially java code, not needed to produce the mandelbrot correctly

                    /*if (h != alt)
                     * {
                     *  b = 1.0f - h * h; // brightness
                     *  //Color background = HSBColor.FromHSB(new HSBColor(h, 0.8f, b));
                     *  //g1.FillRegion
                     *  Color color = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255));
                     *
                     *  alt = h;
                     *  Pen pen = new Pen(color);
                     *  g1.DrawLine(pen, x, y, x + 1, y);
                     * }*/

                    g1.DrawLine(pen, x, y, x + 1, y);
                }
            }
            //showStatus("Mandelbrot-Set ready - please select zoom area with pressed mouse.");
            //setCursor(c2);
            action = true;
        }
        private void mandelbrot() // calculate all points
        {
            int   x, y;
            float h, b, alt = 0.0f;

            test        = true;
            action      = false;
            this.Cursor = c1;
            for (x = 0; x < x1; x += 2)
            {
                for (y = 0; y < y1; y++)
                {
                    h = pointcolour(xstart + xzoom * (double)x, ystart + yzoom * (double)y);
                    // color value
                    Color color = new Color();
                    using (g1 = Graphics.FromImage(bitmap))
                    {
                        if (h != alt)
                        {
                            b = 1.0f - h * h; // brightnes

                            ///djm added

                            ///HSBcol.fromHSB(h,0.8f,b);
                            ///
                            //convert hsb to rgb then make a Java Color

                            color = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255));

                            ///g1.setColor(col);
                            //djm end
                            //djm added to convert to RGB from HSB

                            //g1.setColor(Color.getHSBColor(h, 0.8f, b));
                            //djm test

                            //  Color col = Color.FromArgb(0, 0, 0, 0);

                            //red = Color.Red;
                            // green = Color.Green;
                            // blue = Color.Blue;

                            //djm
                            alt = h;
                            Pen p = new Pen(color);
                            g1.DrawLine(p, x, y, x + 1, y);
                        }
                        else
                        {
                            b     = 1.0f - h * h; // brightnes
                            color = HSBColor.FromHSB(new HSBColor(h * 255, 0.8f * 255, b * 255));
                            Pen p = new Pen(color);
                            g1.DrawLine(p, x, y, x + 1, y);
                        }
                    }
                }
            }
            //showStatus("Mandelbrot-Set ready - please select zoom area with pressed mouse.");
            this.Cursor = c2;
            action      = true;
        }