in reply to Tk:Canvas - Arc with an arrow?
Many, many thanks for your work on this problem. It was a delight for me to read through your responses first thing this morning!
ELISHEVA, your find-the-end-of-the-arc solution works great, in combination with liverpole's fantastic try-things-out-and-play-with-it-script, and the synergy between the two of you has helped educated me in this area quite a bit. Thanks for going all PerlMonks on this one. It's exactly what I needed.
In the mean time, I continued on with the bunch-o-lines solution, after posting this and came up with the final version attached here.
My guts are telling me that the right solution is to get Tk to add an arrow option on to the end of the canvas arc item (and possibly others). I've run this gauntlet a long time ago to add a Get/Delete Enhancement for Tk Text Widget, so maybe this would be a good long-term solution (opinions?).
In any case, thanks again for all the valuable help!
-Craig
use strict; use warnings; use Tk; my $top = MainWindow->new; my $can = $top->Canvas()->pack(); my @offset = (100, 100); my $PI = atan2(1,1) * 4; my $max = 100; my $radius = 20; my $start=35; my $end=$max-22; # Generate list of line segments... my @coords; foreach my $i (1..$end) { my $radians = ($i+$start)*2*$PI/$max, $radius; my @nextXY = ( $radius * sin($radians), # X-val $radius * cos($radians), # Y-val ); push(@coords, @nextXY); } # Fix things for the arrowhead... $coords[-1] -= 2; # y $coords[-2] += 2; # x # Draw the line (arrowed arc)... my $l = $can->create('line', \@coords, -arrow=>'last'); $can->move($l, @offset); MainLoop;
|
|---|