3v4l.org

run code in 300+ PHP versions simultaneously
<?php $width = 150; $height = 100; // create new image $img = imagecreatetruecolor($width, $height); // transparent background $background = imagecolorallocate($img, 0xFF, 0xFF, 0xFF); imagefilledrectangle ($img, 0,0, $width,$height, $background); imagecolortransparent($img, $background); // helper function, draws pixel and mirrors it function setpixel4($img, $centerX, $centerY, $deltaX, $deltaY, $color) { imagesetpixel($img, $centerX + $deltaX, $centerY + $deltaY, $color); imagesetpixel($img, $centerX - $deltaX, $centerY + $deltaY, $color); imagesetpixel($img, $centerX + $deltaX, $centerY - $deltaY, $color); imagesetpixel($img, $centerX - $deltaX, $centerY - $deltaY, $color); } // red ellipse, 2*10px border $color = imagecolorallocate($img, 0xFF, 0x00, 0x00); $centerX = $width /2; $radiusX = ($width -20) / 2; $centerY = $height/2; $radiusY = ($height-20) / 2; static $maxTransparency = 0x7F; // 127 $radiusX2 = $radiusX * $radiusX; $radiusY2 = $radiusY * $radiusY; // upper and lower halves $quarter = round($radiusX2 / sqrt($radiusX2 + $radiusY2)); for ($x = 0; $x <= $quarter; $x++) { $y = $radiusY * sqrt(1-$x*$x/$radiusX2); $error = $y - floor($y); $transparency = round($error * $maxTransparency); $alpha = $color | ($transparency << 24); $alpha2 = $color | (($maxTransparency - $transparency) << 24); setpixel4($img, $centerX, $centerY, $x, floor($y), $alpha); setpixel4($img, $centerX, $centerY, $x, floor($y)+1, $alpha2); } // right and left halves $quarter = round($radiusY2 / sqrt($radiusX2 + $radiusY2)); for ($y = 0; $y <= $quarter; $y++) { $x = $radiusX * sqrt(1-$y*$y/$radiusY2); $error = $x - floor($x); $transparency = round($error * $maxTransparency); $alpha = $color | ($transparency << 24); $alpha2 = $color | (($maxTransparency - $transparency) << 24); setpixel4($img, $centerX, $centerY, floor($x), $y, $alpha); setpixel4($img, $centerX, $centerY, floor($x)+1, $y, $alpha2); } // send PNG to browser header("Content-type: image/png"); imagepng($img, "", 9, PNG_ALL_FILTERS); ?>
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Call to undefined function imagecreatetruecolor() in /in/B3WE9:6 Stack trace: #0 {main} thrown in /in/B3WE9 on line 6
Process exited with code 255.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.37, 5.6.0 - 5.6.28
Fatal error: Call to undefined function imagecreatetruecolor() in /in/B3WE9 on line 6
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: imagecreatetruecolor() in /in/B3WE9 on line 6
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Fatal error: Call to undefined function: imagecreatetruecolor() in /in/B3WE9 on line 6
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: imagecreatetruecolor() in /in/B3WE9 on line 6

preferences:
202.45 ms | 401 KiB | 367 Q