Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function hexRgb(h) {
- h = h.match(/^#?([\da-f]{3}|[\da-f]{6})$/i);
- if (!h) return null;
- h = h[1];
- h = parseInt(h.length == 3 ? h.replace(/(.)/g, '$1$1') : h, 16);
- return {
- r: h >> 16,
- g: h >> 8 & 0xff,
- b: h & 0xff
- };
- }
- function rgbHex(r, g, b) {
- function h(v) {
- return v &= 0xff, (v < 16 ? '0' : '') + v.toString(16);
- }
- return '#' + h(r) + h(g) + h(b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement