84.tools
84.tools is a collection of helpers for your projects
List of helpers
colors
-
hexToRgb
- Convert hexadecimal color string to rgba string -
rgbToHex
- Convert RGB(A) color string to HEX string -
toObject
- Convert RGB(A) or HEX color string to RGBA object
dom
-
destroyVideo
- Properly destroy HTMLVideoElement taking care of removing it from memory -
getIndex
- Get index of specific element relative to its parent -
getURLParameters
- Retrieve all URL GET parameters
maths
-
calculatAspectRatioFit
- This method calculate the ratio depending of an specified maxWidth & maxHeight -
clamp
- Clamp a value between two bounds -
closestInArray
- Return the closest value|index of an array from a specified value -
degrees
- Convert radians to degrees -
getPointOnCircle
- Method to get a point from a circle and an angle -
getPointsAngle
- Return the angle between 2 points -
getPointsDist
- Return the distance between two points -
getRandomFloat
- Generate a random float between a min and max values -
getRandomInt
- Generate a random int between a min and max values -
getSlope
- Get the slope value from two points -
prependZeros
- This method prepend an amout of 0 to a string|number -
radians
- This method prepend an amout of 0 to a string|number - Convert degrees to radians -
range
- Return a new value linearly interpolate between a new min and max -
rectHitTest
- Check if two rectangle are overlaping
How to use
You can add this project as a dependency in your project.
You can require it or just the methods you need via Browserify.
How to contribute
If you want to add methods to this collection :
- Each file can contain only one function to export.
- The function and the file must have the same name.
- Add your new function to the global category file. For example, if you add a maths helpers, add your file into the
maths
directory and add require this file intomaths.js
. - In case the category doesn't exists, create the directory of the category and the category file at root. And be sure to require this category file into
index.js
. - Write a bunch of test for your function/method into the
tests
directory. - Commit & Push !