Skip to content

IntExtensions

Namespace: SideXP.Core

public static class IntExtensions

Extension functions for int values.

Methods

Ratio(int, int, int)

public static float Ratio(int value, int min, int max)

Remaps the given value from its range to a range between 0 and 1. If the input value is out of the given range, it's clamped between 0 and 1.

Parameters

  • value: The value to remap.
  • min: The lower bound of the value's current range.
  • max: The upper bound of the value's current range.

Returns

Returns the remapped value, clamped between 0 and 1.

Percents(int, int, int)

public static float Percents(int value, int min, int max)

Remaps the given value from its range to a range between 0 and 1. If the input value is out of the given range, it's clamped between 0 and 1.

Parameters

  • value: The value to remap.
  • min: The lower bound of the value's current range.
  • max: The upper bound of the value's current range.

Returns

Returns the remapped value, clamped between 0 and 1.

Clamp(int, int, int)

public static int Clamp(int value, int min, int max)

Clamps this value between given min and max.

Parameters

  • value: The value to clamp.
  • min: The lower bound of the value.
  • max: The upper bound of the value.

Returns

Returns the clamped value.

Pad(int, int, char)

public static string Pad(int value, int length, char padChar = '0')

Pads a value as string with leading characters.

Parameters

  • value: The value to pad.
  • length: The expected length of the string.
  • padChar: The character used to pad the value.

Returns

Returns the padded value as string.