imagelayereffect()函数是PHP中的内置函数,用于设置alpha混合标志以使用分层效果。如果成功,此函数返回True;如果失败,则返回False。
用法:
bool imagelayereffect( $image, $effect )
参数:该函数接受上述和以下描述的两个参数:
- $image:它由图像创建函数之一(例如imagecreatetruecolor())返回。它用于创建图像的尺寸。
 - $effect:此参数设置效果常数的值。效果常数的值如下所示:
- IMG_EFFECT_REPLACE:用于设置像素替换。等效于将True传递给imagealphablending()函数。
 - IMG_EFFECT_ALPHABLEND:用于设置普通像素混合。等效于将False传递给imagealphablending()函数。
 - IMG_EFFECT_NORMAL:与IMG_EFFECT_ALPHABLEND相同。
 - IMG_EFFECT_OVERLAY:这是黑色背景像素将保持黑色,白色背景像素将保持白色而灰色背景像素将采用前景像素颜色的效果。
 - IMG_EFFECT_MULTIPLY:设置乘法效果。
 
 
返回值:如果成功,此函数返回True;如果失败,则返回False。
以下示例程序旨在说明PHP中的imagelayereffect()函数:
示例1:
<?php 
// Setup an image 
$im = imagecreatetruecolor(200, 200); 
  
// Set a background 
imagefilledrectangle($im, 0, 0, 200, 200, imagecolorallocate($im, 220, 220, 220)); 
  
// Apply the overlay alpha blending flag 
imagelayereffect($im, IMG_EFFECT_OVERLAY); 
  
// Draw two grey ellipses 
imagefilledellipse($im, 100, 100, 160, 160, imagecolorallocate($im, 100, 255, 100)); 
imagefilledellipse($im, 100, 100, 140, 140, imagecolorallocate($im, 100, 100, 255)); 
imagefilledellipse($im, 100, 100, 100, 100, imagecolorallocate($im, 255, 100, 100)); 
  
// Output 
header('Content-type: image/png'); 
  
imagepng($im); 
imagedestroy($im); 
?>输出:

示例2:
<?php 
// Setup an image 
$im = imagecreatetruecolor(200, 200); 
  
// Set a background 
imagefilledrectangle($im, 0, 0, 200, 200, imagecolorallocate($im, 220, 220, 220)); 
  
// Apply the overlay alpha blending flag 
imagelayereffect($im, IMG_EFFECT_REPLACE); 
  
// Draw two grey ellipses 
imagefilledellipse($im, 100, 100, 160, 160, imagecolorallocate($im, 100, 255, 100)); 
imagefilledellipse($im, 100, 100, 140, 140, imagecolorallocate($im, 100, 100, 255)); 
imagefilledellipse($im, 100, 100, 100, 100, imagecolorallocate($im, 255, 100, 100)); 
  
// Output 
header('Content-type: image/png'); 
  
imagepng($im); 
imagedestroy($im); 
?>输出:

参考: http://php.net/manual/en/function.imagelayereffect.php
相关用法
- p5.js day()用法及代码示例
 - PHP key()用法及代码示例
 - p5.js log()用法及代码示例
 - PHP each()用法及代码示例
 - p5.js cos()用法及代码示例
 - PHP each()用法及代码示例
 - p5.js tan()用法及代码示例
 - p5.js sq()用法及代码示例
 - PHP Ds\Map put()用法及代码示例
 - p5.js pow()用法及代码示例
 - PHP tan( )用法及代码示例
 - p5.js sin()用法及代码示例
 
注:本文由纯净天空筛选整理自Vishal_Khoda大神的英文原创作品 PHP | imagelayereffect() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
