AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
translate (Number tx, Number ty) typedict.Matrix
 
Changes this matrix so that the origin is shifted tx units horizontally and ty units vertically, and returns this matrix to the caller. The mathematical description of translate says it transforms the point
(x, y)
into
(x + tx, y + ty)
which means the new and old matrices map
(0, 0)
and
(tx, ty)
into the same point.
 
 Example:   The program,
import yoix.*.*;

JFrame f = {
    Color background = Color.black;

    paint(Rectangle rect) {
        graphics {            // "named block"
            gsave();
            arc(0, 0, 72, 0, 360);
            setrgbcolor(1, 0, 0);
            fill();
            translate(size.width/2, size.height/2);
            arc(0, 0, 72, 0, 360);
            setrgbcolor(0, 1, 0);
            fill();
            translate(size.width/2, size.height/2);
            arc(0, 0, 72, 0, 360);
            setrgbcolor(0, 0, 1);
            fill();
            grestore();
         }
    }
};

f.visible = TRUE;
defines a paint function in a frame that uses translate to draw a red circle in the upper left corner, a green circle in the center, and a blue circle in the lower right corner.
 
 Return:   Matrix
 
 See Also:   concat, concatmatrix, currentmatrix, dividematrix, dtransform, Graphics, identmatrix, idtransform, initmatrix, invertmatrix, itransform, maptopixel, rotate, scale, setmatrix, shear, transform

 

Yoix is a registered trademark of AT&T Inc.