Open AlexZ33 opened 3 years ago
// https://codepen.io/iondrimba/pen/EMwvgE?editors=1010
const radians = (degrees) => {
return degrees * Math.PI / 180;
}
const distance = (x1, y1, x2, y2) => {
return Math.sqrt(Math.pow((x1 - x2), 2) + Math.pow((y1 - y2), 2));
}
const map = (value, istart, istop, ostart, ostop) => {
return ostart + (ostop - ostart) * ((value - istart) / (istop - istart));
}
// https://codepen.io/iondrimba/pen/EMwvgE?editors=1010
const hexToRgbTreeJs = (hex) => {
const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16) / 255,
g: parseInt(result[2], 16) / 255,
b: parseInt(result[3], 16) / 255
} : null;
}
useage: https://codepen.io/FrankFitzGerald/pen/LAbfm