KuntalBhusan has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
The Tk::Abstract canvas manual page in CPAN says of a method :
$acnv->rotate(TagOrID, angle ?,x, y?) This method rotates the object identified by TagOrID by angle. The ang +le is specified in degrees. If an x, y coordinate is specified, then +the object is rotated about that point. Otherwise, the object is rota +ted about its center point, if that can be determined.
and also mentions later that :
As it stands, the module can only rotate the following object types ab +out their centers: Lines Polygons Rectangles (if rectToPoly(1) is called) Ovals (if ovalToPoly(1) is called) All other object types (bitmap, image, arc, text, && window) can only +be rotated about another point. A warning is issued if the user tries + to rotate one of these object types about their center. Hopefully, m +ore types will be able to center-rotate in the future.
This means that it is able to rotate texts...
when I tried to do the same using the code below, my text is not rotated...
use Tk; use Tk::AbstractCanvas; my $mw=MainWindow->new(-title=>'RotateText-Test'); my $w = $mw->screenwidth; my $h = $mw->screenheight; $mw->geometry( $w."x".$h); $mw->resizable(1,1); my $canvas = $mw->Scrolled('AbstractCanvas', -background => "white", -scrollbars => "osoe", -height => 0, -relief => "solid", -width => 0, -scrollregion=>[0,0,1,1], )->pack(-anchor=>'nw', -side=>'top', -fill=>'both', -expand=>1); my $text = $canvas->createText(0,0,-anchor=>'center',-fill => 'red',-t +ext => 'Hello Monks !!!',); #my $text = $canvas->createText(2,10,-anchor=>'center',-fill => 'red', +width => 1,-text => 'Hello Monks !!!',); ## this rotates but not the +characters :( $canvas->rotate($text,90,$x,$y); $canvas->viewAll(); MainLoop; ();
seeking the Monks help..
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: How to rotate text in Tk::Abstract Canvas ?
by kcott (Archbishop) on May 09, 2013 at 21:02 UTC | |
by KuntalBhusan (Acolyte) on May 10, 2013 at 04:51 UTC |
Back to
Seekers of Perl Wisdom