Я изучаю тк и пытаюсь отладить свой скрипт. Я не уверен, что мне не хватает, чтобы сохранить мое изображение в файл. Спасибо за любую помощь
#!/tool/pandora64/bin/perl5.8.8.a
use Tk;
my ( $size, $step ) = ( 200, 10 );
# Create MainWindow and configure:
my $mw = MainWindow->new;
$mw->configure( -width=>$size, -height=>$size );
$mw->resizable( 0, 0 ); # not resizable in any direction
# Create and configure the canvas:
my $canvas = $mw->Canvas( -cursor=>"crosshair", -background=>"white",
-width=>$size, -height=>$size )->pack;
# Place objects on canvas:
$canvas->createRectangle( $step, $step, $size-$step, $size-$step, -fill=>"red" );
for( my $i=$step; $i<$size-$step; $i+=$step ) {
my $val = 255*$i/$size;
my $color = sprintf( "#%02x%02x%02x", $val, $val, $val );
$canvas->createRectangle( $i, $i, $i+$step, $i+$step, -fill=>$color );
}
$canvas->postscript( -file=>"file_name.ps" );
`convert file_name.ps file_name.jpeg`; # I can move this outside out of the script
exit 0;