wish of those help I'm creating a line of hexagon-masked images using GD but I'm unable to work out how to create transparency around each mask. The collage itself works perfectly but it adds a white, not transparent background to the image, despite setting 127 on the alpha argument in the imagecolorallocatealpha function. The code is based on this SO answer. , You need
help you fix your problem This can be done by first setting its alpha value to 0 of the regions that you want to make them fully transparent (255 for others), and then save it to PNG. To set the alpha value of pixel-(x,y), it can be done:
image.at<cv::Vec4b>(y, x) = 0;
cv::cvtColor(image, image, CV_BGR2BGRA);
cv::Mat mask; // 0 for transparent regions, 255 otherwise (serve as the alpha channel)
it fixes the issue Hexagon with rounded corners are complex shapes to create and I usually recommend using SVG for creating them. The need for a transparent background makes it even more better suited for SVG. With SVG you can get better control over the shape, its curves etc and you don't have to add a lot of extra (unnecessary) elements to your markup also. All that is needed for creating this shape with SVG is to use a single path element along with a few L (line) and A (arc) commands. The L (line) command basically draws a line from point 1 to point 2 whereas the A (arc) command draws an arc of the specified radius (the first two values immediately following the A command).