convert: common/utils/stringToColor

This commit is contained in:
David Sevilla Martin 2020-06-23 10:05:27 -04:00 committed by Franz Liedke
parent 20baa93ca7
commit 455327cca1
No known key found for this signature in database
GPG Key ID: 9A0231A879B055F4

View File

@ -1,4 +1,6 @@
function hsvToRgb(h, s, v) {
type RGB = { r: number; g: number; b: number };
function hsvToRgb(h: number, s: number, v: number): RGB {
let r;
let g;
let b;
@ -51,11 +53,8 @@ function hsvToRgb(h, s, v) {
/**
* Convert the given string to a unique color.
*
* @param {String} string
* @return {String}
*/
export default function stringToColor(string) {
export default function stringToColor(string: string): string {
let num = 0;
// Convert the username into a number based on the ASCII value of each