corrade-http-templates – Blame information for rev 77
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
12 | eva | 1 | <?php |
2 | |||
3 | /////////////////////////////////////////////////////////////////////////// |
||
4 | // Copyright (C) Wizardry and Steamworks 2015 - License: GNU GPLv3 // |
||
5 | /////////////////////////////////////////////////////////////////////////// |
||
6 | function wasColorHash($a) { |
||
7 | $hash = sha1($a); |
||
8 | $size = strlen($hash); |
||
9 | |||
10 | return substr($hash, 0, 2). |
||
11 | substr($hash, $size/2, 2). |
||
12 | substr($hash, $size-2, 2); |
||
13 | } |
||
14 | |||
15 | function hex2RGB($hexStr, $returnAsString = false, $seperator = ',') { |
||
16 | $hexStr = preg_replace("/[^0-9A-Fa-f]/", '', $hexStr); |
||
17 | $rgbArray = array(); |
||
18 | switch(strlen($hexStr)) { |
||
19 | case 6: |
||
20 | $colorVal = hexdec($hexStr); |
||
21 | $rgbArray['red'] = 0xFF & ($colorVal >> 0x10); |
||
22 | $rgbArray['green'] = 0xFF & ($colorVal >> 0x8); |
||
23 | $rgbArray['blue'] = 0xFF & $colorVal; |
||
24 | break; |
||
25 | case 3: |
||
26 | $rgbArray['red'] = hexdec( |
||
27 | str_repeat(substr($hexStr, 0, 1), 2)); |
||
28 | $rgbArray['green'] = hexdec( |
||
29 | str_repeat(substr($hexStr, 1, 1), 2)); |
||
30 | $rgbArray['blue'] = hexdec( |
||
31 | str_repeat(substr($hexStr, 2, 1), 2)); |
||
32 | break; |
||
33 | default: |
||
34 | return false; |
||
35 | } |
||
36 | return $returnAsString ? implode($seperator, $rgbArray) : $rgbArray; |
||
37 | } |