All pastes #278457 Raw Edit

Stuff

public php v1 · immutable
·published 2006-12-14 02:24 UTC
rendered paste body
<?phpfunction warp($path_image) {	# CREATE IMAGE OBJECT FROM ORIGINAL FILE	$im = imagecreatefrompng($path_image);$pixel = array();	# CREATE NEW IMAGE OBJECT 150% THE HEIGHT OF THE ORIGNAL	$n_im = imagecreatetruecolor(imagesx($im),(imagesy($im)+(imagesy($im)/2)));	# FILL WHITE	$fond = imagecolorallocatealpha($n_im, 255, 255, 255, 0);	imagefill($n_im, 0, 0, $fond);	# LOOP OVER EVERY PIXEL AND STORE IN A 2D ARRAY	for($y=0;$y<imagesy($n_im);$y++) {		for($x=0;$x<imagesx($n_im);$x++) {			$rgb = imagecolorat($im, $x, $y);			$pixel = imagecolorsforindex($im, $rgb);			$matrix[$x][$y] = $pixel;		}	}	# CREATE WHITE AND BLACK PIXELS FOR FUTURE USE	$whitepixel = array('red' => 255 , 'green' => 255 , 'blue' => 255 , 'alpha' => 0);	$blackpixel = array('red' => 0 , 'green' => 0 , 'blue' => 0 , 'alpha' => 0);	# LOOP OVER EVERY PIXEL AGAIN		for($x=0;$x<imagesx($n_im);$x++) {			# IF PIXEL FALLS WITHIN CURVE FROM 0,0 TO WIDTH,0			//$value = 100 * cos ( ( $x / imagesx($n_im) ) * 2 * pi() ) ;			$value = 20 * (1 + cos ( ( $x / imagesx($n_im) ) * 2 * pi() ))			for($i=0;$i<$value;$i++) {				array_unshift($matrix[$x],$whitepixel);			}		}	# LOOP OVER EVERY PIXEL AGAIN	for($y=0;$y<(imagesy($n_im)+(imagesy($n_im)/2));$y++) {		for($x=0;$x<(imagesx($n_im)+(imagesx($n_im)/2));$x++) {			# PRINT OUT THIS PIXEL			$pixel = $matrix[$x][$y];			$r = $pixel['red'];			$g = $pixel['green'];			$b = $pixel['blue'];			$a = $pixel['alpha'];			$pixelcolor = imagecolorallocatealpha($n_im, $r, $g, $b, $a);			imagealphablending($n_im, TRUE);			imagesetpixel($n_im, $x, $y, $pixelcolor);		}	}	# OUTPUT IMAGE	imagepng($n_im);	imagedestroy($n_im);}header('Content-type:image/png');$imagefile = "fearthepie.png";warp($imagefile);?>