All pastes #174097 Raw Edit

Anonymous

public php v1 · immutable
·published 2006-09-17 16:26 UTC
rendered paste body
Function Gradient($height,$width,$base,$end, $alpha=20) {	$im = ImageCreate($width,$height);	sscanf($base, "%2x%2x%2x", $rbase, $gbase, $bbase);	sscanf($end, "%2x%2x%2x", $rend, $gend, $bend);	$varstep=$height;	if ($rbase==$rend) {		$rend = $rend -1;	}	if ($gbase==$gend) {		$gend = $gend -1;	}	if ($bbase==$bend) {		$bend = $bend -1;	}	if ($varstep == 0) {		$varstep=1;	}	$rmod = ($rend - $rbase) /$varstep;	$gmod = ($gend - $gbase) /$varstep;	$bmod = ($bend - $bbase) /$varstep;	$white=ImageColorAllocateAlpha($im,255,255,255,$alpha);	for($i=1;$i<$varstep;$i=$i+2) {		$clour1 = ($i*$rmod)+$rbase;		$clour2 = ($i*$gmod)+$gbase;		$clour3 = ($i*$bmod)+$bbase;		$col=ImageColorAllocateAlpha($im,$clour1,$clour2,$clour3,$alpha);		imagefilledrectangle($im,$width-$width+1,$height-$i,$width,$height-$i+1,$col);	}	return $im;}