O'Reilly logo

Mastering Perl/Tk by Nancy Walsh, Stephen Lidie

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

clock-bezier.ppl

In Chapter 22, we discussed the Netscape PerlPlus Plugin and used several PPL programs in our examples. We include two PPL programs in this appendix. The first is the clock-bezier.ppl program, shown in Figure C-3.

clock-bezier.ppl

Figure C-3. clock-bezier.ppl

#!/usr/local/bin/perl -w # # This most entertaining program was written in Tcl/Tk by Scott Hess # (shess@winternet.com). It's a clock that uses a bezier curve anchored # at four points—the hour position, the minute position, the second # position and the center of the clock—to show the time. # # <Button-1> switches between display modes, and <Button-2> switches # between line thicknesses. # # Perl/Tk version by Stephen.O.Lidie@Lehigh.EDU, 2000/02/05. use POSIX qw/asin/; use Tk; use subs qw/buildclock hands setclock/; use vars qw/$clock %hand $mw $pi180 $resize/; use strict; %hand = ( hour => 0.40, minute => 0.75, second => 0.85, 0 => 0.00, intick => 0.95, outtick => 1.00, width => 0.05, scale => 100, type => 'bezier', types => [qw/normal curve angle bezier/], tindx => 3, normal => [qw/minute 0 0 second 0 0 hour 0 0 minute/], curve => [qw/minute 0 second 0 hour 0 minute/], angle => [qw/minute second second hour/], bezier => [qw/minute second 0 hour/], tick => [qw/intick outtick/], ); $pi180 = asin(1) / 90.0; $resize = 0; $mw = MainWindow->new; $clock = $mw->Canvas(qw/-width 200 -height 200/); $clock->pack(qw/-expand 1 -fill both/); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required