All pastes #254341 Raw Edit

Untitled

public text v1 · immutable
#254341 ·published 2006-11-21 19:48 UTC
rendered paste body
<?php



function rand_color()
{
	$color_val= mt_rand(50, 150);
	return $color_val;
}

function create_seed()
{
	list($usec, $sec) = explode(' ', microtime());
	return (float) $sec + ((float) $usec * 1000);
}

function make_word()
{
	$chars = 'bcdghklmnpqrsvwxyz1122345667899aeiuo';
	$word ='';
	
	#$wordlen = mt_rand(6, $max_length);
	$wordlen = 8;
	for($i=0; $i<$wordlen; $i++)
	{
		$word .= $chars{rand(0, strlen($chars))};
	}
	return $word;
}


function draw_word($word)
{
	$font = '/home/web/redington.me3.com/html/wbrown/jenkinsv.ttf';
	$max_length=9;
	$fontsize = 18;
	$size = imagettfbbox($fontsize, 0, $font, $word); 
	$width = $size[2] + $size[0] + 12;
	$height = abs($size[1]) + abs($size[7]) + 15;	
	$im = imagecreatetruecolor($width, $height);
	#$bg = ImageColorAllocate($im, 255, 255, 255);
	#ImageFill($im, 0, 0, $bg);


		$text_r = rand_color();
		$text_g = rand_color();
		$text_b = rand_color();
		
		$char_color = ImageColorAllocate($im, $text_r, $text_g, $text_b);
		
		#ImageString($im, 5, 0, 0, $word[$i], $text_color);


	ImageString($im, $font, 15, 10, $word, $char_color);
	
	header("Content-type: image/png");
	imagepng($im);
}





$word = make_word();

draw_word($word);




?>