Evan's Drawing

Face with X



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($image255255255);
$black imagecolorallocate($image000);
$red   imagecolorallocate($image25500);

// Fill background
imagefilledrectangle($image00$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 20360$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 401006020160$black);

// --- Draw thick red X ---
imagesetthickness($image25); // <-- Make the X THICK

// Diagonal top-left → bottom-right
imageline($image4040$width 40$height 40$red);

// Diagonal bottom-left → top-right
imageline($image40$height 40$width 4040$red);

// Output PNG
header("Content-Type: image/png");
imagepng($image);
imagedestroy($image);
?>