GD ve Resim İşlevleri
PHP Manual

imagesetpixel

(PHP 4, PHP 5)

imagesetpixel — Bir pikselin rengini değiştirir

Açıklama

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

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($gd, 255, 0, 0);

for (
$i = 0; $i < 100000; $i++) {
  
imagesetpixel($gd, round($x),round($y), $red);
  
$a = rand(0, 2);
  
$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


GD ve Resim İşlevleri
PHP Manual