Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TK find overlapping

Status
Not open for further replies.

NTKF

Technical User
Jun 1, 2005
1
0
0
US
Please can somebody help me with the follwoing problem.
I have a grid of 20x20 points on a canvas (created by drawing rectanfles on the canvas) and I have a circle on this grid of points. Now I want to highlight the points that are that correspond to the edge of the circle, in a way such that the points could be connected to reconstruct the circle.
Then, two additional circles should be created corresponding to the largest and smallest radius of the highlighted points.

The following is my code but it doesn't seem to work. where the circle is in variable cir, and the grid points are in rectID. PLease can someone help.

set x0 0 ; set y0 0; set x1 10; set y1 10; set idx 0;
for {set j 0} {$j < 400} {incr j 20} {
for {set i 0} {$i < 400} {incr i 20} {
set x2 [ expr $x0 + $i ] ; set x3 [ expr $x1 + $i ]
set y2 [ expr $y0 + $j ] ; set y3 [ expr $y1 + $j ]
set over [ .c find overlapping $x2 $y2 $x3 $y3 ]
lappend over $over
}
}

for {set j 0} {$j < 400} {incr j} {
if {[lsearch [lindex $over $j] $cir]} { .c itemconfigure rect$j -fill blue }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top