All pastes #485427 Raw Edit

Anonymous

public php v1 · immutable
·published 2007-05-13 01:04 UTC
rendered paste body
<?phpheader("Content-type: text/html; charset=utf-8");$start_color = $_REQUEST['start'];$end_color = $_REQUEST['end'];$height = $_REQUEST['height'];if($start_color == '') $start_color = '339933';if($end_color == '') $end_color = 'FFFF66';if($height == '') $height = 400;if($height == 0) $height = 1;?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"   "http://www.w3.org/TR/html4/strict.dtd"><head><title>Useless Gradient Generator [Newbold]</title><script src="/mint/?js" type="text/javascript"></script></head><body><form style="font-family: sans-serif; font-size: .8em;" action="?" method="get"><p><strong>Hi, make a gradient.</strong> &nbsp;&nbsp;&nbsp; start color #<input name="start" type="text" value="<?php echo $start_color; ?>"> &nbsp;&nbsp;&nbsp; end color #<input name="end" type="text" value="<?php echo $end_color; ?>"> &nbsp;&nbsp;&nbsp; height (px) <input name="height" type="text" value="<?php echo $height; ?>"> &nbsp;&nbsp;&nbsp; <input type="submit" value="Make"> &nbsp;&nbsp;&nbsp;&copy; <a href="/adam/" style="color: #000; text-decoration: none;">Adam Newbold</a></p></form><?phpfunction gradient($start, $end, $steps = 256) {	$s = hexdec($start) & 0xFFFFFF;		$e = hexdec($end) & 0xFFFFFF;	$sr = ($s >> 16) & 0xFF;	$sg = ($s >> 8) & 0xFF;	$sb = $s & 0xFF;	$er = ($e >> 16) & 0xFF;	$eg = ($e >> 8) & 0xFF;	$eb = $e & 0xFF;	$dr = ($sr - $er) / $steps;	$dg = ($sg - $eg) / $steps;	$db = ($sb - $eb) / $steps;	$ret = array();	for($i = 0; $i < $steps; $i++) {		$ret[] = sprintf('%02x%02x%02x', $sr - ($dr * $i), $sg - ($dg * $i), $sb - ($db * $i));	}	return $ret;}$colors = gradient($start_color, $end_color, $height);$i = 0;while ($i < count($colors)) {echo '<div style="width: 100%; height: 1px; background-color: #'.$colors[$i].';"></div>';$i++;}?></body></html>