修改以下代码让它的渐变效果从下往上。$imgsrc = imagecreatefromstringfile_get_contentsimagejpg; $imgsrcw = imagesx$imgsrc; $imgsrch = imagesy$imgsrc; $width = 1920; $x1 = 0; $x2 = $imgsrcw - $x1 - 20; $y1 = $imgsrch - $w
$imgsrc = imagecreatefromstring(file_get_contents("image.jpg")); $imgsrcw = imagesx($imgsrc); $imgsrch = imagesy($imgsrc); $width = 1920; $x1 = 0; $x2 = $imgsrcw - $x1 - 20; $y1 = 2; // 从上往下的起始位置改为从下往上的起始位置 $y2 = $y1 + $width; $steps = $x2 - $x1; for($i = 0; $i < $steps; $i ++) { $alphax = round($i/($steps/127))+60; if($alphax >= 128) $alphax = 127; $alpha = imagecolorallocatealpha($imgsrc, 255, 255, 255, $alphax); // 将矩形的填充位置从下往上改为从上往下 imagefilledrectangle($imgsrc, ($i+$x1), $y2, ($i+$x1+1), $y1, $alpha); } header('content-type: image/jpeg'); imagejpeg($imgsrc,'09.jpg'); imagedestroy($imgsrc)
原文地址: https://www.cveoy.top/t/topic/c8PV 著作权归作者所有。请勿转载和采集!