Evan's Drawing
CODE FOLLOWS
<?php
include('includes/header.php');
error_reporting(E_ALL);
// For highlighting THIS file
$self = basename(__FILE__);
?>
<h1>Evan's Drawing</h1>
<!-- Display the image generated by the slave file -->
<img src="evans-drawing.php" alt="Face with X">
<br><br>
<hr><br>
<b>CODE FOLLOWS</b><br><br>
<?php
// Show THIS file's code
highlight_file($self);
echo "<hr><br><b>SLAVE CODE FOLLOWS</b><br><br>";
// Show the drawing code
highlight_file('evans-drawing.php');
include('includes/footer.php');
?>
SLAVE CODE FOLLOWS
<?php
// --- Create canvas ---
$width = 300;
$height = 300;
$image = imagecreatetruecolor($width, $height);
// --- Colors ---
$white = imagecolorallocate($image, 255, 255, 255);
$black = imagecolorallocate($image, 0, 0, 0);
$red = imagecolorallocate($image, 255, 0, 0);
// Fill background
imagefilledrectangle($image, 0, 0, $width, $height, $white);
// --- Draw the face (circle) ---
$centerX = $width / 2;
$centerY = $height / 2;
$radius = 100;
$thickness = 8;
imagesetthickness($image, $thickness);
imagearc($image, $centerX, $centerY, $radius * 2, $radius * 2, 0, 360, $black);
// --- Eyes ---
$eyeRadius = 10;
imagefilledellipse($image, $centerX - 40, $centerY - 30, $eyeRadius, $eyeRadius, $black);
imagefilledellipse($image, $centerX + 40, $centerY - 30, $eyeRadius, $eyeRadius, $black);
// --- Sad mouth ---
imagearc($image, $centerX, $centerY + 40, 100, 60, 20, 160, $black);
// --- Draw thick red X ---
imagesetthickness($image, 25); // <-- Make the X THICK
// Diagonal top-left → bottom-right
imageline($image, 40, 40, $width - 40, $height - 40, $red);
// Diagonal bottom-left → top-right
imageline($image, 40, $height - 40, $width - 40, 40, $red);
// Output PNG
header("Content-Type: image/png");
imagepng($image);
imagedestroy($image);
?>