logo
pub trait Tools: Encrypter {
Show 21 methods fn create_guid(
        &self,
        is_small: Option<bool>,
        prefix: Option<String>
    ) -> String; fn ease(&self, original_value: f32, new_value: f32, ease: f32) -> f32; fn sort_by_string(&self, a: String, b: String) -> i32; fn sort_by_int(&self, a: i32, b: i32) -> i32; fn sort_by_priority(
        &self,
        a: Box<dyn Priority>,
        b: Box<dyn Priority>
    ) -> i32; fn to_upper_case_first(&self, value: String) -> String; fn to_camel_case(&self, value: String, is_upper: Option<bool>) -> String; fn to_const_case(&self, value: String) -> String; fn from_camel_case(&self, value: String) -> String; fn from_const_case(&self, value: String) -> String; fn to_words(&self, value: String) -> String; fn limit(&self, value: f32, min: f32, max: f32) -> f32; fn range(&self, value: f32, min: f32, max: f32) -> f32; fn is_odd(&self, value: i32) -> bool; fn is_even(&self, value: i32) -> bool; fn sgn(&self, value: f32) -> i32; fn nearest_square(&self, value: f32) -> i32; fn distance(
        &self,
        start_x: f32,
        start_y: f32,
        end_x: f32,
        end_y: f32,
        is_squared: Option<bool>
    ) -> f32; fn convert_updates_to_formatted_time(
        &self,
        updates: i32,
        delimiter: Option<String>
    ) -> String; fn convert_age_to_formatted_time(
        &self,
        age: i32,
        delimiter: Option<String>
    ) -> String; fn int_to_hex(&self, value: i32) -> String;
}
Expand description

The Tools should be implemented by objects intended to provide tool box functionality.

Many of these tools are need in the minimalist implementation of the interfaces. The other functions are often regularly used in entity creation.

Required Methods

Creates a Globally Unique Identifier.

Arguments
  • isSmall - If true returns an 8 bit identifier, 16 bit otherwise. (optional, default: false)
  • prefix - Adds characters to the front of the GUID. (optional, default: empty)

Return: A Globally Unique Identifier.

Find the tween of two values.

Arguments
  • originalValue - Value A.
  • newValue - Value B.
  • ease - The proportion of A:B.

Return: The proportional value of A:B.

Sorting functio’n for String collections.

Arguments
  • a - Value A.
  • b - Value B.

Return: -1 if A<B, 1 if A>B or 0 if A==B.

Sorting functio’n for Int collections.

Arguments
  • a - Value A.
  • b - Value B.

Return: -1 if A<B, 1 if A>B or 0 if A==B.

Sorting functio’n for IPriority collections.

Arguments
  • a - Value A.
  • b - Value B.

Return: -1 if A<B, 1 if A>B or 0 if A==B.

Creates a copy of a string with the first character uppercased.

Arguments
  • value - The string to transform.

Return: Copy of a string with the first character uppercased.

Turns a word or sentence into camelCase. E.g. “this example string” becomes “thisExampleString”.

Arguments
  • value - The string to transform.
  • isUpper - If true returns PascalCase (first character uppercased). (optional, default: false)

Return: camelCase or PascalCase representation of a string.

Turns a word of sentence into CONST_CASE. E.g. “this example string” becomes “THIS_EXAMPLE_STRING”.

Arguments
  • value - The string to transform.

Return: CONST_CASE representation of a string.

Reverts a camelCase string to a word or phrase. E.g. “thisExampleString” becomes “this example string”.

Arguments
  • value - The camelCase string to revert.

Return: Word or phrase.

Reverts a CONST_CASE string to a word or phrase. E.g. “THIS_EXAMPLE_STRING” becomes “this example string”

Arguments
  • value - The CONST_CASE string to revert.

Return: Word or phrase.

Reverts either a camelCase or CONST_CASE string to a word or phrase.

Arguments
  • value - The camelCase or CONST_CASE string.

Return: Word or phrase.

Clamps a value between a floor and ceiling boundary.

Arguments
  • value - The value to clamp.
  • min - The floor.
  • max - The ceiling.

Return: Value >= floor and <= ceiling.

Wraps a value between a floor and ceiling boundary.

Arguments
  • value - The value to wrap.
  • min - The floor.
  • max - The ceiling.

Return: A value between floor and ceiling proportional to over or under shoot.

Not divisible by two.

Arguments
  • value - The value to check.

Return: True if value not divisible by two.

Divisible by two.

Arguments
  • value - The value to check.

Return: True if value divisible by two.

Determine whether a value is less than zero, equal to zero or greater than zero.

Arguments
  • value - The value to check.

Return: -1 if <0, 1 if >0, 0 otherwise.

Calculate the nearest square number to a given value. Useful for performance routines.

Arguments
  • value - The value to check.

Return: A square number nearest to the value.

Calculates the distance between two coordinates.

Arguments
  • startX - The starting position horizontal coordinate.
  • startY - The starting position vertical coordinate.
  • endX - The ending position horizontal coordinate.
  • endY - The ending position vertical coordinate.
  • isSquared - For performance. Set this to true square comparator (to avoid sqrt). (optional, default: false)

Return: The distance between two coordinates.

Creates a string representing a clock in the format “hh’mm’ss”. Uses IFactory.targetFramerate to determine the duration from updates.

Arguments
  • updates - The update cycles elapsed in the duration.
  • delimiter - The character used to separate the components (default: “’”).

Return: String representing a clock in the format “hh:mm:ss”.

Creates a string representing a clock in the format “hh’mm’ss”.

Arguments
  • age - The time elapsed in the duration as milliseconds.
  • delimiter - The character used to separate the components (default: “’”).

Return: String representing a clock in the format “hh:mm:ss”.

Converts an Int to a Hex string.

Arguments
  • value - The Int to convert.

Return: Hex value.

Implementors