| pointInRect |
(Point p, Number x, Number y, Number w, Number h) |
yoix.graphics |
| |
Returns
1
if
p
lies inside the rectangle that is
w
units wide,
h
units high, and has its upper left corner at the point
(x,y).
| |
| Example: |
The program,
import yoix.*.*;
JFrame frame = {
Array layout = {
new JCanvas {
Color background = Color.black;
Graphics graphics = {
Color foreground = Color.yellow;
};
paint(clip) {
fillRect(this, 72, 2*72, 3*72, 72.0/4);
}
mousePressed(e) {
int result;
result = pointInRect(e.location, 72, 2*72, 3*72, 72.0/4);
puts(result ? "inside" : "outside");
}
},
};
};
frame.visible = TRUE;
sleep(5);
exit(0);
defines a paint function in a canvas that draws a red rectangle
3 inches wide and 1/4 inch high that is placed
1 inch from the left and 2 inches from the top of the canvas.
The canvas also defines a
mousePressed
event handler that uses
pointInRect
to report whether the cursor was inside or outside the rectangle when
the button was pressed.
| | |
| See Also: |
clearRect,
copyArea,
drawArc,
drawImage,
drawLine,
drawOval,
drawPolygon,
drawPolyline,
drawRect,
drawRoundRect,
drawString,
fillArc,
fillOval,
fillPolygon,
fillRect,
fillRoundRect,
pointInPolygon,
rectContainsRect,
rectIntersectionRect,
rectIntersectsRect,
rectUnionRect,
stringBounds,
stringWidth
|
|
Yoix is a registered trademark of AT&T Inc.
|