Andrew's code for Drawing a Smiley Face

Smiley Face


WORKER CODE FOLLOWS

<?php
// Set content type
header("Content-Type: image/png");

// Image size
$width 300;
$height 300;

// Create image
$image imagecreatetruecolor($width$height);

// Colors
$yellow imagecolorallocate($image2552050);
$black  imagecolorallocate($image000);
$white  imagecolorallocate($image255255255);

// Fill background
imagefill($image00$white);

// Draw face
imagefilledellipse($image150150250250$yellow);

// Draw eyes
imagefilledellipse($image1101203040$black); // Left eye
imagefilledellipse($image1901203040$black); // Right eye

// Draw smile
imagefilledarc($image1501801501000180$blackIMG_ARC_PIE);

// Left eyebrow coordinates
$leftEyebrow = [
    
9590,   // top-left
    
11585,  // top-right
    
12095,  // bottom-right
    
90100   // bottom-left
];

// Right eyebrow coordinates
$rightEyebrow = [
    
18585,  // top-left
    
20590,  // top-right
    
210100// bottom-right
    
18095   // bottom-left
];

// Draw the polygons
imagefilledpolygon($image$leftEyebrow4$black);
imagefilledpolygon($image$rightEyebrow4$black);

// Output image
imagepng($image);

// Clean up
imagedestroy($image);