Ejemplo n.º 1
0
        /// <summary>Creates the a texture with a rectangle with given color and border.</summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="borderWidth">Width of the border.</param>
        /// <param name="color">The color.</param>
        /// <param name="borderColor">Color of the border.</param>
        /// <returns>A color map with a rectangle image in the colorMap.</returns>
        public static ColorMap CreateRectangleColorMap(int width, int height, int borderWidth, GUIColor color, GUIColor borderColor)
        {
            var colorMap = new ColorMap(width, height);

            var left   = borderWidth;
            var right  = width - borderWidth;
            var top    = borderWidth;
            var bottom = height - borderWidth;

            GUIColor colorToUse;

            for (var wY = 0; wY < height; wY++)
            {
                for (var wX = 0; wX < width; wX++)
                {
                    colorToUse = color;

                    if (wX < left || wX >= right)
                    {
                        colorToUse = borderColor;
                    }

                    if (wY < top || wY >= bottom)
                    {
                        colorToUse = borderColor;
                    }

                    colorMap.Set(wX, wY, colorToUse);
                }
            }

            return(colorMap);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Modifies an existing brightness level. </summary>
        /// <remarks>
        /// To reduce brightness use a number smaller then 1. To increase brightness use a number larger then 1. </remarks>
        /// <param name="colorToModify">The original color.</param>
        /// <param name="brightness">The luminance delta.</param>
        /// <returns>An adjusted color.</returns>
        public static GUIColor ModifyBrightness(GUIColor colorToModify, double brightness)
        {
            var hsl = RGBToHSL(colorToModify);

            hsl.L *= brightness;
            return(HSLToRGB(hsl));
        }
Ejemplo n.º 3
0
        /// <summary>Converts RGB to CMYK.</summary>
        /// <param name="colorToConvert">A color to convert.</param>
        /// <returns>A CMYK object.</returns>
        public static CMYK RGBToCMYK(GUIColor colorToConvert)
        // ReSharper restore InconsistentNaming
        {
            var cmyk = new CMYK();
            var low  = 1.0;

            cmyk.Cyan = (double)(255 - colorToConvert.R) / 255;
            if (low > cmyk.Cyan)
            {
                low = cmyk.Cyan;
            }

            cmyk.Magenta = (double)(255 - colorToConvert.G) / 255;
            if (low > cmyk.Magenta)
            {
                low = cmyk.Magenta;
            }

            cmyk.Yellow = (double)(255 - colorToConvert.B) / 255;
            if (low > cmyk.Yellow)
            {
                low = cmyk.Yellow;
            }

            if (low > 0.0)
            {
                cmyk.KeyBlack = low;
            }

            return(cmyk);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets the absolute Hue level. </summary>
        /// <remarks>Accepted values 0-1.</remarks>
        /// <param name="color">An original color.</param>
        /// <param name="hue">The Hue value to impose.</param>
        /// <returns>An adjusted color.</returns>
        public static GUIColor SetHue(GUIColor color, double hue)
        {
            var hsl = RGBToHSL(color);

            hsl.H = hue;
            return(HSLToRGB(hsl));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Sets the absolute saturation level. </summary>
        /// <remarks>Accepted values 0-1.</remarks>
        /// <param name="colorToChange">An original color.</param>
        /// <param name="saturation">The saturation value to impose.</param>
        /// <returns>An adjusted color.</returns>
        public static GUIColor SetSaturation(GUIColor colorToChange, double saturation)
        {
            var hsl = RGBToHSL(colorToChange);

            hsl.S = saturation;
            return(HSLToRGB(hsl));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Sets the absolute brightness of a color.</summary>
        /// <param name="colorToChange">Original color.</param>
        /// <param name="brightness">The luminance level to impose.</param>
        /// <returns>an adjusted color.</returns>
        public static GUIColor SetBrightness(GUIColor colorToChange, double brightness)
        {
            var hsl = RGBToHSL(colorToChange);

            hsl.L = brightness;
            return(HSLToRGB(hsl));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Modifies an existing Saturation level. </summary>
        /// <remarks>
        /// To reduce Saturation use a number smaller then 1. To increase Saturation use a number larger then 1. </remarks>
        /// <param name="colorToModify">The original color.</param>
        /// <param name="saturation">The saturation delta.</param>
        /// <returns>An adjusted color.</returns>
        public static GUIColor ModifySaturation(GUIColor colorToModify, double saturation)
        {
            var hsl = RGBToHSL(colorToModify);

            hsl.S *= saturation;
            return(HSLToRGB(hsl));
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ColorBoxGradient"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 public ColorBoxGradient(string name) : base(name)
 {
     this.hsl = new HSL { H = 0.3, S = 0.6, L = 0.8 };
     this.rgba = AdobeColors.HSLToRGB(this.hsl);
     this.drawStyle = DrawStyle.Hue;
     Config.Width = Theme.ControlWidth;
     Config.Height = Theme.ControlWidth;
     this.redrawControlFlag = true;
 }
Ejemplo n.º 9
0
        /// <summary>Creates the circle texture.</summary>
        /// <param name="radius">The radius.</param>
        /// <param name="borderWidth">Width of the border.</param>
        /// <param name="borderInnerTransitionWidth">Width of the border inner transition.</param>
        /// <param name="borderOuterTransitionWidth">Width of the border outer transition.</param>
        /// <param name="color">The color.</param>
        /// <param name="borderColor">Color of the border.</param>
        /// <returns>A array with a representation of a circle inside.</returns>
        public static GUIColor[] CreateCircleTexture(int radius, int borderWidth, int borderInnerTransitionWidth, int borderOuterTransitionWidth, GUIColor color, GUIColor borderColor)
        {
            int x;
            var y        = -1;
            var diameter = (radius + 2) * 2;

            // DVector2 center = new DVector2(0, 0);
            var center = new DVector2((diameter - 1) / 2f, (diameter - 1) / 2f);

            var colors = new GUIColor[diameter * diameter];

            for (var i = 0; i < colors.Length; i++)
            {
                if (i % diameter == 0)
                {
                    y += 1;
                }

                x = i % diameter;

                // var distance = new DVector2(Math.Abs(center.X - x), Math.Abs(center.Y - y));
                var diff   = new DVector2(x, y) - center;
                var length = diff.Length; // distance.Length();

                if (length > radius)
                {
                    colors[i] = GUIColor.Transparent();
                }
                else if (length >= radius - borderOuterTransitionWidth)
                {
                    var transitionAmount = (length - (radius - borderOuterTransitionWidth)) / borderOuterTransitionWidth;
                    transitionAmount = 255 * (1 - transitionAmount);
                    colors[i]        = new GUIColor(borderColor.R, borderColor.G, borderColor.B, (byte)transitionAmount);
                }
                else if (length > radius - (borderWidth + borderOuterTransitionWidth))
                {
                    colors[i] = borderColor;
                }
                else if (length >= radius - (borderWidth + borderOuterTransitionWidth + borderInnerTransitionWidth))
                {
                    var transitionAmount = (length
                                            - (radius
                                               - (borderWidth + borderOuterTransitionWidth + borderInnerTransitionWidth)))
                                           / (borderInnerTransitionWidth + 1);
                    colors[i] = new GUIColor(
                        (byte)Lerp(color.R, borderColor.R, transitionAmount),
                        (byte)Lerp(color.G, borderColor.G, transitionAmount),
                        (byte)Lerp(color.B, borderColor.B, transitionAmount));
                }
                else
                {
                    colors[i] = color;
                }
            }

            return(colors);
        }
Ejemplo n.º 10
0
        /// <summary>Creates the circle texture.</summary>
        /// <param name="radius">The radius.</param>
        /// <param name="borderWidth">Width of the border.</param>
        /// <param name="borderInnerTransitionWidth">Width of the border inner transition.</param>
        /// <param name="borderOuterTransitionWidth">Width of the border outer transition.</param>
        /// <param name="color">The color.</param>
        /// <param name="borderColor">Color of the border.</param>
        /// <returns>A array with a representation of a circle inside.</returns>
        public static GUIColor[] CreateCircleTexture(int radius, int borderWidth, int borderInnerTransitionWidth, int borderOuterTransitionWidth, GUIColor color, GUIColor borderColor)
        {
            int x;
            var y = -1;
            var diameter = (radius + 2) * 2;

            // DVector2 center = new DVector2(0, 0);
            var center = new DVector2((diameter - 1) / 2f, (diameter - 1) / 2f);

            var colors = new GUIColor[diameter * diameter];

            for (var i = 0; i < colors.Length; i++)
            {
                if (i % diameter == 0)
                {
                    y += 1;
                }

                x = i % diameter;

                // var distance = new DVector2(Math.Abs(center.X - x), Math.Abs(center.Y - y));
                var diff = new DVector2(x, y) - center;
                var length = diff.Length; // distance.Length();

                if (length > radius)
                {
                    colors[i] = GUIColor.Transparent();
                }
                else if (length >= radius - borderOuterTransitionWidth)
                {
                    var transitionAmount = (length - (radius - borderOuterTransitionWidth)) / borderOuterTransitionWidth;
                    transitionAmount = 255 * (1 - transitionAmount);
                    colors[i] = new GUIColor(borderColor.R, borderColor.G, borderColor.B, (byte)transitionAmount);
                }
                else if (length > radius - (borderWidth + borderOuterTransitionWidth))
                {
                    colors[i] = borderColor;
                }
                else if (length >= radius - (borderWidth + borderOuterTransitionWidth + borderInnerTransitionWidth))
                {
                    var transitionAmount = (length
                                            - (radius
                                               - (borderWidth + borderOuterTransitionWidth + borderInnerTransitionWidth)))
                                           / (borderInnerTransitionWidth + 1);
                    colors[i] = new GUIColor(
                        (byte)Lerp(color.R, borderColor.R, transitionAmount),
                        (byte)Lerp(color.G, borderColor.G, transitionAmount),
                        (byte)Lerp(color.B, borderColor.B, transitionAmount));
                }
                else
                {
                    colors[i] = color;
                }
            }

            return colors;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Converts a color from HSL to RGB. </summary>
        /// <remarks>Adapted from the algorithm in Foley and Van-Dam.</remarks>
        /// <param name="colorToConvert">The HSL value.</param>
        /// <returns>A Color structure containing the equivalent RGB values.</returns>
        public static GUIColor HSLToRGB(HSL colorToConvert)
        {
#if DEBUG
            if (colorToConvert == null)
            {
                throw new ArgumentNullException("colorToConvert");
            }
#endif

            // ReSharper disable JoinDeclarationAndInitializer
            int    max, mid, min;
            double q;

            // ReSharper restore JoinDeclarationAndInitializer
            max = Round(colorToConvert.L * 255);
            min = Round((1.0 - colorToConvert.S) * (colorToConvert.L / 1.0) * 255);
            q   = (double)(max - min) / 255;

            if (colorToConvert.H >= 0 && colorToConvert.H <= (double)1 / 6)
            {
                mid = Round((((colorToConvert.H - 0) * q) * 1530) + min);
                return(GUIColor.FromARGB(max, mid, min));
            }

            if (colorToConvert.H <= (double)1 / 3)
            {
                mid = Round((-((colorToConvert.H - ((double)1 / 6)) * q) * 1530) + max);
                return(GUIColor.FromARGB(mid, max, min));
            }

            if (colorToConvert.H <= 0.5)
            {
                mid = Round((((colorToConvert.H - ((double)1 / 3)) * q) * 1530) + min);
                return(GUIColor.FromARGB(min, max, mid));
            }

            if (colorToConvert.H <= (double)2 / 3)
            {
                mid = Round((-((colorToConvert.H - 0.5) * q) * 1530) + max);
                return(GUIColor.FromARGB(min, mid, max));
            }

            if (colorToConvert.H <= (double)5 / 6)
            {
                mid = Round((((colorToConvert.H - ((double)2 / 3)) * q) * 1530) + min);
                return(GUIColor.FromARGB(mid, min, max));
            }

            if (colorToConvert.H <= 1.0)
            {
                mid = Round((-((colorToConvert.H - ((double)5 / 6)) * q) * 1530) + max);
                return(GUIColor.FromARGB(max, min, mid));
            }

            return(GUIColor.FromARGB(0, 0, 0));
        }
Ejemplo n.º 12
0
        /// <summary>Tries to set the specified color at location x,y.</summary>
        /// <param name="locationX">The location x.</param>
        /// <param name="locationY">The location y.</param>
        /// <param name="color">The color.</param>
        /// <returns>true when there is success setting it.</returns>
        public bool TrySet(int locationX, int locationY, GUIColor color)
        {
            var pos = locationX + (locationY * this.width);

            if (pos > this.colors.Length)
            {
                return(false);
            }

            this.colors[pos] = color;
            return(true);
        }
Ejemplo n.º 13
0
        /// <summary>Creates a line with given height and width.</summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="color">The color.</param>
        /// <returns>A color array containing a representation of a line.</returns>
        public static GUIColor[] CreateFlat(int width, int height, GUIColor color)
        {
            // Texture2D texture2D = new Texture2D(graphicsDevice, 2, lineWidth + 2);
            var count      = width * height;
            var colorArray = new GUIColor[count];

            for (var i = 0; i < count; i++)
            {
                colorArray[i] = color;
            }

            return(colorArray);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Called when graphics resources need to be loaded. 
        /// 
        /// Use this for the usage of :
        /// - creation of the internal embedded controls.
        /// - setting of the variables and resources in this control
        /// - to load any game-specific graphics resources
        /// - take over the config width and height and use it into State
        /// - overriding how this item looks like , by settings its texture or theme
        /// 
        /// Call base.LoadContent before you do your override code, this will cause :
        /// - State.SourceRectangle to be reset to the Config.Size 
        /// </summary>
        public override void LoadContent()
        {
            base.LoadContent();

            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
            this.UpdateDrawSourceRectangleByConfig();

            const int Width = 10;
            const int Height = 10;
            var color = new GUIColor(0, 0, 255);
            this.CurrentTextureName = this.Manager.ImageCompositor.CreateFlatTexture(this.Name + "-Background", Width, Height, color);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ColorSliderVertical"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public ColorSliderVertical(string name) : base(name)
        {
            // Initialize Colors
            this.hsl = new HSL { H = 1.0, S = 1.0, L = 1.0 };
            this.rgba = AdobeColors.HSLToRGB(this.hsl);

            // pick a format to show
            this.drawStyle = DrawStyle.Hue;

            this.Padding = 9;

            Config.Width = Theme.ControlHeight;
            Config.Height = Theme.ControlWidth;
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Sit in between the start and end color by specified percentage.
        /// </summary>
        /// <param name="startColor">The start color.</param>
        /// <param name="endColor">The end color.</param>
        /// <param name="percentage">The percentage.</param>
        /// <returns>The interpolated color.</returns>
        /// <exception cref="System.ArgumentException">value must be between 0 and 1.</exception>
        public static GUIColor Lerp(GUIColor startColor, GUIColor endColor, float percentage)
        {
            if (percentage < 0 || percentage > 1)
            {
                throw new ArgumentException("Value must be between 0 and 1");
            }

            var r = (byte)(((endColor.R - startColor.R) * percentage) + startColor.R);
            var g = (byte)(((endColor.G - startColor.G) * percentage) + startColor.G);
            var b = (byte)(((endColor.B - startColor.B) * percentage) + startColor.B);
            var a = (byte)(((endColor.A - startColor.A) * percentage) + startColor.A);

            return(new GUIColor(r, g, b, a));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Reverses this color-array in this instance.
        /// </summary>
        /// <returns>A reversed color-map.</returns>
        public ColorMap Reverse()
        {
            var reverseData = new GUIColor[this.Width * this.Height];
            var r           = reverseData.Length - 1;

            foreach (var guiColor in this.colors)
            {
                reverseData[r] = guiColor;
                r--;
            }

            var map = new ColorMap(reverseData, this.width, this.height);

            return(map);
        }
Ejemplo n.º 18
0
        /// <summary>Converts CMYK to RGB.</summary>
        /// <param name="colorToConvert">A color to convert.</param>
        /// <returns>A Color object.</returns>
        public static GUIColor CMYKToRGB(CMYK colorToConvert)
        {
#if DEBUG
            if (colorToConvert == null)
            {
                throw new ArgumentNullException("colorToConvert");
            }
#endif

            int red, green, blue;
            red   = Round(255 - (255 * colorToConvert.Cyan));
            green = Round(255 - (255 * colorToConvert.Magenta));
            blue  = Round(255 - (255 * colorToConvert.Yellow));

            return(GUIColor.FromARGB(red, green, blue));
        }
Ejemplo n.º 19
0
        private static void SetSelectionRectangle(Rectangle rectangle, TextBoxSelectionBox textBoxSelectionBox, GUIColor color)
        {
            if (rectangle.Width >= 1 && rectangle.Height >= 1)
            {
                textBoxSelectionBox.CurrentTextureName = textBoxSelectionBox.Manager.ImageCompositor.CreateRectangleTexture(textBoxSelectionBox.Name, (int)rectangle.Width, (int)rectangle.Height, 0, GUIColor.White(), GUIColor.White());
                var size = textBoxSelectionBox.Manager.ImageCompositor.ReadSizeTexture(textBoxSelectionBox.CurrentTextureName);
                var count = (int)size.X * (int)size.Y;

                var colorArray = new GUIColor[count];
                for (var i = 0; i < count; i++)
                {
                    colorArray[i] = color;
                }

                var map = new ColorMap(colorArray, (int)size.X, (int)size.Y);

                textBoxSelectionBox.Manager.ImageCompositor.UpdateTexture(textBoxSelectionBox.CurrentTextureName, map);

                textBoxSelectionBox.ConfigActive = true;
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Contrasts the color.
        /// </summary>
        /// <param name="color">The color.</param>
        /// <returns>The contrasted color.</returns>
        public static GUIColor ContrastColor(GUIColor color)
        {
            int d;

            // Counting the perceptive luminance - human eye favors green color...
            var ar = 0.299 * color.R;
            var ag = 0.587 * color.G;
            var ab = 0.114 * color.B;
            var a  = 1 - ((ar + ag + ab) / 255);

            if (a < 0.5)
            {
                d = 0; // bright colors - black font
            }
            else
            {
                d = 255; // dark colors - white font
            }

            return(GUIColor.FromARGB(d, d, d));
        }
Ejemplo n.º 21
0
        /// <summary>Creates a rectangle texture.</summary>
        /// <param name="preferredName">The preferred name to use.</param>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="borderWidth">Width of the border.</param>
        /// <param name="fillColor">Color of the fill.</param>
        /// <param name="borderColor">Color of the border.</param>
        /// <returns>The URL to the created texture resource that looks like a rectangle.</returns>
        /// <exception cref="ArgumentException">Width can not be zero or less;width
        /// or
        /// height can not be zero or less;height
        /// or
        /// Control name can not be null;preferredName
        /// or
        /// Border width can not be smaller then zero;borderWidth.</exception>
        public override string CreateRectangleTexture(string preferredName, int width, int height, int borderWidth, GUIColor fillColor, GUIColor borderColor)
        {
#if DEBUG
            if (width <= 0)
            {
                throw new ArgumentException("width can not be zero or less", "width");
            }

            if (height <= 0)
            {
                throw new ArgumentException("height can not be zero or less", "height");
            }

            if (string.IsNullOrEmpty(preferredName))
            {
                throw new ArgumentException("Control name can not be null", "preferredName");
            }

            if (borderWidth < 0)
            {
                throw new ArgumentException("Border width can not be smaller then zero", "borderWidth");
            }
#endif

            var textureName = this.resourcesTexture.Create(preferredName, width, height, fillColor);

            // var colordata = RectangleBrush.CreateRectangleColorMap(width, height,borderWidth,1,1, fillColor, borderColor);
            var colordata = ColorMapDrawer.CreateRectangleColorMap(width, height, borderWidth, fillColor, borderColor);
            // var colordata = ColorMapDrawer.CreateRoundedRectangleColorMap(
            //                                                            width,
            //                                                            height,
            //                                                            borderWidth,
            //                                                            20,
            //                                                            fillColor,
            //                                                            borderColor);
            this.resourcesTexture.Update(textureName, colordata.ToArray());

            return textureName;
        }
Ejemplo n.º 22
0
        private static ColorMap CreateRoundedCornerColorMap(int innerRadius, int outerRadius, GUIColor innerColor, GUIColor outerColor)
        {
            int x;
            int y;
            int width = outerRadius;
            int height = outerRadius;

            var array = new ColorMap(width, height);
            for (x = 0; x < +width; x++)
            {
                for (y = 0; y < +height; y++)
                {
                    // get the distance to x,y
                    var r = Math.Sqrt((x * x) + (y * y));

                    if (r < innerRadius)
                    {
                        array.Set(x, y, innerColor);
                    }
                    else if (r >= innerRadius && r < outerRadius)
                    {
                        array.Set(x, y, outerColor);
                    }
                }
            }

            return array;
        }
Ejemplo n.º 23
0
 /// <summary>Sets the specified color at location x,y.</summary>
 /// <param name="locationX">The location x.</param>
 /// <param name="locationY">The location y.</param>
 /// <param name="color">The color.</param>
 public void Set(int locationX, int locationY, GUIColor color)
 {
     this.colors[locationX + (locationY * this.width)] = color;
 }
Ejemplo n.º 24
0
 private static void CreateEmptyRectangleColorMap(ref ColorMap colorMap, int imageWidth, int imageHeight, GUIColor colorToUse)
 {
     for (var wY = 0; wY < imageHeight; wY++)
     {
         for (var wX = 0; wX < imageWidth; wX++)
         {
             colorMap.Set(wX, wY, colorToUse);
         }
     }
 }
Ejemplo n.º 25
0
        private static void SetPixel(ref ColorMap colorMap, int imageWidth, int imageHeight, float x, float y, GUIColor colorToUse)
        {
            // all is centered , so shift it back t bitmap coordinates

            // shift x to bitmap location
            var tempX = (imageWidth / 2) + (int)x;

            if (tempX >= imageWidth)
            {
                return;
            }

            if (tempX <= 0)
            {
                return;
            }

            // shift y to bitmap location
            var tempY = (imageHeight / 2) + (int)y;

            if (tempY >= imageHeight)
            {
                return;
            }

            if (tempY <= 0)
            {
                return;
            }

            // get the location into my array
            colorMap.Set(tempX, tempY, colorToUse);
        }
Ejemplo n.º 26
0
        /// <summary>Creates a high quality rounded corner color-map.</summary>
        /// <param name="innerRadius">The inner radius.</param>
        /// <param name="outerRadius">The outer radius.</param>
        /// <param name="innerColor">Color of the inner.</param>
        /// <param name="outerColor">Color of the outer.</param>
        /// <returns>A color-map with a high quality rounded corner inside.</returns>
        private static ColorMap CreateHighQualityRoundedCornerColorMap(int innerRadius, int outerRadius, GUIColor innerColor, GUIColor outerColor)
        {
            int       x;
            int       y;
            const int GrowFactor = 4;
            int       width      = outerRadius * GrowFactor;
            int       height     = outerRadius * GrowFactor;

            // create a grown round corner
            var array = new ColorMap(width, height);

            for (x = 0; x < +width; x++)
            {
                for (y = 0; y < +height; y++)
                {
                    // get the distance to x,y
                    var r = Math.Sqrt((x * x) + (y * y));

                    if (r < innerRadius * GrowFactor)
                    {
                        array.Set(x, y, innerColor);
                    }
                    else if (r >= innerRadius * GrowFactor && r < outerRadius * GrowFactor)
                    {
                        array.Set(x, y, outerColor);
                    }
                }
            }

            // and shrink it
            array = ResizeImage(array, outerRadius, outerRadius);

            return(array);
        }
Ejemplo n.º 27
0
 /// <summary>
 /// Draws a horizontal line on the given color-map.
 /// </summary>
 /// <param name="colorMap">The color map to draw into.</param>
 /// <param name="y">The y position to draw the line.</param>
 /// <param name="startX">The start x to draw the line.</param>
 /// <param name="endX">The end x to draw the line.</param>
 /// <param name="colorToUse">The color to use.</param>
 private static void DrawHorizontalLineOnColorMap(ref ColorMap colorMap, int y, int startX, int endX, GUIColor colorToUse)
 {
     for (var x = startX; x < endX; x++)
     {
         colorMap.Set(x, y, colorToUse);
     }
 }
Ejemplo n.º 28
0
        /// <summary>
        /// Called when graphics resources need to be loaded.
        ///
        /// Use this for the usage of :
        /// - creation of the internal embedded controls.
        /// - setting of the variables and resources in this control
        /// - to load any game-specific graphics resources
        /// - take over the config width and height and use it into State
        /// - overriding how this item looks like , by settings its texture or theme
        ///
        /// Call base.LoadContent before you do your override code, this will cause :
        /// - State.SourceRectangle to be reset to the Config.Size
        /// </summary>
        public override void LoadContent()
        {
            if (this.hsl == null)
            {
                this.hsl = new HSL { H = 1.0, S = 1.0, L = 1.0 };
                this.rgba = AdobeColors.HSLToRGB(this.hsl);
            }

            Config.Width = Theme.ControlHeight;
            Config.Height = Theme.ControlWidth;

            // create left indicator
            this.IndicatorLeft = new ColorSliderVerticalIndicator(Name + "-indicatorLeft")
            {
                Side = Side.Left,
                Manager = Manager
            };
            this.AddControl(this.IndicatorLeft);

            // create right indicator
            this.IndicatorRight = new ColorSliderVerticalIndicator(Name + "-indicatorRight")
            {
                Side = Side.Right,
                Manager = Manager
            };
            this.AddControl(this.IndicatorRight);

            this.SetIndicatorPosition(0);

            this.RedrawControl();

            // do the basic stuff
            base.LoadContent();
            this.UpdateDrawPositionByConfigAndParent();
            this.UpdateDrawSizeByConfig();
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Draws a color filled rectangle on given color-map.
 /// </summary>
 /// <param name="colorMap">The color map.</param>
 /// <param name="startX">The start x.</param>
 /// <param name="startY">The start y.</param>
 /// <param name="endX">The end x.</param>
 /// <param name="endY">The end y.</param>
 /// <param name="colorToUse">The color to use.</param>
 private static void DrawRectangleOnColorMap(ref ColorMap colorMap, int startX, int startY, int endX, int endY, GUIColor colorToUse)
 {
     for (var x = startX; x < endX; x++)
     {
         for (var y = startY; y < endY; y++)
         {
             colorMap.Set(x, y, colorToUse);
         }
     }
 }
Ejemplo n.º 30
0
 /// <summary>Creates a rectangle texture. </summary>
 /// <param name="preferredName">The preferred name to use.</param>
 /// <param name="width">The width.</param>
 /// <param name="height">The height.</param>
 /// <param name="borderWidth">Width of the border.</param>
 /// <param name="fillColor">Color of the fill.</param>
 /// <param name="borderColor">Color of the border.</param>
 /// <returns>The URL to the created texture resource that looks like a rectangle.</returns>
 public abstract string CreateRectangleTexture(string preferredName, int width, int height, int borderWidth, GUIColor fillColor, GUIColor borderColor);
Ejemplo n.º 31
0
 /// <summary>Draws the string using specified location font and color.</summary>
 /// <param name="fontName">Name of the font.</param>
 /// <param name="text">The text to draw.</param>
 /// <param name="position">The position of the text.</param>
 /// <param name="fontColor">Color of the font.</param>
 public abstract void DrawString(string fontName, string text, DVector2 position, GUIColor fontColor);
Ejemplo n.º 32
0
 /// <summary>
 /// Draws the vertical line on the given color-map.
 /// </summary>
 /// <param name="colorMap">The color map to draw into.</param>
 /// <param name="x">The x position to draw the line.</param>
 /// <param name="startY">The start y to draw the line.</param>
 /// <param name="endY">The end y to draw the line.</param>
 /// <param name="colorToUse">The color to use.</param>
 private static void DrawVerticalLineOnColorMap(ref ColorMap colorMap, int x, int startY, int endY, GUIColor colorToUse)
 {
     for (int y = startY; y < endY; y++)
     {
         colorMap.Set(x, y, colorToUse);
     }
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Draws a horizontal line on the given color-map.
 /// </summary>
 /// <param name="colorMap">The color map to draw into.</param>
 /// <param name="y">The y position to draw the line.</param>
 /// <param name="startX">The start x to draw the line.</param>
 /// <param name="endX">The end x to draw the line.</param>
 /// <param name="colorToUse">The color to use.</param>
 private static void DrawHorizontalLineOnColorMap(ref ColorMap colorMap, int y, int startX, int endX, GUIColor colorToUse)
 {
     for (var x = startX; x < endX; x++)
     {
         colorMap.Set(x, y, colorToUse);
     }
 }
Ejemplo n.º 34
0
        /// <summary>Creates a high quality rounded corner color-map.</summary>
        /// <param name="innerRadius">The inner radius.</param>
        /// <param name="outerRadius">The outer radius.</param>
        /// <param name="innerColor">Color of the inner.</param>
        /// <param name="outerColor">Color of the outer.</param>
        /// <returns>A color-map with a high quality rounded corner inside.</returns>
        private static ColorMap CreateHighQualityRoundedCornerColorMap(int innerRadius, int outerRadius, GUIColor innerColor, GUIColor outerColor)
        {
            int x;
            int y;
            const int GrowFactor = 4;
            int width = outerRadius * GrowFactor;
            int height = outerRadius * GrowFactor;

            // create a grown round corner
            var array = new ColorMap(width, height);
            for (x = 0; x < +width; x++)
            {
                for (y = 0; y < +height; y++)
                {
                    // get the distance to x,y
                    var r = Math.Sqrt((x * x) + (y * y));

                    if (r < innerRadius * GrowFactor)
                    {
                        array.Set(x, y, innerColor);
                    }
                    else if (r >= innerRadius * GrowFactor && r < outerRadius * GrowFactor)
                    {
                        array.Set(x, y, outerColor);
                    }
                }
            }

            // and shrink it
            array = ResizeImage(array, outerRadius, outerRadius);

            return array;
        }
Ejemplo n.º 35
0
 /// <summary>
 /// Modifies an existing Saturation level. </summary>
 /// <remarks>
 /// To reduce Saturation use a number smaller then 1. To increase Saturation use a number larger then 1. </remarks>
 /// <param name="colorToModify">The original color.</param>
 /// <param name="saturation">The saturation delta.</param>
 /// <returns>An adjusted color.</returns>
 public static GUIColor ModifySaturation(GUIColor colorToModify, double saturation)
 {
     var hsl = RGBToHSL(colorToModify);
     hsl.S *= saturation;
     return HSLToRGB(hsl);
 }
Ejemplo n.º 36
0
 /// <summary>
 /// Sets the absolute Hue level. </summary>
 /// <remarks>Accepted values 0-1.</remarks>
 /// <param name="color">An original color.</param>
 /// <param name="hue">The Hue value to impose.</param>
 /// <returns>An adjusted color.</returns>
 public static GUIColor SetHue(GUIColor color, double hue)
 {
     var hsl = RGBToHSL(color);
     hsl.H = hue;
     return HSLToRGB(hsl);
 }
Ejemplo n.º 37
0
        /// <summary>Converts RGB to HSL.</summary>
        /// <remarks>Takes advantage of what is already built in to .NET by using the Color.GetHue, Color.GetSaturation and Color.GetBrightness methods.</remarks>
        /// <param name="colorToConvert">A Color to convert.</param>
        /// <returns>An HSL value.</returns>
        public static HSL RGBToHSL(GUIColor colorToConvert)
        {
            var hsl = new HSL();

            // ReSharper disable JoinDeclarationAndInitializer
            int max, min, diff;
            // ReSharper restore JoinDeclarationAndInitializer

            //	Of our RGB values, assign the highest value to Max, and the Smallest to Min
            if (colorToConvert.R > colorToConvert.G)
            {
                max = colorToConvert.R;
                min = colorToConvert.G;
            }
            else
            {
                max = colorToConvert.G;
                min = colorToConvert.R;
            }

            if (colorToConvert.B > max)
            {
                max = colorToConvert.B;
            }
            else if (colorToConvert.B < min)
            {
                min = colorToConvert.B;
            }

            diff = max - min;

            //	Luminance - a.k.a. Brightness - Adobe photoshop uses the logic that the
            //	site VBspeed regards (regarded) as too primitive = superior decides the 
            //	level of brightness.
            hsl.L = (double)max / 255;

            //	Saturation
            if (max == 0)
            {
                hsl.S = 0; //	Protecting from the impossible operation of division by zero.
            }
            else
            {
                hsl.S = (double)diff / max; //	The logic of Adobe Photoshops is this simple.
            }

            //	Hue		R is situated at the angel of 360 degrees; 
            //			G 120 degrees
            //			B 240 degrees
            double q;
            if (diff == 0)
            {
                q = 0; // Protecting from the impossible operation of division by zero.
            }
            else
            {
                q = (double)60 / diff;
            }

            if (max == colorToConvert.R)
            {
                if (colorToConvert.G < colorToConvert.B)
                {
                    hsl.H = (360 + (q * (colorToConvert.G - colorToConvert.B))) / 360;
                }
                else
                {
                    hsl.H = q * (colorToConvert.G - colorToConvert.B) / 360;
                }
            }
            else if (max == colorToConvert.G)
            {
                hsl.H = (120 + (q * (colorToConvert.B - colorToConvert.R))) / 360;
            }
            else if (max == colorToConvert.B)
            {
                hsl.H = (240 + (q * (colorToConvert.R - colorToConvert.G))) / 360;
            }
            else
            {
                hsl.H = 0.0;
            }

            return hsl;
        }
Ejemplo n.º 38
0
 /// <summary>
 /// Draws the vertical line on the given color-map.
 /// </summary>
 /// <param name="colorMap">The color map to draw into.</param>
 /// <param name="x">The x position to draw the line.</param>
 /// <param name="startY">The start y to draw the line.</param>
 /// <param name="endY">The end y to draw the line.</param>
 /// <param name="colorToUse">The color to use.</param>
 private static void DrawVerticalLineOnColorMap(ref ColorMap colorMap, int x, int startY, int endY, GUIColor colorToUse)
 {
     for (int y = startY; y < endY; y++)
     {
         colorMap.Set(x, y, colorToUse);
     }
 }
Ejemplo n.º 39
0
        /// <summary>Converts RGB to CMYK.</summary>
        /// <param name="colorToConvert">A color to convert.</param>
        /// <returns>A CMYK object.</returns>
        public static CMYK RGBToCMYK(GUIColor colorToConvert)
        // ReSharper restore InconsistentNaming
        {
            var cmyk = new CMYK();
            var low = 1.0;

            cmyk.Cyan = (double)(255 - colorToConvert.R) / 255;
            if (low > cmyk.Cyan)
            {
                low = cmyk.Cyan;
            }

            cmyk.Magenta = (double)(255 - colorToConvert.G) / 255;
            if (low > cmyk.Magenta)
            {
                low = cmyk.Magenta;
            }

            cmyk.Yellow = (double)(255 - colorToConvert.B) / 255;
            if (low > cmyk.Yellow)
            {
                low = cmyk.Yellow;
            }

            if (low > 0.0)
            {
                cmyk.KeyBlack = low;
            }

            return cmyk;
        }
Ejemplo n.º 40
0
        /// <summary>Converts RGB to HSL.</summary>
        /// <remarks>Takes advantage of what is already built in to .NET by using the Color.GetHue, Color.GetSaturation and Color.GetBrightness methods.</remarks>
        /// <param name="colorToConvert">A Color to convert.</param>
        /// <returns>An HSL value.</returns>
        public static HSL RGBToHSL(GUIColor colorToConvert)
        {
            var hsl = new HSL();

            // ReSharper disable JoinDeclarationAndInitializer
            int max, min, diff;

            // ReSharper restore JoinDeclarationAndInitializer

            //	Of our RGB values, assign the highest value to Max, and the Smallest to Min
            if (colorToConvert.R > colorToConvert.G)
            {
                max = colorToConvert.R;
                min = colorToConvert.G;
            }
            else
            {
                max = colorToConvert.G;
                min = colorToConvert.R;
            }

            if (colorToConvert.B > max)
            {
                max = colorToConvert.B;
            }
            else if (colorToConvert.B < min)
            {
                min = colorToConvert.B;
            }

            diff = max - min;

            //	Luminance - a.k.a. Brightness - Adobe photoshop uses the logic that the
            //	site VBspeed regards (regarded) as too primitive = superior decides the
            //	level of brightness.
            hsl.L = (double)max / 255;

            //	Saturation
            if (max == 0)
            {
                hsl.S = 0; //	Protecting from the impossible operation of division by zero.
            }
            else
            {
                hsl.S = (double)diff / max; //	The logic of Adobe Photoshops is this simple.
            }

            //	Hue		R is situated at the angel of 360 degrees;
            //			G 120 degrees
            //			B 240 degrees
            double q;

            if (diff == 0)
            {
                q = 0; // Protecting from the impossible operation of division by zero.
            }
            else
            {
                q = (double)60 / diff;
            }

            if (max == colorToConvert.R)
            {
                if (colorToConvert.G < colorToConvert.B)
                {
                    hsl.H = (360 + (q * (colorToConvert.G - colorToConvert.B))) / 360;
                }
                else
                {
                    hsl.H = q * (colorToConvert.G - colorToConvert.B) / 360;
                }
            }
            else if (max == colorToConvert.G)
            {
                hsl.H = (120 + (q * (colorToConvert.B - colorToConvert.R))) / 360;
            }
            else if (max == colorToConvert.B)
            {
                hsl.H = (240 + (q * (colorToConvert.R - colorToConvert.G))) / 360;
            }
            else
            {
                hsl.H = 0.0;
            }

            return(hsl);
        }
Ejemplo n.º 41
0
        /// <summary>
        /// Contrasts the color.
        /// </summary>
        /// <param name="color">The color.</param>
        /// <returns>The contrasted color.</returns>
        public static GUIColor ContrastColor(GUIColor color)
        {
            int d;

            // Counting the perceptive luminance - human eye favors green color... 
            var ar = 0.299 * color.R;
            var ag = 0.587 * color.G;
            var ab = 0.114 * color.B;
            var a = 1 - ((ar + ag + ab) / 255);

            if (a < 0.5)
            {
                d = 0; // bright colors - black font
            }
            else
            {
                d = 255; // dark colors - white font
            }

            return GUIColor.FromARGB(d, d, d);
        }
Ejemplo n.º 42
0
        private static ColorMap CreateRoundedCornerColorMap(int innerRadius, int outerRadius, GUIColor innerColor, GUIColor outerColor)
        {
            int x;
            int y;
            int width  = outerRadius;
            int height = outerRadius;

            var array = new ColorMap(width, height);

            for (x = 0; x < +width; x++)
            {
                for (y = 0; y < +height; y++)
                {
                    // get the distance to x,y
                    var r = Math.Sqrt((x * x) + (y * y));

                    if (r < innerRadius)
                    {
                        array.Set(x, y, innerColor);
                    }
                    else if (r >= innerRadius && r < outerRadius)
                    {
                        array.Set(x, y, outerColor);
                    }
                }
            }

            return(array);
        }
Ejemplo n.º 43
0
 /// <summary>
 /// Sets the absolute brightness of a color.</summary>
 /// <param name="colorToChange">Original color.</param>
 /// <param name="brightness">The luminance level to impose.</param>
 /// <returns>an adjusted color.</returns>
 public static GUIColor SetBrightness(GUIColor colorToChange, double brightness)
 {
     var hsl = RGBToHSL(colorToChange);
     hsl.L = brightness;
     return HSLToRGB(hsl);
 }
Ejemplo n.º 44
0
        /// <summary>
        /// Sit in between the start and end color by specified percentage.
        /// </summary>
        /// <param name="startColor">The start color.</param>
        /// <param name="endColor">The end color.</param>
        /// <param name="percentage">The percentage.</param>
        /// <returns>The interpolated color.</returns>
        /// <exception cref="System.ArgumentException">value must be between 0 and 1.</exception>
        public static GUIColor Lerp(GUIColor startColor, GUIColor endColor, float percentage)
        {
            if (percentage < 0 || percentage > 1)
            {
                throw new ArgumentException("Value must be between 0 and 1");
            }

            var r = (byte)(((endColor.R - startColor.R) * percentage) + startColor.R);
            var g = (byte)(((endColor.G - startColor.G) * percentage) + startColor.G);
            var b = (byte)(((endColor.B - startColor.B) * percentage) + startColor.B);
            var a = (byte)(((endColor.A - startColor.A) * percentage) + startColor.A);

            return new GUIColor(r, g, b, a);
        }
Ejemplo n.º 45
0
 /// <summary>
 /// Modifies an existing brightness level. </summary>
 /// <remarks>
 /// To reduce brightness use a number smaller then 1. To increase brightness use a number larger then 1. </remarks>
 /// <param name="colorToModify">The original color.</param>
 /// <param name="brightness">The luminance delta.</param>
 /// <returns>An adjusted color.</returns>
 public static GUIColor ModifyBrightness(GUIColor colorToModify, double brightness)
 {
     var hsl = RGBToHSL(colorToModify);
     hsl.L *= brightness;
     return HSLToRGB(hsl);
 }
Ejemplo n.º 46
0
        /// <summary>Creates a rounded rectangle texture with given color and border.</summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="borderWidth">Width of the border.</param>
        /// <param name="cornerSize">Size of the corner.</param>
        /// <param name="fillColor">Color of the fill.</param>
        /// <param name="borderColor">Color of the border.</param>
        /// <returns>A color-map with a rounded rectangle inside.</returns>
        public static ColorMap CreateRoundedRectangleColorMap(int width, int height, int borderWidth, int cornerSize, GUIColor fillColor, GUIColor borderColor)
        {
            var colorMap = new ColorMap(width, height);

            if (cornerSize > width / 2)
            {
                cornerSize = width / 2;
            }

            if (cornerSize > height / 2)
            {
                cornerSize = height / 2;
            }

            // draw top horizontal lines
            for (var y = 0; y < cornerSize; y++)
            {
                if (y < borderWidth)
                {
                    DrawHorizontalLineOnColorMap(ref colorMap, y, cornerSize, width - cornerSize, borderColor);
                }
                else
                {
                    DrawHorizontalLineOnColorMap(ref colorMap, y, cornerSize, width - cornerSize, fillColor);
                }
            }

            // draw bottom horizontal lines
            for (var y = height - cornerSize; y < height; y++)
            {
                if (y < height - borderWidth)
                {
                    DrawHorizontalLineOnColorMap(ref colorMap, y, cornerSize, width - cornerSize, fillColor);
                }
                else
                {
                    DrawHorizontalLineOnColorMap(ref colorMap, y, cornerSize, width - cornerSize, borderColor);
                }
            }

            // draw left vertical lines
            for (var x = 0; x < cornerSize; x++)
            {
                if (x < borderWidth)
                {
                    DrawVerticalLineOnColorMap(ref colorMap, x, cornerSize, height - cornerSize, borderColor);
                }
                else
                {
                    DrawVerticalLineOnColorMap(ref colorMap, x, cornerSize, height - cornerSize, fillColor);
                }
            }

            // draw right vertical lines
            for (var x = width - cornerSize; x < width; x++)
            {
                if (x < width - borderWidth)
                {
                    DrawVerticalLineOnColorMap(ref colorMap, x, cornerSize, height - cornerSize, fillColor);
                }
                else
                {
                    DrawVerticalLineOnColorMap(ref colorMap, x, cornerSize, height - cornerSize, borderColor);
                }
            }

            // draw internal rectangle
            DrawRectangleOnColorMap(ref colorMap, cornerSize, cornerSize, width - cornerSize, height - cornerSize, fillColor);

            // create the bottom right corner
            var bottomRightCorner = CreateHighQualityRoundedCornerColorMap(cornerSize - borderWidth, cornerSize, fillColor, borderColor);

            PlaceSourceColorMapIntoTargetColorMap(bottomRightCorner, ref colorMap, width - cornerSize, height - cornerSize);

            // create the bottom left corner
            var bottomLeftCorner = FlipColorMapHorizontal(bottomRightCorner);

            PlaceSourceColorMapIntoTargetColorMap(bottomLeftCorner, ref colorMap, 0, height - cornerSize);

            // create the top right corner
            var topRightCorner = FlipColorMapHVertical(bottomRightCorner);

            PlaceSourceColorMapIntoTargetColorMap(topRightCorner, ref colorMap, width - cornerSize, 0);

            // create the bottom left corner
            var topLeftCorner = FlipColorMapHorizontal(topRightCorner);

            PlaceSourceColorMapIntoTargetColorMap(topLeftCorner, ref colorMap, 0, 0);

            return(colorMap);
        }
Ejemplo n.º 47
0
 /// <summary>
 /// Sets the absolute saturation level. </summary>
 /// <remarks>Accepted values 0-1.</remarks>
 /// <param name="colorToChange">An original color.</param>
 /// <param name="saturation">The saturation value to impose.</param>
 /// <returns>An adjusted color.</returns>
 public static GUIColor SetSaturation(GUIColor colorToChange, double saturation)
 {
     var hsl = RGBToHSL(colorToChange);
     hsl.S = saturation;
     return HSLToRGB(hsl);
 }
Ejemplo n.º 48
0
 /// <summary>
 /// Draws a color filled rectangle on given color-map.
 /// </summary>
 /// <param name="colorMap">The color map.</param>
 /// <param name="startX">The start x.</param>
 /// <param name="startY">The start y.</param>
 /// <param name="endX">The end x.</param>
 /// <param name="endY">The end y.</param>
 /// <param name="colorToUse">The color to use.</param>
 private static void DrawRectangleOnColorMap(ref ColorMap colorMap, int startX, int startY, int endX, int endY, GUIColor colorToUse)
 {
     for (var x = startX; x < endX; x++)
     {
         for (var y = startY; y < endY; y++)
         {
             colorMap.Set(x, y, colorToUse);
         }
     }
 }
Ejemplo n.º 49
0
        private static void SetPixel(ref ColorMap colorMap, int imageWidth, int imageHeight, float x, float y, GUIColor colorToUse)
        {
            // all is centered , so shift it back t bitmap coordinates

            // shift x to bitmap location
            var tempX = (imageWidth / 2) + (int)x;
            if (tempX >= imageWidth)
            {
                return;
            }

            if (tempX <= 0)
            {
                return;
            }

            // shift y to bitmap location
            var tempY = (imageHeight / 2) + (int)y;
            if (tempY >= imageHeight)
            {
                return;
            }

            if (tempY <= 0)
            {
                return;
            }

            // get the location into my array
            colorMap.Set(tempX, tempY, colorToUse);
        }
Ejemplo n.º 50
0
 /// <summary>
 /// Draws the specified texture using specified draw-state , with a tint color.
 /// </summary>
 /// <param name="name">The name of the item to draw.</param>
 /// <param name="drawState">The state that contains all the info to draw the item.</param>
 /// <param name="tintColor">The color to use to tint the shown item.</param>
 public abstract void Draw(string name, DrawState drawState, GUIColor tintColor);
Ejemplo n.º 51
0
        /// <summary>Creates a line with given height and width.</summary>
        /// <param name="width">The width.</param>
        /// <param name="height">The height.</param>
        /// <param name="color">The color.</param>
        /// <returns>A color array containing a representation of a line.</returns>
        public static GUIColor[] CreateFlat(int width, int height, GUIColor color)
        {
            // Texture2D texture2D = new Texture2D(graphicsDevice, 2, lineWidth + 2);
            var count = width * height;
            var colorArray = new GUIColor[count];

            for (var i = 0; i < count; i++)
            {
                colorArray[i] = color;
            }

            return colorArray;
        }
Ejemplo n.º 52
0
 /// <summary>
 /// Clears the current render target with given color.
 /// </summary>
 /// <param name="clearColor">Color of the clear.</param>
 public abstract void Clear(GUIColor clearColor);
Ejemplo n.º 53
0
        /// <summary>
        /// Redraws the box.
        /// </summary>
        private void RedrawBox()
        {
            // when there are no changes , do nothing
            if (this.currentrgba.Equals(this.rgba))
            {
                return;
            }

            // we have a new color , destroy the old , plant the new
            if (Manager.ImageCompositor.Contains(this.CurrentTextureName))
            {
                // destroy the old !
                Manager.ImageCompositor.Delete(this.CurrentTextureName);
            }

            // create the new
            this.CurrentTextureName = Manager.ImageCompositor.CreateRectangleTexture(this.Name + "-FillColor", (int)Config.Width, (int)Config.Height, 1, this.rgba, Theme.BorderColor);
            this.currentrgba = this.rgba;
        }
Ejemplo n.º 54
0
 /// <summary>
 /// Creates a flat texture with one color.
 /// </summary>
 /// <param name="preferredName">The preferred name to use.</param>
 /// <param name="width">The width of the line texture.</param>
 /// <param name="height">The height of the line texture.</param>
 /// <param name="color">The fill color of the line texture.</param>
 /// <returns>the name to use to find the texture back.</returns>
 public abstract string CreateFlatTexture(string preferredName, int width, int height, GUIColor color);
Ejemplo n.º 55
0
Archivo: Grid.cs Proyecto: xxy1991/cozy
        /// <summary>
        /// Initializes a new instance of the <see cref="Grid"/> class.
        /// </summary>
        /// <param name="name">The name.</param>
        public Grid(string name) : base(name)
        {
            this.cellHeight = Theme.ControlHeight;
            this.cellWidth = Theme.ControlWidth;
            this.configLineWidth = DefaultGridLineWidth;
            this.configColumnCount = 4;
            this.configRowCount = 4;

            Config.Width = this.cellWidth * this.ConfigRowCount;
            Config.Height = this.cellHeight * this.ConfigColumnCount;

            this.gridColor = Theme.FillColor;

            this.mustredraw = true;
        }