[ Index ]
 

Code source de eGroupWare 1.2.106-2

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

title

Body

[fermer]

/calendar/inc/ -> round_corners.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: round_corners.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'=>-20,'height'=>40,'border'=>1,'color'=>'000080','bgcolor'=>'0000FF') as $name => $default)
  31  {
  32      $$name = isset($_GET[$name]) ? $_GET[$name] : $default;
  33  }
  34  
  35  $image = @imagecreate(abs($width),abs($height))
  36      or die("Cannot Initialize new GD image stream");
  37  
  38  $white = imagecolorallocate($image, 254, 254, 254);
  39  imagecolortransparent($image, $white);
  40  
  41  foreach(array('color','bgcolor') as $name)
  42  {
  43      preg_match('/^#?([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})([0-9A-Fa-f]{2})$/',$$name,$rgb) or
  44          die("Wrong value '".$$name."' for $name, should be something like #80FFFF' !!!");
  45  
  46      $$name = imagecolorallocate($image,hexdec($rgb[1]),hexdec($rgb[2]),hexdec($rgb[3]));
  47  }
  48  $radius = min(abs($width),abs($height));
  49  $center_x = $width > 0 ? abs($width)-$radius-1 : $radius;
  50  $center_y = $height < 0 ? abs($height)-$radius-1 : $radius;
  51  //echo "width=$width, height=$height => radius=$radius: center_x=$center_x, center_y=$center_y";
  52  if ($border) imagefilledellipse($image,$center_x,$center_y,2*$radius,2*$radius,$color);
  53  imagefilledellipse($image,$center_x,$center_y,2*($radius-$border),2*($radius-$border),$bgcolor);
  54  
  55  if (abs($height) > abs($width))
  56  {
  57      if ($height < 0)    // lower corners
  58      {
  59          $y1 = 0;
  60          $y2 = abs($height)-$radius-1;
  61      }
  62      else
  63      {
  64          $y1 = $radius;
  65          $y2 = abs($height)-1;
  66      }
  67      imagefilledrectangle($image,0,$y1,abs($width),$y2,$bgcolor);
  68      if ($border)
  69      {
  70          $x1 = $width < 0 ? 0 : abs($width)-$border;
  71          $x2 = $width < 0 ? $border-1 : abs($width)-1;
  72          imagefilledrectangle($image,$x1,$y1,$x2,$y2,$color);
  73      }
  74  }
  75  
  76  session_cache_limiter('public');    // allow caching
  77  if (function_exists('imagegif'))
  78  {
  79      header("Content-type: image/gif");
  80      imagegif($image);
  81  }
  82  else
  83  {
  84      header("Content-type: image/png");
  85      imagepng($image);
  86  }
  87  imagedestroy($image);
  88  ?>


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