public static Rect FirstLine(this Rect rect, float height = 18) { rect = rect.Abs(); rect.height = height; return(rect.Abs()); }
public static Rect MoveDownFor(this Rect rect, float newHeight, float space = SPACE) { rect = rect.Abs(); rect.y += rect.height + space; rect.height = newHeight; return(rect.Abs()); }
public static Rect MoveLeftFor(this Rect rect, float newWidth, float space = SPACE) { rect = rect.Abs(); rect.x -= newWidth + space; rect.width = newWidth; return(rect.Abs()); }
public static Rect MoveRight(this Rect rect, float space = SPACE) { rect = rect.Abs(); rect.x += rect.width + space; return(rect); }
public static Rect MoveDown(this Rect rect, float space = SPACE) { rect = rect.Abs(); rect.y += rect.height + space; return(rect); }
public static Rect[] Row(this Rect rect, int count, float space = SPACE) { rect = rect.Abs(); switch (count) { case 1: { return(new Rect[] { rect }); } case 2: { return(RowTwoSlices(rect, space)); } case 3: { return(RowThreeSlices(rect, space)); } default: { var weights = Enumerable.Repeat(1f, count).ToArray(); var widthes = Enumerable.Repeat(0f, count).ToArray(); return(Row(rect, weights, widthes, space)); } } }
public static Rect Intend(this Rect rect, float border) { rect = rect.Abs(); var result = new Rect( x: rect.x + border, y: rect.y + border, width: rect.width - 2 * border, height: rect.height - 2 * border ); if (result.width < 0) { result.x += result.width / 2; result.width = 0; } if (result.height < 0) { result.y += result.height / 2; result.height = 0; } return(result); }
/// <summary> /// Clamp the point to the rect. /// </summary> /// <param name="extends">Extends.</param> /// <param name="point">Point.</param> public static Vector2 Clamp(this Rect extends, Vector2 point) { extends = extends.Abs(); float x = HydraMathUtils.Clamp(point.x, extends.xMin, extends.xMax); float y = HydraMathUtils.Clamp(point.y, extends.yMin, extends.yMax); return(new Vector2(x, y)); }
public static Rect Extend(this Rect rect, float border) { rect = rect.Abs(); return(new Rect( x: rect.x - border, y: rect.y - border, width: rect.width + 2 * border, height: rect.height + 2 * border )); }
public static Rect[] Row(this Rect rect, float[] weights, float[] widthes, float space = SPACE) { if (weights == null) { throw new ArgumentException("Weights is null. You must specify it"); } if (widthes == null) { widthes = Enumerable.Repeat(0f, weights.Length).ToArray(); } rect = rect.Abs(); return(RowSafe(rect, weights, widthes, space)); }
public static Rect MoveUp(this Rect rect, float space = 2) { rect = rect.Abs(); rect.y -= rect.height + space; return(rect); }
public static Rect MoveLeft(this Rect rect, float space = 2) { rect = rect.Abs(); rect.x -= rect.width + space; return(rect); }
public void Abs(string name, Rect from, Rect expected) { var actual = from.Abs(); Assert.AreEqual(expected, actual); }