Ejemplo n.º 1
0
 public QGeneratedTexture(QColor content, QColor lightBorder, QColor darkBorder, BorderType borderType = BorderType.Shaded, int borderWidth = 2)
 {
     ContentColor         = content;
     BorderMainColor      = lightBorder;
     BorderSecondaryColor = darkBorder;
     BorderType           = borderType;
     BorderWidth          = borderWidth;
 }
Ejemplo n.º 2
0
 public QGeneratedTexture(QColor content, QColor border, BorderType borderType = BorderType.Normal, int borderWidth = 1)
 {
     ContentColor         = content;
     BorderMainColor      = border;
     BorderSecondaryColor = border;
     BorderType           = borderType;
     BorderWidth          = borderWidth;
 }
Ejemplo n.º 3
0
 public QGeneratedTexture(QColor content)
 {
     ContentColor         = content;
     BorderMainColor      = content;
     BorderSecondaryColor = content;
     BorderType           = BorderType.None;
     BorderWidth          = 1;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Generates a Texture2D with the given settings.
        /// </summary>
        /// <param name="content">Colors for the content(center color).</param>
        /// <param name="borderMain">Colors for the main border. </param>
        /// <param name="borderSecondary">Colors for the secondary border (used with BorderType.Shaded)</param>
        /// <param name="borderType">Border Type.</param>
        /// <param name="borderWidth">Border thickness.</param>
        /// <param name="width">Texture's width.</param>
        /// <param name="height">Texture's height.</param>
        /// <returns></returns>
        public static Texture2D GenerateTexture(QColor content, QColor borderMain, QColor borderSecondary, BorderType borderType, int borderWidth = 1, int width = 8, int height = 8)
        {
            if (borderWidth < 0)
            {
                borderWidth = 0;
            }
            else if (borderWidth > width / 2 || borderWidth > height / 2)
            {
                borderWidth = ((width > height ? height : width) / 2) - 1;
            }
            Texture2D texture = new Texture2D(width, height, TextureFormat.ARGB32, false);

            if (borderType == BorderType.None)
            {
                for (int y = 0; y < width; y++)
                {
                    for (int x = 0; x < height; x++)
                    {
                        texture.SetPixel(x, y, content.Color);
                    }
                }
            }
            else if (borderType == BorderType.Normal)
            {
                for (int y = 0; y < width; y++)
                {
                    for (int x = 0; x < height; x++)
                    {
                        if (x <= (borderWidth - 1) || x >= (width - borderWidth))
                        {
                            texture.SetPixel(x, y, borderMain.Color);
                        }
                        else if (y <= (borderWidth - 1) || y >= (height - borderWidth))
                        {
                            texture.SetPixel(x, y, borderMain.Color);
                        }
                        else
                        {
                            texture.SetPixel(x, y, content.Color);
                        }
                    }
                }
            }
            else if (borderType == BorderType.Shaded)
            {
                //TODO: make the shaded texture
            }
            texture.Apply();
            return(texture);
        }
Ejemplo n.º 5
0
 public QColor(QColor qColor, float alpha, bool from256 = true)
 {
     _dark  = new Color(qColor.Dark.r, qColor.Dark.g, qColor.Dark.b, from256 ? alpha / 256f : alpha);
     _light = new Color(qColor.Light.r, qColor.Light.g, qColor.Light.b, from256 ? alpha / 256f : alpha);
 }
Ejemplo n.º 6
0
 public QColor(QColor qColor)
 {
     _dark  = qColor.Dark;
     _light = qColor.Light;
 }
Ejemplo n.º 7
0
 private static GUIStyle TextStyleWithBackground(string name, Texture2D background, QColor textColor, int fontSize, FontStyle fontStyle, TextAnchor alignment, bool richText = true, bool wordWrap = true, Font font = null)
 {
     return(new GUIStyle()
     {
         name = name,
         normal =
         {
             background = background,
             textColor  = EditorGUIUtility.isProSkin ? textColor.Dark : textColor.Light
         },
         fontSize = fontSize,
         fontStyle = fontStyle,
         alignment = alignment,
         richText = richText,
         wordWrap = wordWrap,
         padding = new RectOffset(8, 8, 8, 8),
         border = new RectOffset(2, 2, 2, 2),
         font = font
     });
 }
Ejemplo n.º 8
0
 public QColor(QColor qColor)
 {
     Dark  = qColor.Dark;
     Light = qColor.Light;
 }