Here is another Tk version, :-) Mine differs in style from BrowserUk's. He made a bunch of pie segments to manipulate. I used a technique of layering an arc over a background circle, and changing their extent and color. There are many ways to do it!

UPDATE: added 'cleanup' tags to improve performance, and fixed the bell repitition problem.

#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = tkinit; $mw->fontCreate('big', -family=>'arial', -weight=>'bold', -size=>int(-18*18/14)); my $running = 0; my $canvas = $mw->Canvas(-width => 600, -height => 600, -bg =>'black')->pack(); my $start_message = $canvas->createText(300,30, -text => 'Press SpaceBar to Start', -fill => 'hotpink', -anchor => 'center', -font => 'big'); $mw->bind('<space>', \&start ); MainLoop; ########################################################### sub start{ return if $running; $running = 1; $canvas->delete('cleanup'); $canvas->itemconfigure($start_message, -state => 'hidden'); $canvas->createOval(100,100,500,500, -fill => 'white', -tags => ['backplate','cleanup'], ); my $extent = -1; my $arc = $canvas->createArc(100,100,500,500, -extent => $extent, -start => 90, -fill => 'black', -tags => ['cleanup'], ); my $repeater; $repeater = $mw->repeat(20, sub{ $extent = $extent - 1; $canvas->itemconfigure($arc, -extent => $extent); if( $extent == -320 ){ print chr(07); #beep $canvas->itemconfigure('backplate', -fill => 'red'); } if( $extent < -359 ){ $repeater->cancel; &message; } }); } ############################################## sub message{ $canvas->createText(300,300, -text => time, -anchor => 'center', -font => 'big', -tags => ['cleanup'], ); $running = 0; $canvas->itemconfigure($start_message, -state => 'normal'); }

I'm not really a human, but I play one on earth. flash japh

In reply to Re: Shrinking Pie Analog Countdown Timer by zentara
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.