Forum und email

imagesetpixel

(PHP 4, PHP 5)

imagesetpixel — Set a single pixel

설명

bool imagesetpixel ( resource $image , int $x , int $y , int $color )

imagesetpixel() draws a pixel at the specified coordinate.

매개변수

font

내장 글꼴 1, 2, 3, 4, 5(큰 숫자가 큰 글꼴)나 imageloadfont()로 등록한 글꼴 식별자를 사용할 수 있습니다.

x

x-coordinate

y

y-coordinate

color

A color identifier created with imagecolorallocate()

반환값

성공할 경우 TRUE를, 실패할 경우 FALSE를 반환합니다.

예제

Example#1 imagesetpixel() example

A random drawing that ends with a regular picture.

<?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);

?>

위 예제의 출력 예: