Aleks <vuje@ifg.uni-hannover.de> wrote:
> .c oval 100 100 100 100 -width 50
> .c find overlapping 95 95 95 95
This looks indeed very fishy at first glance:
It goes as far as (I left out the line-item):
% .c find overlapping 83 83 117 117 --> no hit
% .c find overlapping 82 82 83 83 --> finds it
But it is again explainable:
You've got a circle with a very small radius (0.5)
and to each side of the small circle's outline you
go 25 pixels. The 25 pixels you go to the outside
show the big disc, but those 25 pixels you go towards
the center (and beyond!) actually create an inner
"anti-circle". Due to the algorithms used for
"in/out"-detection, you get a hit only if the
test-region overlaps the parts *between* the outer
circle and the (by 0.5 points smaller) inner anti-circle.
This surely beats most peoples' geometrical imagination :-)
play with this:
pack [canvas .c -width 400 ]
.c create oval 50 50 150 150 -width 50 ;# (100/100 r=50 ri=25 ro=75)
.c create oval 275 75 325 125 -width 100; # (300/100 r=25 ri=-25 ro=75)
.c bind all <Motion> {
.c itemconf all -outline black; puts %x.%y
foreach i [.c find overlapping %x %y %x %y] {.c itemconf $i -outline red}
}
You see a tyre and a disc, but both behave like tyres
for the binding. One has been created as a tyre,
the other is a disc with an invisible but observable
anti-disk round its center.
It is necessary to understand, that "find overlapping" is
not based on the actual drawn pixels, but instead on the
mathematical shape (based on floating-point data).
This may lead to situations, where the drawn pixels do not
show the whole truth, and also, occasionally, floating-
point-inaccuracies may add some more confusion.
Note also, that the binding itself fires based on drawn
pixels, (thus also inside the anti-disk) and if you move the
mouse out of the shapes slowly enough, their shape will turn
back to black, because although the binding fires,
find-overlapping doesn't consider the point as "inside".
PS: for saving some keystrokes during experimenting,
you can also write .c fi o ... since these are
currently unambiguous abbreviations for "find
overlapping", but in production code you should
*never ever* use abbreviations.
PS2: I don't know if there is any alternative to
"overlapping", that would instead work consistent
with the bindings. I fear not. *That* is the bug.
Received on Sat Dec 3 03:28:40 2005