Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Function to convert HTML colors to Array with RGB info.
- Example of usage with TCPDF for PDF reporting:
- $Backcolor = $this->html2rgb('#FFF8F0');
- $this->SetFillColor($Backcolor[2], $Backcolor[1], $Backcolor[0]);
- */
- function html2rgb($color)
- {
- if ($color[0] == '#')
- $color = substr($color, 1);
- if (strlen($color) == 6)
- list($r, $g, $b) = array($color[0].$color[1],
- $color[2].$color[3],
- $color[4].$color[5]);
- elseif (strlen($color) == 3)
- list($r, $g, $b) = array($color[0].$color[0], $color[1].$color[1], $color[2].$color[2]);
- else
- return false;
- $r = hexdec($r); $g = hexdec($g); $b = hexdec($b);
- return array($r, $g, $b);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement