略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: imagesetbrush

2024-04-27

imagesetbrush

(PHP 4 >= 4.0.6, PHP 5, PHP 7, PHP 8)

imagesetbrush设定画线用的画笔图像

说明

imagesetbrush(resource $image, resource $brush): bool

当用特殊的颜色 IMG_COLOR_BRUSHEDIMG_COLOR_STYLEDBRUSHED 绘画时,imagesetbrush() 设定了所有画线的函数(例如 imageline()imagepolygon())所使用的画笔图像。【注:使用画笔图像,所画的线是由 brush 所代表的图像构成的。请参考并尝试运行 imagesetstyle() 中的例子以帮助理解。】

注意:

使用完画笔图像后不需要采取什么特殊动作。但如果销毁了画笔图像,在设定一个新的画笔图像之前不能使用 IMG_COLOR_BRUSHEDIMG_COLOR_STYLEDBRUSHED

注意:

本函数是 PHP 4.0.6 添加的。

add a noteadd a note

User Contributed Notes 1 note

up
0
brent at ebrent dot net
15 years ago
Use a brush to create a thick line.

To create a 3x3 red brush:

<?php
$brush_size
= 3;
$brush = imagecreatetruecolor($brush_size,$brush_size);
$brush_color = imagecolorallocate($brush,255,0,0);
imagefill($brush,0,0,$brush_color);
imagesetbrush($im,$brush);
?>

Then use imageline() or imagepolygon() with IMG_COLOR_BRUSHED as the color.

To stop using the brush, destroy it:

<?php imagedestroy($brush); ?>

The brush can also be created from an existing image.

官方地址:https://www.php.net/manual/en/function.imagesetbrush.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3