2005-09-23 19:35:37 -04:00
|
|
|
<?php
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-09-23 19:35:37 -04:00
|
|
|
$img = 'kubrickheader.jpg';
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-09-23 19:35:37 -04:00
|
|
|
// If we don't have image processing support, redirect.
|
|
|
|
if ( ! function_exists('imagecreatefromjpeg') )
|
|
|
|
die(header("Location: kubrickheader.jpg"));
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-09-23 19:35:37 -04:00
|
|
|
// Assign and validate the color values
|
|
|
|
$default = false;
|
2006-01-04 20:47:22 -05:00
|
|
|
$vars = array('upper'=>array('r1', 'g1', 'b1'), 'lower'=>array('r2', 'g2', 'b2'));
|
2005-09-23 19:35:37 -04:00
|
|
|
foreach ( $vars as $var => $subvars ) {
|
|
|
|
if ( isset($_GET[$var]) ) {
|
|
|
|
foreach ( $subvars as $index => $subvar ) {
|
2006-01-04 20:47:22 -05:00
|
|
|
$length = strlen($_GET[$var]) / 3;
|
|
|
|
$v = substr($_GET[$var], $index * $length, $length);
|
|
|
|
if ( $length == 1 ) $v = '' . $v . $v;
|
|
|
|
$$subvar = hexdec( $v );
|
2005-09-23 19:35:37 -04:00
|
|
|
if ( $$subvar < 0 || $$subvar > 255 )
|
|
|
|
$default = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$default = true;
|
|
|
|
}
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-09-23 19:35:37 -04:00
|
|
|
if ( $default )
|
|
|
|
list ( $r1, $g1, $b1, $r2, $g2, $b2 ) = array ( 105, 174, 231, 65, 128, 182 );
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-09-23 19:35:37 -04:00
|
|
|
// Create the image
|
|
|
|
$im = imagecreatefromjpeg($img);
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-09-23 19:35:37 -04:00
|
|
|
// Get the background color, define the rectangle height
|
|
|
|
$white = imagecolorat( $im, 15, 15 );
|
|
|
|
$h = 182;
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-09-23 19:35:37 -04:00
|
|
|
// Define the boundaries of the rounded edges ( y => array ( x1, x2 ) )
|
|
|
|
$corners = array(
|
|
|
|
0 => array ( 25, 734 ),
|
|
|
|
1 => array ( 23, 736 ),
|
|
|
|
2 => array ( 22, 737 ),
|
|
|
|
3 => array ( 21, 738 ),
|
|
|
|
4 => array ( 21, 738 ),
|
|
|
|
177 => array ( 21, 738 ),
|
|
|
|
178 => array ( 21, 738 ),
|
|
|
|
179 => array ( 22, 737 ),
|
|
|
|
180 => array ( 23, 736 ),
|
|
|
|
181 => array ( 25, 734 ),
|
|
|
|
);
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-09-23 19:35:37 -04:00
|
|
|
// Blank out the blue thing
|
|
|
|
for ( $i = 0; $i < $h; $i++ ) {
|
|
|
|
$x1 = 19;
|
|
|
|
$x2 = 740;
|
|
|
|
imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-09-23 19:35:37 -04:00
|
|
|
// Draw a new color thing
|
|
|
|
for ( $i = 0; $i < $h; $i++ ) {
|
|
|
|
$x1 = 20;
|
|
|
|
$x2 = 739;
|
|
|
|
$r = ( $r2 - $r1 != 0 ) ? $r1 + ( $r2 - $r1 ) * ( $i / $h ) : $r1;
|
|
|
|
$g = ( $g2 - $g1 != 0 ) ? $g1 + ( $g2 - $g1 ) * ( $i / $h ) : $g1;
|
|
|
|
$b = ( $b2 - $b1 != 0 ) ? $b1 + ( $b2 - $b1 ) * ( $i / $h ) : $b1;
|
|
|
|
$color = imagecolorallocate( $im, $r, $g, $b );
|
|
|
|
if ( array_key_exists($i, $corners) ) {
|
|
|
|
imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );
|
|
|
|
list ( $x1, $x2 ) = $corners[$i];
|
|
|
|
}
|
|
|
|
imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $color );
|
|
|
|
}
|
2007-06-13 22:25:30 -04:00
|
|
|
|
2005-09-23 19:35:37 -04:00
|
|
|
//die;
|
|
|
|
header("Content-Type: image/jpeg");
|
|
|
|
imagejpeg($im, '', 92);
|
|
|
|
imagedestroy($im);
|
2005-12-06 19:36:07 -05:00
|
|
|
?>
|