@react-hive/honey-utils
Version:
A lightweight TypeScript utility library providing a collection of helper functions for common programming tasks
30 lines (29 loc) • 1.15 kB
TypeScript
/**
* Calculates the Euclidean distance between two points in 2D space.
*
* @param startX - The X coordinate of the starting point.
* @param startY - The Y coordinate of the starting point.
* @param endX - The X coordinate of the ending point.
* @param endY - The Y coordinate of the ending point.
*
* @returns The Euclidean distance between the two points.
*/
export declare const calculateEuclideanDistance: (startX: number, startY: number, endX: number, endY: number) => number;
/**
* Calculates the moving speed.
*
* @param distance - The distance.
* @param elapsedTime - The time taken to move the distance.
*
* @returns The calculated speed, which is the absolute value of delta divided by elapsed time.
*/
export declare const calculateMovingSpeed: (distance: number, elapsedTime: number) => number;
/**
* Calculates the specified percentage of a given value.
*
* @param value - The value to calculate the percentage of.
* @param percentage - The percentage to calculate.
*
* @returns The calculated percentage of the value.
*/
export declare const calculatePercentage: (value: number, percentage: number) => number;