ari.lt/content/js/utils/index.js
Ari Archer 9d8f66c0f0 Use strict equality
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
2022-06-19 20:52:03 +03:00

21 lines
415 B
JavaScript

"use strict";
// Get padding
export function gp(str, pad) {
let ammount = pad - str.length;
if (ammount <= 0) return "";
return " ".repeat(ammount);
}
export function component_to_hex(c) {
let hex = c.toString(16);
return hex.length === 1 ? "0" + hex : hex;
}
export function rgb_to_hex(rgb) {
let hex = "";
rgb.forEach((item) => (hex += component_to_hex(item)));
return hex;
}