#!/usr/bin/perl

use CGI::Carp qw/fatalsToBrowser/;
use GD;
use Time::Local;

$| = 1;

print "Content-type: image/png\n\n";

$margin = 2;
$top = "days until Eevee moves";
$bottom = "in with Kupo, maybe!";
($smallw, $smallh) = (gdSmallFont->width, gdSmallFont->height);
$topsize = length($top) * $smallw;
$botsize = length($bottom) * $smallw;

$width = $margin * 2 + (($topsize > $botsize) ? $topsize : $botsize);
$height = $margin * 6 + $smallh * 2 + gdGiantFont->height;

$img = new GD::Image($width, $height);

$colors{black} = $img->colorAllocate(0, 0, 0);
$colors{white} = $img->colorAllocate(255, 255, 255);
$img->fill(0, 0, $colors{white});

$img->string(gdSmallFont, int(($width - $topsize) / 2), $height - $smallh * 2 - $margin * 3, $top, $colors{black});
$img->string(gdSmallFont, int(($width - $botsize) / 2), $height - $margin - $smallh, $bottom, $colors{black});

$num = int((timegm(0, 0, 6, 28, 4, 2005) - time) / 36 / 24) / 100;
$numsize = length($num) * gdGiantFont->width;

$img->string(gdGiantFont, int(($width - $numsize) / 2), $margin, $num, $colors{black});

print $img->png;

