multicolors-converter
Version:
A very simple tool to convert colors into differents formats
43 lines (42 loc) • 1.02 kB
JavaScript
import { Converter } from "@src/converters/Converter";
export class HexConverter extends Converter {
/**
*
* @param hex The hex color to convert to Rgb
*/
static hexToRgb(hex) {
let found = null;
this.getColors().find((c) => {
if (c.hex === hex.toUpperCase()) {
found = c.rgb.split("-").map(Number);
}
});
return found;
}
/**
*
* @param hex The hex color to convert to Ral
*/
static hexToRal(hex) {
let found = null;
this.getColors().find((c) => {
if (c.hex === hex.toUpperCase()) {
found = c.ral;
}
});
return found;
}
/**
*
* @param hex The hex color to convert to Name
*/
static hexToName(hex) {
let found = null;
this.getColors().find((c) => {
if (c.hex === hex.toUpperCase()) {
found = c.name;
}
});
return found;
}
}