was.js – Blame information for rev 7

Subversion Repositories:
Rev:
Rev Author Line No. Line
7 office 1 /*************************************************************************/
2 /* Copyright (C) 2015 Wizardry and Steamworks - License: GNU GPLv3 */
3 /*************************************************************************/
4 function HexToRGB(hex) {
5 var shortRegEx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
6 hex = hex.replace(
7 shortRegEx,
8 function(m, r, g, b) {
9 return r + r + g + g + b + b;
10 }
11 );
12  
13 var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
14 return result ? {
15 r: parseInt(result[1], 16),
16 g: parseInt(result[2], 16),
17 b: parseInt(result[3], 16)
18 } : null;
19 }