In einer Tk::Canvas kann man alles Mögliche darstellen, z.B. Linien, Rechtecke, Polygone, Bögen, Fotos, Widgets, Text usw.
Tk::RotCanvas bietet Funktionen an, um diese Objekte auch zu drehen. Allerdings nur für Objekte des Typs Linie, Rechteck, Polygon und Oval. Die Tk::Canvas allein kann das nicht (siehe Abschnitt TRANSFORMATIONS).
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::RotCanvas;
my $mw = tkinit();
my $canvas = $mw->RotCanvas(-bg => 'white')->pack(-fill => 'both', -expand => 1);
my $rect = $canvas->createRectangle(30,30, 130,130, -fill => 'green');
my $angle = 45;
$canvas->rotate($rect, $angle);
$mw->MainLoop;
exit(0);
#!/usr/bin/perl
use strict;
use warnings;
use Tk;
use Tk::RotCanvas;
my $mw = tkinit();
my $canvas = $mw->RotCanvas(-bg => 'white')->pack(-fill => 'both', -expand => 1);
$canvas->createRectangle(10,200, 30,220, -fill => 'red');
$canvas->createRectangle(100,20, 120,40, -fill => 'blue');
$canvas->createRectangle(300,200, 320,220, -fill => 'yellow');
my @coords = (10,200, 100,20, 300,200);
my %options = (-fill => 'orange');
my $obj = $canvas->createPolygon(@coords, %options);
my %options2rotate = (-fill => 'red');
my $obj2rotate = $canvas->createPolygon(@coords, %options2rotate);
my $angle = 45;
$canvas->rotate($obj2rotate, $angle);
$mw->MainLoop;
exit(0);