Beispiel #1
0
        public static Rect Adjust(Rect rect, float width, float height, RectHorizontalAlignment horizontal, RectVerticalAlignment vertical)
        {
            var h = AdjustWidth(rect, width, horizontal);
            var v = AdjustHeight(h, height, vertical);

            return(v);
        }
Beispiel #2
0
        public static Rect AdjustWidth(Rect rect, float width, RectHorizontalAlignment alignment)
        {
            var offset = 0.0f;

            switch (alignment)
            {
            case RectHorizontalAlignment.Center: offset = (rect.width - width) * 0.5f; break;

            case RectHorizontalAlignment.Right: offset = rect.width - width; break;
            }

            return(new Rect(rect.x + offset, rect.y, width, rect.height));
        }