PHP | ImageFilled()函数

这个 imagefilledellipse() 函数是PHP中的一个内置函数,用于绘制填充椭圆。它用图形绘制椭圆 指定中心坐标 .

null

语法:

bool imagefilledellipse( $image, $cx, $cy, $width, $height, $color )

参数: 此函数接受六个参数,如下所述:

  • $image: 这个 imagecreatetruecolor() 函数用于创建给定大小的空白图像。
  • $cx: 中心的x坐标。
  • $cy: 中心的y坐标。
  • $width: 椭圆的宽度。
  • $height: 椭圆的高度。
  • $color: 填充颜色。使用imagecolorallocate()创建的颜色标识符。

返回值: 此函数在成功时返回TRUE,失败时返回FALSE。

下面的程序说明了 imagefilledellipse() 函数。

项目1:

<?php
// It create the size of image or blank image.
$image = imagecreatetruecolor(500, 300);
// Set the background color of image.
$bg = imagecolorallocate( $image , 205, 220, 200);
// Fill background with above selected color.
imagefill( $image , 0, 0, $bg );
// Set the color of an ellipse.
$col_ellipse = imagecolorallocate( $image , 0, 102, 0);
// Function to draw the filled ellipse.
imagefilledellipse( $image , 250, 150, 400, 250, $col_ellipse );
// Output of the image.
header( "Content-type: image/png" );
imagepng( $image );
?>


输出: image-fill

项目2:

<?php
// It create the size of image or blank image.
$image = imagecreatetruecolor(300, 500);
// Set the background color of image.
$bg = imagecolorallocate( $image , 205, 220, 200);
// Fill background with above selected color.
imagefill( $image , 0, 0, $bg );
// set color of ellipse.
$col_ellipse = imagecolorallocate( $image , 0, 102, 0);
// function to draw the filled ellipse with white color.
imagefilledellipse( $image , 150, 250, 250, 400, $col_ellipse );
// output of the image.
header( "Content-type: image/png" );
imagepng( $image );
?>


输出: ellipse filled

你也可以试着用同样的函数画一个圆。

相关文章: PHP | imageellipse()函数

参考: http://php.net/manual/en/function.imagefilledellipse.php

© 版权声明
THE END
喜欢就支持一下吧
点赞9 分享