Stealing liberaly and recoding a little. This does the same thing (mostly) but without all the different slices. This lets you set the angle that you could like to be removed every frame and the timer length. Moved configuration data to the top and thats about it. Mine is probably worse in some ways or better in others, but in reality i was just playing and thought i would share.

#! perl -slw use strict; use warnings; use Time::HiRes qw[ time ]; use Tk::Canvas; my $inc = 1; #degrees to move each frame my $length = 10; #seconds to take my ($width, $height) = (480,480); my $trip_point = 90; my $code = 'A123BC'; my $repeatTime = ($length * 1000) / (360 / $inc); my $mw = MainWindow->new; my $canvas = $mw->Canvas( -width => $width, -height => $height, -bg => 'black', )->pack; my $start = 359; my $arc = $canvas->createArc( 0, 0, $width, $height, -fill => 'white', -outline => undef, -extent => $start, -start => 90, -tag => 'arc', ); ## Bind action to space bar $mw->bind( '<space>', sub { my $rep; my $tripped = 0; ## Set up the repeating callback with the delay calculated earlier $rep = $mw->repeat( $repeatTime, sub { $start -= $inc; $canvas->itemconfigure('arc', -extent => $start ); if ($start < 0) { $canvas->itemconfigure('arc', -extent => 0); $rep->cancel; printf "\a"; $canvas->createText($width / 2, $height /2, -text => $code, -tag => 'code', -fill => 'red', ); } elsif ($start < $trip_point and !$tripped) { printf "\a"; $tripped = 1; $canvas->itemconfigure('arc', -fill => 'red'); } }); }); $mw->MainLoop;

Update: .... errr cut and pasted the wrong file, sorry bout that.


___________
Eric Hodges

In reply to Re^2: Shrinking Pie Analog Countdown Timer by eric256
in thread Shrinking Pie Analog Countdown Timer by Optimalist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.