#!/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(260, 150) or die; $white = $img->colorAllocate(255,255,255); $black = $img->colorAllocate(0,0,0); $brown = $img->colorAllocate(192,128,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,100,40,$black); $img->filledRectangle(40,20,80,60,$brown); $img->rectangle(40,20,80,60,$black); $img->string(gdSmallFont,43,30,"0.5 kg",$white); $vessel->offset(150,30); $img->filledPolygon($vessel,gdTiled); $img->polygon($vessel,$black); $vessel->offset(-150,-30); $img->line(160,40,240,40,$black); $img->filledRectangle(180,80,220,120,$green); $img->rectangle(180,80,220,120,$black); $img->string(gdSmallFont,190,90,"2 kg",$white); $fn = $0; $fn =~ s/pl$/png/; open(F, ">$fn") or die; binmode F; print F $img->png; close(F);