imagearc

(PHP 4, PHP 5, PHP 7, PHP 8)

imagearc画弧线

说明

imagearc(
    GdImage $image,
    int $center_x,
    int $center_y,
    int $width,
    int $height,
    int $start_angle,
    int $end_angle,
    int $color
): bool

imagearc() 绘制以指定坐标为中心的弧线。

参数

image

由图象创建函数(例如imagecreatetruecolor())返回的 GdImage 对象。

center_x

中心的 x 坐标。

center_y

中心的 y 坐标。

width

弧宽。

height

弧高。

start_angle

弧线起始角度,以度为单位。

end_angle

弧线结束角度,以度为单位。0° 位于三点钟位置,顺时针绘制弧线。

color

颜色标识符使用 imagecolorallocate() 创建。

返回值

成功时返回 true, 或者在失败时返回 false

更新日志

版本 说明
8.0.0 image 现在需要 GdImage 实例;之前需要有效的 gd resource

范例

示例 #1 使用 imagearc() 画圆

<?php

// 创建 200*200 图像
$img = imagecreatetruecolor(200, 200);

// 分配一些颜色
$white = imagecolorallocate($img, 255, 255, 255);
$red = imagecolorallocate($img, 255, 0, 0);
$green = imagecolorallocate($img, 0, 255, 0);
$blue = imagecolorallocate($img, 0, 0, 255);

// 画头
imagearc($img, 100, 100, 200, 200, 0, 360, $white);
// 嘴
imagearc($img, 100, 100, 150, 150, 25, 155, $red);
// 先左眼,然后右眼
imagearc($img, 60, 75, 50, 50, 0, 360, $green);
imagearc($img, 140, 75, 50, 50, 0, 360, $blue);

// 在浏览器中输出图像
header("Content-type: image/png");
imagepng($img);

// 释放内存
imagedestroy($img);

?>

以上例程的输出类似于:

示例输出:使用 imagearc() 画圆

参见

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top