| gsave |
([String tag]) |
typedict.Graphics |
| |
|
Saves the current graphics state and returns the number
of states that are currently saved.
All changes made to the graphics state following
gsave
are undone by
grestore.
The optional
tag
argument is an arbitrary string associated with the values saved by
gsave
that can be handed to
grestore
to restore the tagged values.
Even though
gsave
and
grestore
affect the entire graphics state, they are reasonably efficient and
are often used to preserve one value, like the current path.
For example, path rendering built-ins often clear the current path,
so surrounding a
fill
or
stroke
call by
gsave
and
grestore
is an easy way to preserve the path.
| |
| Example: |
The program,
import yoix.*.*;
JFrame f = {
Color background = Color.white;
paint(Rectangle r) {
graphics { // "named block"
gsave();
rectclip(r);
translate(72, 72);
moveto(0, 0);
rlineto(144, 0);
rlineto(0, 72);
closepath();
gsave();
setcmykcolor(1, 0, 0);
fill();
grestore();
setcmykcolor(0, 1, 0);
stroke();
grestore();
}
}
};
f.visible = TRUE;
defines a paint function in a frame that fills a cyan triangle
and then draws the outline of that triangle in magenta.
| | |
| Return: |
int
| | |
| See Also: |
grestore,
grestoreall,
initclip,
initgraphics,
setcmykcolor,
setdash,
setfont,
setgradient,
setgray,
sethsbcolor,
setlinecap,
setlinejoin,
setlinewidth,
setmiterlimit,
setpath,
setrgbcolor,
settexture
|
|
Yoix is a registered trademark of AT&T Inc.
|