Exemplo n.º 1
0
 public virtual void SetColor(Color color)
 {
     this.ColorRGB = color;
     this.ColorHSV = HsvColor.FromRgb(color);
     this.CalcRectPointer();
     this.CalcSliderValue();
 }
Exemplo n.º 2
0
        private void GenerateColors(Color canvasColor, Color baseColor)
        {
            CanvasColor = canvasColor;
            BaseColor   = baseColor;

            var canvasHsl = HslColor.FromRgb(canvasColor);
            var canvasHsv = HsvColor.FromRgb(canvasColor);
            var baseHsv   = HsvColor.FromRgb(baseColor);
            var baseHsl   = HslColor.FromRgb(baseColor);

            TextColor          = (canvasHsl.L < 0.4) ? Colors.White : Colors.Black; //GetTextColor(canvasColor);
            TextInactiveColor  = HsvColor.ToRgb(canvasHsv.H, canvasHsv.S, TextColor == Colors.White ? canvasHsv.V + 0.6 : canvasHsv.V - 0.45);
            TextDisabledColor  = HsvColor.ToRgb(canvasHsv.H, canvasHsv.S, TextColor == Colors.White ? canvasHsv.V + 0.3 : canvasHsv.V - 0.15);
            CanvasDarkColor    = HsvColor.ToRgb(canvasHsv.H, canvasHsv.S, TextColor == Colors.White ? canvasHsv.V + 0.5 : canvasHsv.V - 0.5);
            CanvasLightColor   = HsvColor.ToRgb(canvasHsv.H, canvasHsv.S, TextColor == Colors.White ? canvasHsv.V + 0.15 : canvasHsv.V - 0.15);
            CanvasLighterColor = HsvColor.ToRgb(canvasHsv.H, canvasHsv.S, TextColor == Colors.White ? canvasHsv.V + 0.05 : canvasHsv.V - 0.05);
            TextLightColor     = HsvColor.ToRgb(canvasHsv.H, canvasHsv.S, TextColor == Colors.Black ? canvasHsv.V - 0.6 : canvasHsv.V + 0.5);
            TextDarkColor      = HsvColor.ToRgb(canvasHsv.H, canvasHsv.S, TextColor == Colors.White ? canvasHsv.V - 0.4 : canvasHsv.V + 0.6); // GetTextColor(CanvasDarkColor);

            BaseTextColor      = GetTextColor(BaseColor);                                                                                     // baseHsl.L < 0.65 ? Colors.White : Colors.Black;
            BaseLightColor     = HslColor.ToRgb(baseHsl.H, baseHsl.S, baseHsl.L + 0.3);
            BaseLightTextColor = GetTextColor(BaseLightColor);
            BaseDarkColor      = HslColor.ToRgb(baseHsl.H, baseHsl.S, baseHsl.L - 0.1);
            BaseDarkerColor    = HslColor.ToRgb(baseHsl.H, baseHsl.S, baseHsl.L - 0.2);

            ComplementColor = HsvColor.ToRgb(GetComplementHue(baseHsv.H), baseHsv.S, baseHsv.V + (baseHsv.V > 0.5 ? -0.35 : 0));
            var compHsl = HslColor.FromRgb(ComplementColor);
            var compHsv = HsvColor.FromRgb(ComplementColor);

            ComplementLightColor     = HsvColor.ToRgb(compHsv.H, compHsv.S, compHsv.V + 0.2);
            ComplementDarkColor      = HslColor.ToRgb(compHsl.H, compHsl.L - 0.1, compHsl.S);
            ComplementDarkerColor    = HslColor.ToRgb(compHsl.H, compHsl.L - 0.2, compHsl.S);
            ComplementTextColor      = GetTextColor(ComplementColor);
            ComplementLightTextColor = GetTextColor(ComplementLightColor);

            CanvasGradientStartColor = HsvColor.ToRgb(canvasHsv.H, canvasHsv.S, canvasHsv.V > 0 ? canvasHsv.V - 0.01 : canvasHsv.V + 0.08);
            CanvasGradientEndColor   = HsvColor.ToRgb(canvasHsv.H, canvasHsv.S, canvasHsv.V > 0 ? canvasHsv.V - 0.08 : canvasHsv.V + 0.2);
        }
Exemplo n.º 3
0
 public virtual void SetColor(Color rgb, PickerRect.Control ctrlType)
 {
     this.ColorRGB = rgb;
     this.ColorHSV = HsvColor.FromRgb(rgb);
     this.SetColor(ctrlType);
 }
            public override HsvColor GetColorByChannelLevelValue(HsvColor c, double value)
            {
                Color rgbColor = c.ToRgb();

                return(HsvColor.FromRgb(Color.FromScRgb(rgbColor.ScA, rgbColor.ScR, rgbColor.ScG, ColorUtilities.sRgbToScRgb((float)value))));
            }
            public override HsvColor GetColorByColorDetailsMarkerCoord(HsvColor c, Point coord)
            {
                Color rgbColor = c.ToRgb();

                return(HsvColor.FromRgb(Color.FromScRgb(rgbColor.ScA, ColorUtilities.sRgbToScRgb((float)coord.X), ColorUtilities.sRgbToScRgb((float)coord.Y), rgbColor.ScB)));
            }