note 54744 added to function.imagesetpixel

From: Date: Thu, 14 Jul 2005 09:28:35 +0000
Subject: note 54744 added to function.imagesetpixel
Groups: php.notes 
Request: Send a blank email to php-notes+get-91941@lists.php.net to get a copy of this message
This code does generate a RGB-cube (with or without borders). Because its only rendering the visible pixels its clearly fast (approx 1 up to 2 seconds). With changing the $order-variable you can see the cube from different perspectives. Entering double or tribble values (like rrg or ggg) will give you other specs of single channels. Send any sugestions to my email. <?php $borders = true; $order = 'rgb'; set_time_limit(0); $img = imageCreateTrueColor(510, 510); $bg = imageColorAllocate($img, 255, 255, 255); $black = imageColorAllocate($img, 255, 255, 255); for ($r=0; $r<256; $r++) { for ($g=0; $g<256; $g++) { for ($b=0; $b<256; $b++) { $rN = ${$order{0}}; $gN = ${$order{1}}; $bN = ${$order{2}}; $col = imageColorAllocate($img, $rN, $gN, $bN); imagesetpixel($img, $b+($r*0.5)+(255/4), $g+($r*0.5)+(255/4), $col); if ($r < 255 && $g > 0) break; } } if ($borders) { imagesetpixel($img, ($r*0.5+(255/4)), ($r*0.5)+(255/4), $black); imagesetpixel($img, ($r*0.5)+255+(255/4), ($r*0.5)+(255/4), $black); imagesetpixel($img, ($r*0.5)+(255/4), ($r*0.5)+255+(255/4), $black); } } if ($borders) { imageline($img, 255/4, 255/4, 255+(255/4), 255/4, $black); imageline($img, 255/4, 255/4, 255/4, 255+(255/4), $black); imageline($img, 255*0.5+(255/4), 255*0.5+(255/4), 255*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), $black); imageline($img, 255*0.5+(255/4), 255*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), 255*0.5+(255/4), $black); imageline($img, 255*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), $black); imageline($img, 255*0.5 + 509*0.5+(255/4), 255*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), 255*0.5 + 509*0.5+(255/4), $black); } header("Content-Type: image/png"); imagepng($img); imagedestroy($img); ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagesetpixel.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54744 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54744&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54744&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54744&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54744&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54744&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54744&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54744&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91941) next »