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

imagefilledrectangle() function in PHP

PHPz
Release: 2023-08-30 09:06:02
forward
1106 people have browsed it

imagefilledrectangle() function draws a filled rectangle.

Syntax

imagefilledrectangle( $img, $x1, $y1, $x2, $y2, $color )
Copy after login

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);
?>
Copy after login

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!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template