mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * @package WordPress
mp-wp_genesis 4 * @subpackage Default_Theme
mp-wp_genesis 5 */
mp-wp_genesis 6
mp-wp_genesis 7 /** @ignore */
mp-wp_update-imag... 8 $img = 'kubrickheader.svg';
mp-wp_genesis 9
mp-wp_genesis 10 // If we don't have image processing support, redirect.
mp-wp_genesis 11 if ( ! function_exists('imagecreatefromjpeg') )
mp-wp_update-imag... 12 die(header("Location: kubrickheader.svg"));
mp-wp_genesis 13
mp-wp_genesis 14 // Assign and validate the color values
mp-wp_genesis 15 $default = false;
mp-wp_genesis 16 $vars = array('upper'=>array('r1', 'g1', 'b1'), 'lower'=>array('r2', 'g2', 'b2'));
mp-wp_genesis 17 foreach ( $vars as $var => $subvars ) {
mp-wp_genesis 18 if ( isset($_GET[$var]) ) {
mp-wp_genesis 19 foreach ( $subvars as $index => $subvar ) {
mp-wp_genesis 20 $length = strlen($_GET[$var]) / 3;
mp-wp_genesis 21 $v = substr($_GET[$var], $index * $length, $length);
mp-wp_genesis 22 if ( $length == 1 ) $v = '' . $v . $v;
mp-wp_genesis 23 $$subvar = hexdec( $v );
mp-wp_genesis 24 if ( $$subvar < 0 || $$subvar > 255 )
mp-wp_genesis 25 $default = true;
mp-wp_genesis 26 }
mp-wp_genesis 27 } else {
mp-wp_genesis 28 $default = true;
mp-wp_genesis 29 }
mp-wp_genesis 30 }
mp-wp_genesis 31
mp-wp_genesis 32 if ( $default )
mp-wp_genesis 33 list ( $r1, $g1, $b1, $r2, $g2, $b2 ) = array ( 105, 174, 231, 65, 128, 182 );
mp-wp_genesis 34
mp-wp_genesis 35 // Create the image
mp-wp_genesis 36 $im = imagecreatefromjpeg($img);
mp-wp_genesis 37
mp-wp_genesis 38 // Get the background color, define the rectangle height
mp-wp_genesis 39 $white = imagecolorat( $im, 15, 15 );
mp-wp_genesis 40 $h = 182;
mp-wp_genesis 41
mp-wp_genesis 42 // Define the boundaries of the rounded edges ( y => array ( x1, x2 ) )
mp-wp_genesis 43 $corners = array(
mp-wp_genesis 44 0 => array ( 25, 734 ),
mp-wp_genesis 45 1 => array ( 23, 736 ),
mp-wp_genesis 46 2 => array ( 22, 737 ),
mp-wp_genesis 47 3 => array ( 21, 738 ),
mp-wp_genesis 48 4 => array ( 21, 738 ),
mp-wp_genesis 49 177 => array ( 21, 738 ),
mp-wp_genesis 50 178 => array ( 21, 738 ),
mp-wp_genesis 51 179 => array ( 22, 737 ),
mp-wp_genesis 52 180 => array ( 23, 736 ),
mp-wp_genesis 53 181 => array ( 25, 734 ),
mp-wp_genesis 54 );
mp-wp_genesis 55
mp-wp_genesis 56 // Blank out the blue thing
mp-wp_genesis 57 for ( $i = 0; $i < $h; $i++ ) {
mp-wp_genesis 58 $x1 = 19;
mp-wp_genesis 59 $x2 = 740;
mp-wp_genesis 60 imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );
mp-wp_genesis 61 }
mp-wp_genesis 62
mp-wp_genesis 63 // Draw a new color thing
mp-wp_genesis 64 for ( $i = 0; $i < $h; $i++ ) {
mp-wp_genesis 65 $x1 = 20;
mp-wp_genesis 66 $x2 = 739;
mp-wp_genesis 67 $r = ( $r2 - $r1 != 0 ) ? $r1 + ( $r2 - $r1 ) * ( $i / $h ) : $r1;
mp-wp_genesis 68 $g = ( $g2 - $g1 != 0 ) ? $g1 + ( $g2 - $g1 ) * ( $i / $h ) : $g1;
mp-wp_genesis 69 $b = ( $b2 - $b1 != 0 ) ? $b1 + ( $b2 - $b1 ) * ( $i / $h ) : $b1;
mp-wp_genesis 70 $color = imagecolorallocate( $im, $r, $g, $b );
mp-wp_genesis 71 if ( array_key_exists($i, $corners) ) {
mp-wp_genesis 72 imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $white );
mp-wp_genesis 73 list ( $x1, $x2 ) = $corners[$i];
mp-wp_genesis 74 }
mp-wp_genesis 75 imageline( $im, $x1, 18 + $i, $x2, 18 + $i, $color );
mp-wp_genesis 76 }
mp-wp_genesis 77
mp-wp_genesis 78 //die;
mp-wp_genesis 79 header("Content-Type: image/jpeg");
mp-wp_genesis 80 imagejpeg($im, '', 92);
mp-wp_genesis 81 imagedestroy($im);
mp-wp_genesis 82 ?>