<?php class piksel { var $r; var $g; var $b; function piksel(){ extract($_REQUEST); if(isset($r) and isset($g) and isset($b)){ $this->r=(int)(abs($r)%255); $this->g=(int)(abs($g)%255); $this->b=(int)(abs($b)%255); }elseif(isset($s)){ $this->renksec($s); } } function cikti($genislik,$yukseklik){ $im = imagecreatetruecolor($genislik,$yukseklik); $renk = imagecolorallocate($im,$this->r,$this->g,$this->b); imagefill($im,0,0,$renk); header('Content-type: image/png'); imagepng($im); imagedestroy($im); } function renksec($renk) { switch ($renk) { case 'black': $this->r=0;$this->g=0;$this->b=0;break; case 'white': $this->r=255;$this->g=255;$this->b=255;break; case 'pink': $this->r=255;$this->g=0;$this->b=255;break; case 'red': $this->r=255;$this->g=0;$this->b=0;break; case 'blue': $this->r=0;$this->g=0;$this->b=255;break; default:$this->r=255;$this->g=0;$this->b=255; } } } $a=new piksel; echo $a->cikti(100,100); ?>
index.php?r=50&g=50&b=50 Çıktısı
index.php?s=pink Çıktısı