Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Tk:Canvas - Arc with an arrow?

by cmv (Chaplain)
on Oct 09, 2009 at 15:11 UTC ( #800307=note: print w/ replies, xml ) Need Help??


in reply to Tk:Canvas - Arc with an arrow?

ELISHEVA++ liverpole++

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;


Comment on Re: Tk:Canvas - Arc with an arrow?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://800307]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (13)
As of 2014-07-29 18:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (226 votes), past polls