[ Index ]
 

Code source de eGroupWare 1.2.106-2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/calendar/inc/ -> gradient.php (source)

   1  <?php
   2      /**************************************************************************\
   3      * eGroupWare - calendar: rounded corners                                      *
   4      * http://www.egroupware.org                                                *
   5      * Written by RalfBecker@outdoor-training.de                                *
   6      * --------------------------------------------                             *
   7      *  This program is free software; you can redistribute it and/or modify it *
   8      *  under the terms of the GNU General Public License as published by the   *
   9      *  Free Software Foundation; either version 2 of the License, or (at your  *
  10      *  option) any later version.                                              *
  11      \**************************************************************************/
  12  
  13      /* $Id: gradient.php 16094 2004-08-01 15:36:04Z ralfbecker $ */
  14  
  15  // some constanst for pre php4.3
  16  if (!defined('PHP_SHLIB_SUFFIX'))
  17  {
  18      define('PHP_SHLIB_SUFFIX',strtoupper(substr(PHP_OS, 0,3)) == 'WIN' ? 'dll' : 'so');
  19  }
  20  if (!defined('PHP_SHLIB_PREFIX'))
  21  {
  22      define('PHP_SHLIB_PREFIX',PHP_SHLIB_SUFFIX == 'dll' ? 'php_' : '');
  23  }
  24  
  25  if (!extension_loaded('gd') && !@dl(PHP_SHLIB_PREFIX.'gd.'.PHP_SHLIB_SUFFIX))
  26  {
  27      die("Can't load the needed php-extension 'gd' !!!");
  28  }
  29  
  30  foreach(array('width'=>1,'height'=>1,'color1'=>'000080','color2'=>'ffffff') as $name => $default)
  31  {
  32      $$name = isset($_GET[$name]) ? $_GET[$name] : $default;
  33  }
  34  
  35  foreach(array('color1','color2') as $name)
  36  {
  37      preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/',$$name,$rgb) or
  38          die("Wrong value '".$$name."' for $name, should be something like #80FFFF' !!!");
  39  
  40      $$name = array('r'=>hexdec($rgb[1]),'g'=>hexdec($rgb[2]),'b'=>hexdec($rgb[3]));
  41  }
  42  $image = @imagecreate(abs($width),abs($height))
  43      or die("Cannot Initialize new GD image stream");
  44  
  45  $length = max($width,$height);
  46  $dist = $length / 256;
  47  if ($dist < 1) $dist = 1;
  48  $anz = round($length / $dist);
  49  foreach ($color1 as $c => $val)
  50  {
  51      $c_step[$c] = ($color2[$c] - $val) / $anz;
  52  }
  53  
  54  $rgb = $color1;
  55  for ($l = 0; $l < $length; $l += $dist)
  56  {
  57      $color = imagecolorallocate($image,(int)$rgb['r'],(int)$rgb['g'],(int)$rgb['b']);
  58      foreach($rgb as $c => $val)
  59      {
  60          $rgb[$c] += $c_step[$c];
  61      }
  62      if ($width > $height)
  63      {
  64          imagefilledrectangle($image,(int)$l,0,(int) ($l+$dist),$height-1,$color);
  65      }
  66      else
  67      {
  68          imagefilledrectangle($image,0,(int)$l,$width-1,(int) ($l+$dist),$color);
  69      }
  70  }
  71  
  72  session_cache_limiter('public');    // allow caching
  73  if (function_exists('imagegif'))
  74  {
  75      header("Content-type: image/gif");
  76      imagegif($image);
  77  }
  78  else
  79  {
  80      header("Content-type: image/png");
  81      imagepng($image);
  82  }
  83  imagedestroy($image);
  84  ?>


Généré le : Sun Feb 25 17:20:01 2007 par Balluche grâce à PHPXref 0.7