| initmatrix |
() |
typedict.Matrix |
| |
Initializes this matrix to one that describes the default coordinate system,
which has its origin at the upper left corner, positive x to the right,
positive y down, and a resolution of 72 dots per inch,
and returns this matrix to the caller.
The values stored in the
sx,
shx,
tx,
sy,
shy,
and
ty
fields in the read-only matrix
VM.screen.defaultmatrix
match the values that
initmatrix
loads in this matrix.
initmatrix
can occasionally be a convenient alternative to
currentmatrix
and
setmatrix
pair, but there are very important differences so its use should be
carefully thought out.
We do not use
initmatrix
much, despite the fact that our example shows how it can simplify code,
and we recommend you adopt the same philosophy.
| |
| Example: |
The program,
import yoix.*.*;
JFrame f = {
Graphics graphics = {
Color foreground = Color.blue;
int linewidth = 72/8;
int linecap = yoix.graphics.CAP_ROUND;
};
paint(Rectangle rect) {
int n;
graphics { // "named block"
translate(size.width/2, size.height/2);
scale(2, .5);
for (n = 0; n < 12; n++) {
moveto(0, 0);
rlineto(1.5*72, 0);
rotate(30);
}
initmatrix();
stroke();
}
}
};
f.visible = TRUE;
draws the same picture as our
setmatrix
example, but using
initmatrix
meant we were able to eliminate a few lines of code.
| | |
| Return: |
Matrix
| | |
| See Also: |
concat,
concatmatrix,
currentmatrix,
dividematrix,
dtransform,
Graphics,
identmatrix,
idtransform,
invertmatrix,
itransform,
maptopixel,
rotate,
scale,
setmatrix,
shear,
transform,
translate
|
|
Yoix is a registered trademark of AT&T Inc.
|