og-image/src/util/color.js

16 lines
313 B
JavaScript
Raw Normal View History

2023-01-30 09:01:16 +01:00
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,
}