#!/usr/bin/perl -w # http://www.hewgill.com/galilean-thermometer/index.html # This program creates a figure for use in the above page. # Requires: # GD.pm - http://stein.cshl.org/WWW/software/GD/GD.html # libgd - http://www.boutell.com/gd/ use GD; $img = new GD::Image(120, 150) or die; $white = $img->colorAllocate(255,255,255); $black = $img->colorAllocate(0,0,0); $green = $img->colorAllocate(0,192,0); $img->interlaced('true'); $hatch = new GD::Image(5,5); $hatch->transparent($hatch->colorAllocate(255,255,255)); $hatch->line(0,4,4,0,$hatch->colorAllocate(0,0,0)); $img->setTile($hatch); $vessel = new GD::Polygon; $vessel->addPt(0,0); $vessel->addPt(0,100); $vessel->addPt(100,100); $vessel->addPt(100,0); $vessel->addPt(90,0); $vessel->addPt(90,90); $vessel->addPt(10,90); $vessel->addPt(10,0); $vessel->offset(10,30); $img->filledPolygon($vessel,gdTiled); $img->polygon($vessel,$black); $vessel->offset(-10,-30); $img->line(20,40,40,40,$black); $img->line(80,40,100,40,$black); $img->filledRectangle(40,20,80,60,$green); $img->rectangle(40,20,80,60,$black); $img->filledRectangle(45,25,75,55,$white); $img->rectangle(45,25,75,55,$black); $img->string(gdSmallFont,43,5,"0.5 kg",$black); $fn = $0; $fn =~ s/pl$/png/; open(F, ">$fn") or die; binmode F; print F $img->png; close(F);