multicolors-converter
Version:
A very simple tool to convert colors into differents formats
43 lines (42 loc) • 1.12 kB
JavaScript
import { Converter } from "@src/converters/Converter";
export class RgbConverter extends Converter {
/**
*
* @param rgb The RGB Array color to convert to Ral
*/
static rgbToRal(rgb) {
const rgbStr = `${rgb.red}-${rgb.green}-${rgb.blue}`;
let found = null;
this.getColors().find((c) => {
if (c.rgb === rgbStr)
found = c.ral;
});
return found;
}
/**
*
* @param rgb The RGB color to convert to Name
*/
static rgbToName(rgb) {
const rgbStr = `${rgb.red}-${rgb.green}-${rgb.blue}`;
let found = null;
this.getColors().find((c) => {
if (c.rgb === rgbStr)
found = c.name;
});
return found;
}
/**
*
* @param rgb The RAL color to convert to HexaDecimal
*/
static rgbToHex(rgb) {
const rgbStr = `${rgb.red}-${rgb.green}-${rgb.blue}`;
let found = null;
this.getColors().find((c) => {
if (c.rgb === rgbStr)
found = c.hex;
});
return found;
}
}