neon_crisp / Modules / utils/numbers
Module: utils/numbers
Table of contents
Functions
Functions
applyPercentage
▸ applyPercentage(percentage, full): number
Calculates the value that corresponds to a given percentage of a full value.
Parameters
| Name | Type | Description |
|---|---|---|
percentage | number | The percentage to apply. |
full | number | The full or maximum possible value. |
Returns
number
The calculated value based on the given percentage.
Example
applyPercentage(50, 32); // Returns 16
Defined in
getPercentage
▸ getPercentage(current, full): number
Calculates what percentage the current value is of the full value.
Parameters
| Name | Type | Description |
|---|---|---|
current | number | The current value. |
full | number | The full or maximum possible value. |
Returns
number
The percentage representation of the current value.
Example
getPercentage(250, 500); // Returns 50
Defined in
percentageToDegrees
▸ percentageToDegrees(whole, current, flip?): number
Converts a percentage to a value between 0 and 360, with an optional flag to flip the output.
Parameters
| Name | Type | Default value | Description |
|---|---|---|---|
whole | number | undefined | The total or maximum value. |
current | number | undefined | The current value to calculate the percentage of. |
flip | boolean | false | Optional flag to flip the output (default is false). |
Returns
number
A number between 0 and 360 representing the percentage of the whole.