I'm not sure what types of binding you want to make, do you want to bind all of them to <1>?
I think you are overlooking "tags", but there are a few ways to do it. The array method is ok, but you would be better off using a hash.
There are many different ways to do it, depending on whether
you need separate callbacks for each ball or not.
untested( but close to correct) :-)
# first way with tags, all outer balls will be bound
# to same callback
my $refitem = $zinc->add('arc',$centergroup2, [ [10,20], [20,30] ],
-filled => 1,
-fillcolor => $refgrad, ## $refgrad
-linewidth => 0,
-priority => 100
-tags => ['outerring'],
);
# make/clone 11/12 more of the above
for (1..11){
my $relement = $zinc->clone($refitem);
$zinc->rotate($relement,.53*$_);
}
$zinc->bind( 'outerring', '<1>', \&ro6);
Now you can also do it to bind each outerring ball to a separate callback.
my %refitems;
my $refitem = $zinc->add('arc',$centergroup2, [ [10,20], [20,30] ],
-filled => 1,
-fillcolor => $refgrad, ## $refgrad
-linewidth => 0,
-priority => 100
);
# make/clone 11/12 more of the above
for (1..11){
$refitem{$_} = $zinc->clone($refitem);
$zinc->rotate($refitem{$_},.53*$_);
#here you bind each one separately, and/or
#pass extra info to the callback
$zinc->bind( $refitem{$_}, '<1>', [ \&ro6, $_ ] ) ;
}
As you can see, there are more than one way to do it.
You can even assign the hash element as a tag, although
it is a bit redundant; however it allows you to search for items
thru the tag mechanism. I include it just to reinforce the idea that you can throw anything into the item's tags.
my $refitem = $zinc->add('arc',$centergroup2, [ [10,20], [20,30] ],
-filled => 1,
-fillcolor => $refgrad, ## $refgrad
-linewidth => 0,
-priority => 100
-tags => ['outerring'],
);
my %refitems;
# make/clone 11/12 more of the above
for (1..11){
$refitem{$_} = $zinc->clone($refitem);
$zinc->addtag($refitem{$_}, $refitem{$_});
$zinc->rotate($refitem{$_},.53*$_);
#here you bind each one separately, and/or
#pass extra info to the callback
$zinc->bind( $refitem{$_}, '<1>', [ \&ro6, $_ ] ) ;
}
Anyways, those are some ideas to explore. When you have more than 1 item, that you want to bind to the same callback, you can use tags, or pass an extra arg to the bind callback, to identify which ball called it.
I'm not really a human, but I play one on earth.
flash japh
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.