/// <summary> /// Gets new width for changing height /// </summary> /// <param name="original">Original square</param> /// <param name="newWidth">New width</param> /// <returns>Width given original item was resized</returns> public static Square HeightChange(Square original, int newWidth) { var returnValue = new Square(); var multiplier = TypeExtension.DefaultDecimal; // Height is only specified, have to calculate width multiplier = Arithmetic.Divide(newWidth.ToDecimal(), original.Width.ToDecimal()); // Resize returnValue.Height = Arithmetic.Multiply(original.Height.ToDecimal(), multiplier).ToInt(); return(returnValue); }
/// <summary> /// Gets new width for changing height /// </summary> /// <param name="originalWidth">Original items width</param> /// <param name="originanHeight">Original items heigth</param> /// <param name="newHeight">New height</param> /// <returns>Width given original item was resized</returns> public static int WidthGet(int originalWidth, int originanHeight, int newHeight) { var newWidth = TypeExtension.DefaultInteger; var multiplier = TypeExtension.DefaultDecimal; // Height is only specified, have to calculate width multiplier = Arithmetic.Divide(newHeight.ToDecimal(), originanHeight.ToDecimal()); // Resize newWidth = Arithmetic.Multiply(originalWidth.ToDecimal(), multiplier).ToInt(); return(newWidth); }