| rectclip |
(Rectangle rect [, int clear [, int subtract]]) |
typedict.Graphics |
| rectclip |
(Number x, Number y, Number width, Number height [, int clear [, int subtract]]) |
|
| |
Transforms
rect,
or the rectangle that has
(x, y)
as its upper left corner and
width
and
height
as its dimensions, using
CTM,
intersects the resulting path with the current clipping path,
and installs that intersection as the new clipping path.
If the optional
subtract
argument is non-zero
rectclip
uses subtraction rather than intersection to create the new clipping path.
By default
rectclip
makes no use of or changes to the current
path,
unless the optional
clear
argument is non-zero, which means the current
path
will be cleared after the new clipping path is created.
The default clipping path associated with every
drawable
is always the smallest rectanglar path that covers
drawable,
which means it changes when
drawable
is resized.
rectclip
is particularly useful when
drawable
defines a paint function, because the rectangle that needs repainting
is passed to that function.
| |
| Example: |
The program,
import yoix.*.*;
JFrame f = {
Color background = Color.white;
paint(Rectangle r) {
graphics { // "named block"
gsave();
linewidth = 9;
rectclip(r);
setrgbcolor(0, 0, 1);
rectfill(72, 72, 144, 72, .4); // alpha
setrgbcolor(1, 0, 0);
rectstroke(72, 72, 144, 72, .2); // alpha
grestore();
}
}
};
f.visible = TRUE;
defines a paint function in a frame that uses
rectclip
to set an appropriate clipping path before a small rectangle is filled
and stroked using
rectfill
and
rectstroke.
This is a short example, but there is lots you can learn,
so we encourage you to experiment with it.
For example, do you understand why we used
gsave
and
grestore,
or can you explain what happens if
rectclip
is removed and you cover and then uncover part of the rectangle?
| | |
| Return: |
none
| | |
| See Also: |
clip,
clippath,
drawablebbox,
eoclip,
eoerase,
eofill,
erase,
erasedrawable,
fill,
ineofill,
infill,
instroke,
rectbutton,
rectcopy,
recterase,
rectfill,
rectmove,
rectstroke,
stroke,
strokepath
|
|
Yoix is a registered trademark of AT&T Inc.
|
|