Home  >  Article  >  Backend Development  >  imagefilledrectangle() function in PHP

imagefilledrectangle() function in PHP

PHPz
PHPzforward
2023-08-30 09:05:061070browse

imagefilledrectangle() function draws a filled rectangle.

Syntax

imagefilledrectangle( $img, $x1, $y1, $x2, $y2, $color )

Parameters

  • image

    Use imagecreatetruecolor() to create a blank image.

  • x1

    x coordinate of point 1.

  • y1

    The y coordinate of point 1.

  • x2

    The x coordinate of point 2.

  • y2

    The y coordinate of point 2.

  • color

    Fill color.

Return value

The imagefilledrectangle() function returns TRUE successfully and FALSE upon failure.

Example

The following is an example:

<?php
   // Create an image
   $img = imagecreatetruecolor(500, 300);
   $color = imagecolorallocate($img, 0, 128, 128);
   imagefilledrectangle($img, 30, 30, 470, 270, $color);
   header("Content-type: image/png");
   imagepng($img);
   imagedestroy($img);
?>

Output

The following is the output:

imagefilledrectangle() function in PHP

The above is the detailed content of imagefilledrectangle() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete