Catalyst-Blinker

 view release on metacpan or  search on metacpan

Blinker.pm  view on Meta::CPAN

                $canvas->ellipse($center,$center,$x,$x);
                $canvas->lineWidth(2);
                $x--;
                $c++;
            }
        },
    );
    $blinker->bring_to_front;
    my $blinkstate = 0;
    my $blinkcolor = 16;
    my $timer = Prima::Timer->new(
        timeout   => 100,
        onTick    => sub {
            my $self = shift;
            if ( $blinkcolor == 8 && $countdown_to_hide > 0 ) {
                # green waits and hides the blinker
                unless (--$countdown_to_hide) {
                    $self->stop;
                    $blinker->hide;
                }
            }

Blinker.pm  view on Meta::CPAN

                # green glows steadily, then nicely fades out
                $blinkstate = 7;
            }

            $c = ( $blinkstate > 7 ) ? ( 15 - $blinkstate ) : $blinkstate;
            $c = (( $c << 4 ) | 0x80) << $blinkcolor;
            $c |= ( $c >> 8 ) if $c > 0x10000; # makes it yellow, as red doesn't blink at all
            $blinker->backColor($c);
        },
    );
    $timer->start;
    my $reader = Prima::File->new(
        file   => $r,
        mask   => fe::Read(),
        onRead => sub {
            my $cmd = <$r>;
            chomp $cmd;
            if ( $cmd eq 'start' ) {
                $blinkstate = 0;
                $countdown_to_hide = 32;
                $blinkcolor = 8;
            } elsif ( $cmd eq 'stop') {
                $timer->start;
                $blinkstate = 0;
                $blinkcolor = 16;
                $blinker->backColor(0x808000);
                $blinker->show;
                $blinker->bring_to_front;
            } elsif ( $cmd eq 'fail') {
                $blinker->backColor(cl::LightRed());
                $blinker->show;
                $blinker->bring_to_front;
                $timer->stop;
            }
        },
    );
    run Prima;
    exit;
}

1;

=head1 AUTHOR



( run in 0.721 second using v1.01-cache-2.11-cpan-49f99fa48dc )