imagesettile

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

imagesettile设置要填充的平铺图像

说明

imagesettile(GdImage $image, GdImage $tile): bool

当使用特殊颜色 IMG_COLOR_TILED时,imagesettile() 设置所有区域填充函数(比如 imagefill()imagefilledpolygon())要使用的平铺图像。

平铺是指使用重复模式填充区域的图像。任何 GD 图像都可以用于平铺,并且通过使用 imagecolortransparent() 来设定平铺图像的透明颜色索引,可以创建允许底层区域的某些部分透过的平铺。

警告

平铺完成后不需要采取什么特殊动作,但如果要销毁平铺图像(或让 PHP 销毁),不能使用 IMG_COLOR_TILED 颜色,除非设置了新的平铺图像。

参数

image

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

tile

用作平铺的图像对象。

返回值

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

更新日志

版本 说明
8.0.0 imagetile 现在需要 GdImage 实例;之前需要 resource

范例

示例 #1 imagesettile() 示例

<?php
// Load an external image
$zend = imagecreatefromgif('./zend.gif');

// Create a 200x200 image
$im = imagecreatetruecolor(200, 200);

// Set the tile
imagesettile($im, $zend);

// Make the image repeat
imagefilledrectangle($im, 0, 0, 199, 199, IMG_COLOR_TILED);

// Output image to the browser
header('Content-Type: image/png');

imagepng($im);
imagedestroy($im);
imagedestroy($zend);
?>

以上例程的输出类似于:

示例输出:imagesettile()

add a note

User Contributed Notes

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