Пример #1
0
        /// <summary> Override <see cref="PalettePicker.Draw"/>. </summary>
        public override void Draw(CanvasControl sender, CanvasDrawingSession ds, HSV hsv, Vector2 center, float squareHalfWidth, float squareHalfHeight, SolidColorBrush stroke)
        {
            //Palette
            Rect rect = new Rect(center.X - squareHalfWidth, center.Y - squareHalfHeight, squareHalfWidth * 2, squareHalfHeight * 2);

            using (CanvasLinearGradientBrush rainbow = new CanvasLinearGradientBrush(sender, this.BackgroundStops))
            {
                rainbow.StartPoint = new Vector2(center.X - squareHalfWidth, center.Y);
                rainbow.EndPoint   = new Vector2(center.X + squareHalfWidth, center.Y);
                ds.FillRoundedRectangle(rect, 4, 4, rainbow);
            }
            using (CanvasLinearGradientBrush brush = new CanvasLinearGradientBrush(sender, this.ForegroundStops))
            {
                brush.StartPoint = new Vector2(center.X, center.Y - squareHalfHeight);
                brush.EndPoint   = new Vector2(center.X, center.Y + squareHalfHeight);
                ds.FillRoundedRectangle(rect, 4, 4, brush);
            }
            ds.DrawRoundedRectangle(rect, 4, 4, stroke.Color);

            //Thumb
            float px = ((float)hsv.H - 180) * squareHalfWidth / 180 + center.X;
            float py = (50 - (float)hsv.S) * squareHalfHeight / 50 + center.Y;

            ds.FillCircle(px, py, 12, stroke.Color);
            ds.FillCircle(px, py, 11, HSV.HSVtoRGB(hsv));
        }
Пример #2
0
        /// <summary> Override <see cref="PaletteBase.GetSliderBrush"/>. </summary>
        public override GradientStopCollection GetSliderBrush(HSV HSV)
        {
            byte  A = HSV.A;
            float H = HSV.H;
            float S = HSV.S;
            float L = HSV.V;

            return(new GradientStopCollection()
            {
                new GradientStop()
                {
                    Offset = 0,
                    Color = HSV.HSVtoRGB(A, H, 0.0f, L)
                },
                new GradientStop()
                {
                    Offset = 1,
                    Color = HSV.HSVtoRGB(A, H, 100.0f, L)
                },
            });
        }
Пример #3
0
            private Color[] GetColorfulColors(Color color, int count)
            {
                Color[] colors = new Color[count];

                float h    = HSV.RGBtoHSV(color).H;
                float span = 100 / count;

                for (int i = 0; i < count; i++)
                {
                    float v = 100 - i * span;
                    float s = i % 4 * 20 + 20;
                    colors[i] = HSV.HSVtoRGB(255, h, s, v);
                }

                return(colors);
            }
Пример #4
0
        /// <summary> Override <see cref="PaletteBase.GetSliderBrush"/>. </summary>
        public override GradientStopCollection GetSliderBrush(HSV hsv)
        {
            byte  A = hsv.A;
            float H = hsv.H;
            float S = hsv.S;
            float L = hsv.V;

            return(new GradientStopCollection()
            {
                new GradientStop()
                {
                    Offset = 0,
                    Color = HSV.HSVtoRGB(A, 0, S, L)
                },
                new GradientStop()
                {
                    Offset = 0.16666667,
                    Color = HSV.HSVtoRGB(A, 60, S, L)
                },
                new GradientStop()
                {
                    Offset = 0.33333333,
                    Color = HSV.HSVtoRGB(A, 120, S, L)
                },
                new GradientStop()
                {
                    Offset = 0.5,
                    Color = HSV.HSVtoRGB(A, 180, S, L)
                },
                new GradientStop()
                {
                    Offset = 0.66666667,
                    Color = HSV.HSVtoRGB(A, 240, S, L)
                },
                new GradientStop()
                {
                    Offset = 0.83333333,
                    Color = HSV.HSVtoRGB(A, 300, S, L)
                },
                new GradientStop()
                {
                    Offset = 1,
                    Color = HSV.HSVtoRGB(A, 0, S, L)
                },
            });
        }
Пример #5
0
            public static Color CalcWheelColor(float x, float y)
            {
                x = x - 0.5f;
                y = y - 0.5f;

                float saturation = 200.0f * (float)Math.Sqrt(x * x + y * y);

                if (saturation > 100.0f)
                {
                    saturation = 100.0f;
                }

                float hue = y < 0 ?
                            (float)(Math.Atan2(-y, -x) / Math.PI) * 180.0f + 180.0f :
                            (float)(Math.Atan2(y, x) / Math.PI) * 180.0f;

                return(HSV.HSVtoRGB(255, hue, saturation, 100.0f));
            }
Пример #6
0
        /// <summary> Override <see cref="PalettePicker.GetSliderBrush"/>. </summary>
        public override GradientStopCollection GetSliderBrush(HSV hsv)
        {
            byte  A = HSV.A;
            float H = HSV.H;
            float S = HSV.S;
            float V = HSV.V;

            return(new GradientStopCollection()
            {
                new GradientStop()
                {
                    Offset = 0.0f,
                    Color = HSV.HSVtoRGB(A, H, S, 0)
                },
                new GradientStop()
                {
                    Offset = 1.0f,
                    Color = HSV.HSVtoRGB(A, H, S, 100)
                },
            });
        }
Пример #7
0
        /// <summary> Override <see cref="PalettePicker.Draw"/>. </summary>
        public override void Draw(CanvasControl sender, CanvasDrawingSession ds, HSV hsv, Vector2 Center, float squareHalfWidth, float squareHalfHeight, SolidColorBrush stroke)
        {
            //Palette
            Rect rect = new Rect(Center.X - squareHalfWidth, Center.Y - squareHalfHeight, squareHalfWidth * 2, squareHalfHeight * 2);

            ds.FillRoundedRectangle(rect, 4, 4, new CanvasLinearGradientBrush(sender, Windows.UI.Colors.White, HSV.HSVtoRGB(hsv.H))
            {
                StartPoint = new Vector2(Center.X - squareHalfWidth, Center.Y), EndPoint = new Vector2(Center.X + squareHalfWidth, Center.Y)
            });
            ds.FillRoundedRectangle(rect, 4, 4, new CanvasLinearGradientBrush(sender, Windows.UI.Colors.Transparent, Windows.UI.Colors.Black)
            {
                StartPoint = new Vector2(Center.X, Center.Y - squareHalfHeight), EndPoint = new Vector2(Center.X, Center.Y + squareHalfHeight)
            });
            ds.DrawRoundedRectangle(rect, 4, 4, stroke.Color);

            //Thumb
            float px = ((float)hsv.S - 50) * squareHalfWidth / 50 + Center.X;
            float py = (50 - (float)hsv.V) * squareHalfHeight / 50 + Center.Y;

            ds.FillCircle(px, py, 12, stroke.Color);
            ds.FillCircle(px, py, 11, HSV.HSVtoRGB(hsv));
        }