Exemplo n.º 1
0
        /// <summary>
        /// Gets a cool Highlight brush for highlighting things.
        /// </summary>
        /// <param name="box">The rectangle in the box</param>
        /// <param name="selectionHighlight">The color to use for the higlight</param>
        /// <returns>The highlight brush.</returns>
        public static IBrush HighlightBrush(Rectangle box, Rgba32 selectionHighlight)
        {
            float med    = selectionHighlight.GetBrightness();
            float bright = med + 0.05f;

            if (bright > 1f)
            {
                bright = 1f;
            }
            float dark = med - 0.05f;

            if (dark < 0f)
            {
                dark = 0f;
            }
            Rgba32 brtCol = ColorFromHsl(selectionHighlight.GetHue(), selectionHighlight.GetSaturation(), bright);
            Rgba32 drkCol = ColorFromHsl(selectionHighlight.GetHue(), selectionHighlight.GetSaturation(), dark);
            Point  p1     = new Point(box.X, box.Y - box.Height / 2);
            Point  p2     = new Point(box.X + box.Width, box.Y - box.Height / 2);

            ColorStop[] colorStops = new ColorStop[2]
            {
                new ColorStop(0, brtCol),
                new ColorStop(0.5f, drkCol)
            };
            return(new LinearGradientBrush(p1, p2, GradientRepetitionMode.None, colorStops));
        }