Style for a long callout list
Matthew Seaman
m.seaman at infracaninophile.co.uk
Sun Aug 1 09:34:58 UTC 2004
On Sun, Aug 01, 2004 at 06:10:47AM +0000, Murray Stokely wrote:
> On Sat, Jul 24, 2004 at 06:06:09PM +0400, Yar Tikhiy wrote:
> > > Stick with it for now. We're hoping to add callout images up to 25 some
> > > time soon.
> >
> > I see, thanks!
>
> Maybe you guys could help us out and just generate the little images
> required? We only go up to 15 right now, as that is the most needed
> by the Handbook. As Ceri said, we'd like to have images up to at
> least 25. Since you are the first to need those images, how about
> making them for us and committing them to the tree? =)
>
> It should actually be possible to make these from the command line
> with tools like ImageMagick. We just need a circle with a number on
> top of it.
It's Sunday. I was bored. Here's a script to generate those images:
#!/usr/bin/perl -w
use strict;
use POSIX qw(floor ceil);
use GD;
$0 =~ s@^.*/@@;
sub colourARGB($$$$)
{
my $alpha = shift;
my $red = shift;
my $green = shift;
my $blue = shift;
# Alpha is in range 0 (opaque) to 127 (fully transparent),
# R, G, B in range 0 .. 255. Force values into range.
$alpha &= 0x7f;
$red &= 0xff;
$green &= 0xff;
$blue &= 0xff;
return $alpha << 24 | $red << 16 | $green << 8 | $blue;
}
MAIN:
{
my $im; # The Image object
my $xsize = 16;
my $ysize = 16;
my $font = "/usr/X11R6/lib/X11/fonts/bitstream-vera/VeraMoBd.ttf";
# Bitstream Vera Mono Bold.
my $bgcol = colourARGB( 127, 255, 255, 255 ); # Transparent White
my $fgcol = colourARGB( 0, 255, 204, 0 ); # Orange
my $txcol = colourARGB( 0, 0, 0, 0 ); # Black
#my $bgcol = colourARGB( 127, 255, 255, 255 ); # Transparent White
#my $fgcol = colourARGB( 0, 153, 0, 0 ); # Daemon Red
#my $txcol = colourARGB( 0, 255, 255, 255 ); # White
my $text = "25"; # What to write onto the image
my $fsize; # Font size
my @bounds; # For compositing text onto image
my $x; # Coords of LL of text
my $y; # Coords of LL of text
# Usage: calloutnum.pl [text [size]]
$text = $ARGV[0] if ( defined $ARGV[0] );
$xsize = $ysize = $ARGV[1] if ( defined $ARGV[1] );
$fsize = $xsize / 2;
$im = new GD::Image->newTrueColor( $xsize, $ysize )
|| die "$0: Failed to create image -- $!\n";
$im->saveAlpha(1);
# Fill image with background colour, center a circle of foreground
# colour on top of that, and write a number centered in that.
$im->alphaBlending(0);
$im->filledRectangle( 0, 0, $xsize - 1, $ysize - 1, $bgcol );
$im->alphaBlending(1);
$im->setAntiAliased($fgcol);
$im->filledEllipse(
$xsize / 2,
$ysize / 2,
$xsize - 2,
$ysize - 2,
gdAntiAliased
);
# First, get the bounding box for the text. Choose fontsize so that
# 2 characters will approx. fill image size.
@bounds = GD::Image->stringFT( $txcol, $font, $fsize, 0, 0, 0, $text )
or die "$0: Can't render text -- $@\n";
$x = floor( 0.5 * ( $xsize + $bounds[0] - $bounds[2] - 1 ) );
$y = ceil( 0.5 * ( $ysize + $bounds[1] - $bounds[7] ) );
$im->stringFT( $txcol, $font, $fsize, 0, $x, $y, $text )
|| die "$0: Can't write using TrueType font -- $@\n";
print $im->png;
}
#
# That's All Folks!
#
Cheers,
Matthew
--
Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks
Savill Way
PGP: http://www.infracaninophile.co.uk/pgpkey Marlow
Tel: +44 1628 476614 Bucks., SL7 1TH UK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-doc/attachments/20040801/dc1ee056/attachment.sig>
More information about the freebsd-doc
mailing list