internal static WidgetSize Lerp(WidgetSize a, WidgetSize b, float t) { if (Mathf.Approximately(t, 0)) { return(a); } if (Mathf.Approximately(t, 1)) { return(b); } var minWidth = Mathf.Lerp(a.MinWidth, b.MinWidth, t); var minHeight = Mathf.Lerp(a.MinHeight, b.MinHeight, t); var maxWidth = float.PositiveInfinity; var maxHeight = float.PositiveInfinity; if (!float.IsInfinity(a.MaxWidth) || !float.IsInfinity(b.MaxWidth)) { var w1 = float.IsInfinity(a.MaxWidth) ? b.MaxWidth : a.MaxWidth; var w2 = float.IsInfinity(b.MaxWidth) ? a.MaxWidth : b.MaxWidth; maxWidth = Mathf.Lerp(w1, w2, t); } if (!float.IsInfinity(a.MaxHeight) || !float.IsInfinity(b.MaxHeight)) { var h1 = float.IsInfinity(a.MaxHeight) ? b.MaxHeight : a.MaxHeight; var h2 = float.IsInfinity(b.MaxHeight) ? a.MaxHeight : b.MaxHeight; maxHeight = Mathf.Lerp(h1, h2, t); } return(new WidgetSize(minWidth, minHeight, maxWidth, maxHeight)); }
internal static WidgetSize StackZ(WidgetSize a, WidgetSize b) { return(new WidgetSize( minWidth: Mathf.Max(a.MinWidth, b.MinWidth), minHeight: Mathf.Max(a.MinHeight, b.MinHeight), maxWidth: Mathf.Min(a.MaxWidth, b.MaxWidth), maxHeight: Mathf.Min(a.MaxHeight, b.MaxHeight) )); }