Сформировать прямоугольник с закругленными краями

PHOTO EMBED

Sat Apr 24 2021 11:46:58 GMT+0000 (Coordinated Universal Time)

Saved by @MaksIT #php

function roundrect($im, $x1, $y1, $x2, $y2, $rad, $col) {
    
    imageline($im, ($x1 + $rad), $y1, ($x2 - $rad), $y1, $col);
    imageline($im, ($x1 + $rad), $y2, ($x2 - $rad), $y2, $col);
    imageline($im, $x1, ($y1 + $rad), $x1, ($y2 - $rad), $col);
    imageline($im, $x2, ($y1 + $rad), $x2, ($y2 - $rad), $col);
    imagearc($im, ($x1 + $rad), ($y1 + $rad), (2 * $rad), (2 * $rad), 180, 270, $col);
    imagearc($im, ($x2 - $rad), ($y1 + $rad), (2 * $rad), (2 * $rad), 270, 360, $col);
    imagearc($im, ($x2 - $rad), ($y2 - $rad), (2 * $rad), (2 * $rad), 0, 90, $col);
    imagearc($im, ($x1 + $rad), ($y2 - $rad), (2 * $rad), (2 * $rad), 90, 180, $col);
}


$myImage = imagecreate(200,100);
$myGrey  = imagecolorallocate($myImage,204,204,204);
$myBlack = imagecolorallocate($myImage,0,0,0);
roundrect($myImage, 20, 10, 180, 90, 20, $myBlack);
header("Content-type: image/png");
imagepng($myImage);
imagedestroy($myImage);
content_copyCOPY

https://htmlweb.ru/php/example/image_box2.php