ari.lt/content/js/utils/index.js
Ari Archer eb1ce0a4d5 update @ Sun 22 May 18:00:07 EEST 2022
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
2022-05-22 18:00:07 +03:00

21 lines
414 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;
}