og-image/src/util/color.js
Simon Vieille ace8a0d891
Init
2023-01-30 09:01:16 +01:00

16 lines
313 B
JavaScript

const hexToRgb = (color) => {
color = color.replace('#', '')
const size = color.length === 3 ? 1 : 2
return {
red: parseInt(color.substr(0, size), 16),
green: parseInt(color.substr(1 * size, size), 16),
blue: parseInt(color.substr(2 * size, size), 16),
}
}
module.exports = {
hexToRgb,
}