public static Rect AdjustHeight(Rect rect, float height, RectVerticalAlignment alignment) { var offset = 0.0f; switch (alignment) { case RectVerticalAlignment.Middle: offset = (rect.height - height) * 0.5f; break; case RectVerticalAlignment.Bottom: offset = rect.height - height; break; } return(new Rect(rect.x, rect.y + offset, rect.width, height)); }
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); }