imagesetpixel

Set a single pixel

&reftitle.description; `bool` `imagesetpixel` `GdImage` `image` `int` `x` `int` `y` `int` `color`

`imagesetpixel` draws a pixel at the specified coordinate.

&reftitle.parameters;

&gd.image.description;

`x`

- x-coordinate.

`y`

- y-coordinate.

`color`

- &gd.identifier.color;

&reftitle.returnvalues;

&return.success;

&reftitle.changelog;

&Version; | &Description;
&gd.changelog.image-param;

&reftitle.examples;

### `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($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);

    ?>

&example.outputs.similar; Output of example : imagesetpixel()
&reftitle.seealso;

- `imagecreatetruecolor`
- `imagecolorallocate`
- `imagecolorat`