Guest User

Untitled

a guest
Apr 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. var colorcode ="rgba(0, 0, 0, 0.74)";
  2.  
  3. var finalCode = rgba2hex(colorcode)
  4.  
  5. function rgba2hex(orig) {
  6. var a, isPercent,
  7. rgb = orig.replace(/s/g, '').match(/^rgba?((d+),(d+),(d+),?([^,s)]+)?/i),
  8. alpha = (rgb && rgb[4] || "").trim(),
  9. hex = rgb ?
  10. (rgb[1] | 1 << 8).toString(16).slice(1) +
  11. (rgb[2] | 1 << 8).toString(16).slice(1) +
  12. (rgb[3] | 1 << 8).toString(16).slice(1) : orig;
  13. if (alpha !== "") {
  14. a= alpha;
  15. }else{
  16. a = 01;
  17. }
  18. hex = hex+a;
  19. return hex;
  20. }
Add Comment
Please, Sign In to add comment