From e4081be2ce50e42c8ab1a1cd146fc7458e170bb7 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 25 Oct 2020 01:33:05 +0200 Subject: [PATCH] added some padding utility constructors --- MLEM/Misc/Padding.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/MLEM/Misc/Padding.cs b/MLEM/Misc/Padding.cs index ef90620..7272d44 100644 --- a/MLEM/Misc/Padding.cs +++ b/MLEM/Misc/Padding.cs @@ -46,6 +46,24 @@ namespace MLEM.Misc { this.Bottom = bottom; } + /// + /// Creates a new padding with the specified x and y values, applying them to both edges. + /// + /// The x padding, which will turn into the left and right padding + /// The y padding, which till turn into the top and bottom padding + public Padding(float x, float y) : + this(x, x, y, y) { + } + + /// + /// Creates a new padding from an existing padding, modifying it by growing or shrinking it. + /// + /// The padding whose initial values to use + /// The amount to grow each border by. Negative values will shrink the padding. + public Padding(Padding padding, float growth) : + this(padding.Left + growth, padding.Right + growth, padding.Top + growth, padding.Bottom + growth) { + } + /// /// Implicitly creates a padding from the given two-dimensional vector. /// The left and right padding will both be the vector's x value, and the top and bottom padding will both be the vector's y value.