All pastes #435117 Raw Edit

Mine

public php v1 · immutable
·published 2007-04-11 19:44 UTC
rendered paste body
<?php/** * Shape randomizer */function hex2rgb($hex) {	$ret = array(		'r' => hexdec(substr($hex, 0, 2)),		'g' => hexdec(substr($hex, 2, 2)),		'b' => hexdec(substr($hex, 4, 2))	);	return $ret;}$img 			= ImageCreate(600, 150);$shapes			= array ( 'hexagon', 'triangle', 'square', 'circle' );$colorRGB		= ( isset($_GET['color']) )	? hex2rgb($_GET['color']) : hex2rgb('909090');$altcolorRGB	= ( isset($_GET['altcolor']) )	? hex2rgb($_GET['altcolor']) : hex2rgb('CACACA');$bgcolorRGB		= ( isset($_GET['bgcolor']) )	? hex2rgb($_GET['bgcolor']) : hex2rgb('FFFFFF');$color			= ImageColorAllocate($img, $colorRGB['r'], $colorRGB['g'], $colorRGB['b']);$altcolor		= ImageColorAllocate($img, $altcolorRGB['r'], $altcolorRGB['g'], $altcolorRGB['b']);$bgcolor		= ImageColorAllocate($img, $bgcolorRGB['r'], $bgcolorRGB['g'], $bgcolorRGB['b']);$bg				= ImageFill($img , 0, 0, $bgcolor);$indent 		= 0;shuffle($shapes);header('Content-type: image/png');while ( list ( $key, $shape ) = @each ( $shapes ) ){	// Keep colors ordered	$this_color = ( $this_color == $color ) ? $altcolor : $color;		// Assign based on name	switch ( $shape )	{		case 'hexagon';			$hexagonPoints	= Array(				$indent + 85, 15, 				$indent + 140, 60, 				$indent + 115, 125, 				$indent + 50, 125, 				$indent + 25, 60, 				$indent + 85, 15);			$hexagon = ImageFilledPolygon($img, $hexagonPoints, 5, $this_color);			break;		case 'triangle';			$trianglePoints	= Array(				$indent + 75, 25, 				$indent + 135, 125, 				$indent + 20, 125			);			$triangle = ImageFilledPolygon($img, $trianglePoints, 3, $this_color);			break;		case 'square';			$square = ImageFilledRectangle($img, 25 + $indent, 20, 130 + $indent, 125, $this_color);			break;		case 'circle':			$circle = ImageFilledEllipse($img, 80 + $indent, 75, 115, 110, $this_color);			break;	}		// Increase indentation	$indent += 147;}$final = imagecreatetruecolor(120, 30); ImageCopyResampled($final, $img, 0, 0, 0, 0, 120, 30, 600, 150);	$displayShapes = ImagePng($final); ImageDestroy($img); ImageDestroy($final);?>