Forums Register Login

Rectangle outcode() not working quite right

+Pie Number of slices to send: Send
I wrote the following to try to capture if the rect is top bottom right left, however it doesnt work right. If I replace the statements eg lets say for top to code==2 || code ==6 || code ==3 it works fine. Any idea what im doing wrong

code = nodeRect.outcode(currentRect.getX(), currentRect.getY());

if(code & Rectangle.OUT_TOP) != 0 ||
(code & (Rectangle.OUT_RIGHT | Rectangle.OUT_TOP)) != 0 ||
(code & (Rectangle.OUT_LEFT | Rectangle.OUT_TOP) ) != 0)
{
//This means the point is above the rectangle
}
else if(code & Rectangle.OUT_BOTTOM) != 0 ||
(code & (Rectangle.OUT_RIGHT | Rectangle.OUT_BOTTOM) ) != 0 ||
(code & (Rectangle.OUT_LEFT | Rectangle.OUT_BOTTOM) ) != 0 )
{
//This means the point is below the rectangle
}
else if(code & Rectangle.OUT_RIGHT) != 0 )
{
//This means the point is to the right of the rectangle
}
else if(code & Rectangle.OUT_LEFT) != 0 )
{
//This means the point is to the left of the rectangle
}
+Pie Number of slices to send: Send
Try something like this

Here's a page in the tutorial that may be helpful
Shift and Logical Operators
Wait for it ... wait .... wait .... NOW! Pafiffle! A perfect tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1489 times.
Similar Threads
How can I keep focus on the component pressed until I pressed other component????
How to DnD JLabels in left Jpanel to right and vice versa??
Why Cannot DnD again after I setToolTipText in JPanel??
Really need help in this program
Why I cannot Move my JLabel after I add SetToolTipText()??
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 00:30:31.