imagesetpixel

(PHP 4, PHP 5, PHP 7)

imagesetpixelBir pikselin rengini değiştirir

Açıklama

imagesetpixel ( resource $resim , int $x , int $y , int $renk ) : bool

imagesetpixel() işlevi koordinatları belirtilen pikselin rengini değiştirir.

Değiştirgeler

resim

imagecreatetruecolor() gibi bir resim oluşturma işlevinden dönen bir resim verisi.

x

Pikselin X konumu.

y

Pikselin Y konumu.

renk

imagecolorallocate() ile oluşturulmuş bir renk tanıtıcısı.

Dönen Değerler

Başarı durumunda TRUE, başarısızlık durumunda FALSE döner.

Örnekler

Örnek 1 - imagesetpixel() örneği

Normal bir resimle sonuçlanan rasgele bir çizim.

<?php

$x 
200;
$y 200;

$gd imagecreatetruecolor($x$y);

$corners[0] = array('x' => 100'y' =>  10);
$corners[1] = array('x' =>   0'y' => 190);
$corners[2] = array('x' => 200'y' => 190);

$red imagecolorallocate($gd25500);

for (
$i 0$i 100000$i++) {
  
imagesetpixel($gdround($x),round($y), $red);
  
$a rand(02);
  
$x = ($x $corners[$a]['x']) / 2;
  
$y = ($y $corners[$a]['y']) / 2;
}

header('Content-Type: image/png');
imagepng($gd);

?>

Yukarıdaki örnek şuna benzer bir çıktı üretir:

imagesetpixel.png

Ayrıca Bakınız