#!/usr/bin/perl -w use strict; use constant WIDTH => 1000; use constant HEIGHT => 100; use constant SPEED => 1; use Cairo; use Glib qw(TRUE FALSE); use Gtk2 -init; use Gtk2::Pango; my ($text,$ticks, $cr, $layout, $desc, $area); sub initialize { $cr = Gtk2::Gdk::Cairo::Context -> create($area->window()); $layout = Gtk2::Pango::Cairo::create_layout($cr); $desc = Gtk2::Pango::FontDescription -> from_string("Sans Bold 57"); $layout -> set_font_description($desc); $layout->set_alignment("PANGO_ALIGN_LEFT"); } sub draw_text { $cr->push_group; $layout->set_text($text); Gtk2::Pango::Cairo::update_layout($cr, $layout); my @size = $layout->get_pixel_size; $cr -> translate(-($ticks*SPEED)%$size[0],0); $cr->set_source_rgb(1.0,1.0,1.0); $cr->fill(); $cr -> set_source_rgb(0.0,0.0,0.0); my $count = int(WIDTH/$size[0]); $cr->translate(-$size[0]*2,0); for(my $i = 0; $i<=$count+1; $i++){ $cr->translate($size[0],0); Gtk2::Pango::Cairo::show_layout($cr,$layout); } $cr->pop_group_to_source; $cr->paint; } my $window = Gtk2::Window->new(); $window -> signal_connect(delete_event => sub { Gtk2 -> main_quit(); }); $area = Gtk2::DrawingArea -> new(); sub draw { $cr->rectangle(0,0,WIDTH,HEIGHT); draw_text($cr,$ticks); } sub timer { $ticks ++; draw(); return 1; } $text = 'Please specify your input file'; if($ARGV[0]){ open(INPUT_FILE, "$ARGV[0]"); $text = ; } $ticks = 0; $window -> set_default_size(WIDTH,HEIGHT); $window -> add($area); $window->show_all(); initialize; my $timer = Glib::Timeout->add(1000/60, \&timer ,'',); Gtk2->main();