public Rectangle(Rectangle r)
 {
     x = r.x;
     y = r.y;
     w = r.w;
     h = r.h;
 }
        public BitmapDecal(ConfigNode node, BitmapDecalCache.Sheet sheet, Texture2D texture)
        {
            type = Type.MONO;
            if (node.HasValue("type")) type = (Type)ConfigNode.ParseEnum(typeof(Type), node.GetValue("type"));

            name = node.GetValue("name");
            url = sheet.url + "/" + name;

            Rectangle rect = new Rectangle();
            rect.x = int.Parse(node.GetValue("x"));
            rect.y = int.Parse(node.GetValue("y"));
            rect.w = int.Parse(node.GetValue("w"));
            rect.h = int.Parse(node.GetValue("h"));

            if (rect.w == 0 || rect.h == 0) return;

            if (sheet.origin == BitmapDecalCache.Origin.TOP_LEFT)
            {
                rect.y = texture.height - rect.y - rect.h;
            }

            Orientation orientation = Orientation.UPRIGHT;
            if (node.HasValue("orientation")) orientation = (Orientation)ConfigNode.ParseEnum(typeof(Orientation), node.GetValue("orientation"));

            image = texture.GetImage(rect);

            switch (orientation)
            {
                case Orientation.FLIPPED_XY:
                    image.flipXY(false);
                    break;

                case Orientation.INVERTED:
                    image.flipVertically();
                    break;

                case Orientation.UPRIGHT:
                default:
                    break;
            }
        }
        public BitmapChar(ConfigNode node, UnityEngine.Texture2D texture)
        {
            if (node.GetValue("character") == "_space_") character = ' ';
            else if (node.GetValue("character") == "_open_brace_") character = '{';
            else if (node.GetValue("character") == "_close_brace_") character = '}';
            else character = node.GetValue("character")[0];

            vx = float.Parse(node.GetValue("vx"));
            vy = float.Parse(node.GetValue("vy"));
            vw = float.Parse(node.GetValue("vw"));
            vh = float.Parse(node.GetValue("vh"));
            cw = float.Parse(node.GetValue("cw"));

            Rectangle rect = new Rectangle();
            rect.x = int.Parse(node.GetValue("x"));
            rect.y = int.Parse(node.GetValue("y"));
            rect.w = int.Parse(node.GetValue("w"));
            rect.h = int.Parse(node.GetValue("h"));

            Orientation orientation = Orientation.UPRIGHT;
            if (node.HasValue("orientation")) orientation = (Orientation)ConfigNode.ParseEnum(typeof(Orientation), node.GetValue("orientation"));

            image = texture.GetImage(rect);

            switch (orientation)
            {
                case Orientation.FLIPPED_XY:
                    image.flipXY(false);
                    break;

                case Orientation.INVERTED:
                    image.flipVertically();
                    break;

                case Orientation.UPRIGHT:
                default:
                    break;
            }
        }