#!/afs/athena/contrib/perl/perl

do "./xbase.perl";

&xlib'x_open_display($ENV{'DISPLAY'});
&xlib'x_clear_area($xlib'root_window, 0, 0, 0, $xlib'rootw, $xlib'rooth);
$mygc = &xlib'x_create_gc($xlib'root_window,$xlib'defines{'GCForeground'} 
| $xlib'defines{'GCBackground'}, $xlib'root_black, $xlib'root_white);

$xstart = ($xlib'rootw)/2 + 100;
$ystart = ($xlib'rooth)/2 +100;
$xend = $xstart + 200;
$yend = $ystart +200;
$co = 8;
while(1){
    &drawline($co, $xstart, $ystart, $xend, $yend);
    $xstart += (rand(50))-25;
    $ystart += (rand(50))-25;
    $xend += (rand(50))-25;
    $yend += (rand(50))-25;
    $co += (rand(2)-1);
    if($xstart < 0){$xstart += 50;}
    if($xstart > $xlib'rootw){$xstart -= 50;}
    if($xend < 0){$xend += 50;}
    if($xend > $xlib'rooth){$xend -= 50;}
    if($ystart < 0){$ystart += 50;}
    if($ystart > $xlib'rooth){$ystart -= 50;}
    if($yend < 0){$yend += 50;}
    if($yend > $xlib'rooth){$yend -= 50;}
    if($co < 0){$co = $co +10;}
    if($co > 20){$co = $co -10;}

}
sub drawline {
    local($color, $x, $y, $nx, $ny) = @_;
    $mygc = &xlib'x_create_gc($xlib'root_window,$xlib'defines{'GCForeground'} 
| $xlib'defines{'GCBackground'}, $color, $xlib'root_white);
&xlib'x_line($xlib'root_window, $mygc, 0, $x, $y, $nx, $ny);
}
