You are here

function support_pm_display_swatch in Support Ticketing System 7

Same name and namespace in other branches
  1. 6 support_pm/support_pm.module \support_pm_display_swatch()
1 string reference to 'support_pm_display_swatch'
support_pm_menu in support_pm/support_pm.module
Implements hook_menu(). TODO: Include date in 'view' and 'edit' tabs

File

support_pm/support_pm.module, line 606
Support Project Management. @author Jeremy Andrews <jeremy@tag1consulting.com> @package Support

Code

function support_pm_display_swatch($color) {
  $color = preg_replace('/[^0-9a-fA-F]/', '', $color);
  if (strlen($color)) {
    if (strlen($color) == 3) {
      $color = $color . $color;
    }
    if (strlen($color) > 6) {
      $color = substr($color, 0, 6);
    }
    else {
      if (strlen($color) < 6) {
        $color = 'FFFFFF';
      }
    }
  }
  $image = imagecreatetruecolor(15, 15);
  $swatch = imagecolorallocate($image, hexdec(substr($color, 0, 2)), hexdec(substr($color, 2, 2)), hexdec(substr($color, 4, 2)));
  imagefill($image, 0, 0, $swatch);
  header('Content-type: image/png');
  imagepng($image);
  imagedestroy($image);
}