Here is the code that I am using currently.
$image = imagecreatetruecolor(400, 300);
imagesavealpha($image, true);
imagesetthickness($image, 2);
$red = imagecolorallocate($image, 255, 0, 0);
$green = imagecolorallocate($image, 0, 255, 0);
$blue = imagecolorallocate($image, 0, 0, 255);
$transparent = imagecolorallocatealpha($image, 255, 255, 255, 0);
imagefill($image, 0, 0, $transparent);
imagerectangle($image, 2, 2, 398, 298, $red);
imagedashedline($image, 0, 150, 400, 150, $blue);
imagedashedline($image, 200, 0, 200, 300, $blue);
imagepolygon($image, array( 10, 180, 10, 250, 110, 250), 3, $red);
// imageflip($image, IMG_FLIP_VERTICAL);
ob_start();
imagepng($image);
printf('<img src="data:image/png;base64,%s"/>', base64_encode(ob_get_clean()));
imagedestroy($image);
The attached image is result of running the above code.
I want to flip the triangle in the bottom right corner and draw it along with the original image. I tried to use imageflip()
but it draws over the original image.
I know that imageflip()
is flipping the rectangle as well as dotted lines but they are symmetric so it is no big deal.
Setting the fill color to transparent did not work. Any help would be appreciated.
My aim is to take original image, flip it along the horizontal line and then flip the resulting image along vertical line.
Once I know how to flip along the horizontal line without loosing the original image, I can try to do the rest on my own.