This scrolls the text in DATA, in a receding manner, like the story intro's in all the Star War movies. It couldn't be done without Tk::Zinc
#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::Zinc;
my %data;
my $count = 0;
while (<DATA>){
chomp;
$data{$count}{'text'} = $_;
$count++;
}
my $count_tot = $count;
$count = 0;
my $mw = MainWindow->new();
$mw->geometry($mw->screenwidth . 'x' .
$mw->screenheight . '+0+20');
$mw->title("Revenge of the Microsith ----- Click to exit");
my $zinc = $mw->Zinc(
-height => $mw->screenheight,
-width => $mw->screenwidth,
-backcolor => 'black',
-relief => 'raised'
)->pack();
$zinc->fontCreate(
"fonta",
-family => 'arial',
-size => -30,
-weight => 'bold'
);
#setup first line
$data{$count}{'group'} = $zinc->add('group',1,
-visible=> 1,
-tags => ['mover'],
);
$zinc->translate($data{$count}{'group'},0, $mw->screenheight - 100);
for(1..$count_tot){
$data{$_}{'group'} = $zinc->clone( $data{0}{'group'}, -tags => ['mover
+'] );
$zinc->translate($data{$_}{'group'},0, $_* 30 );
}
$data{$count}{'rect'} = $zinc->add('rectangle', $data{$count}{'group'}
+,
[
50,0,
$mw->screenwidth -50, 30
],
#-linecolor => 'blue',
#-linewidth => 1,
);
$data{$count}{'obj'} = $zinc->add('text',$data{$count}{'group'},
-position => [$mw->screenwidth/2 , 15 ],
-text => $data{$count}{'text'},
-anchor => 'center',
-color => 'hotpink',
-font => 'fonta',
);
$mw->bind( '<ButtonPress-1>', sub { exit; } );
my $id = Tk::After->new($zinc, 75, 'repeat', \&move );
MainLoop;
sub move {
if( $count < $count_tot ){
$count++;
$data{$count}{'rect'} = $zinc->add('rectangle', $data{$count}{'gro
+up'},
[
50,0,
$mw->screenwidth -50, 30
],
#-linecolor => 'blue',
#-linewidth => 1,
);
$data{$count}{'obj'} = $zinc->add('text',$data{$count}{'group'},
-position => [$mw->screenwidth/2 , 15 ],
-text => $data{$count}{'text'},
-anchor => 'center',
-color => 'hotpink',
-font => 'fonta',
);
}
for(0..$count_tot){
my $aref = $zinc->tget($data{$_}{'group'});
if( @$aref[5] < .8*($mw->screenheight)){
$zinc->scale($data{$_}{'obj'},.99,.99);
}
}
$zinc->translate('mover',0,-1);
#check for end condition
my $arefend = $zinc->tget($data{$count_tot}{'group'});
if( @$arefend[5] < .78*($mw->screenheight)){ exit }
}
__DATA__
Attack of the Microsith
Not so long ago, in a computer not so far away,
the evil lord of the Microsith, Darth Bill, was
conspiring with the enemies of Open Source Federation
to take complete control over all motherboards in
the known universe.
It was during this monstrous conspiracy, that Prince
Linus had the revelations from the Force, to create
a new electron-manipulation-engine that would be so clean
and powerful, that it would thwart Darth Bill's evil plans.
In a fortunate turn of fate, a young Jedi named Larry,
came upon a powerful technique of controlling electron-flow,
Practical Electron Relativistic Levitation,
which would free everyone from the dependency on Darth Bill's
polluting technology forever.
Darth Bill became aware of a planned union between Prince
Linus and the young Jedi Larry, and assembled his forces led
by the dark lord Daryl, to mount a campaign of harrasment
against the Federation.
Master Yoda, who sensed Lord Daryl's imminent attack, sent
a sub-space message to Jedi Larry....."Use the Perl, Larry"
Our story begins.............