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
settexture (Image image [, Number tx, Number ty]) typedict.Graphics
 
Sets foreground to a value (either image or an Array that contains the three arguments), that arranges to use image as the texture for painting on drawable. The optional tx and ty arguments, which should be numbers in the default Yoix coordinate system, translate the texture so the upper left corner of image maps to the point (tx, ty) in the window (or image) that contains drawable. Omitting tx and ty tells the interpreter to try to pick values that map the upper left corner of image to the upper left visible pixel in the window (or image) containing drawable.
 
 Example:   The program,
import yoix.*.*;

Image img = {
    String source = "http://www.yoix.org/imgs/ATTlogo.gif";

    paint(rect) {
        graphics {
            setrgbcolor(1, 0, 0);
            moveto(0, 0);
            rlineto(200, 0);
            moveto(0, 0);
            rlineto(0, 200);
            stroke();
        }
    }
};

JFrame f = {
    Color background = Color.black;

    Graphics graphics = {
        double linewidth = 24;
        double linecap = CAP_ROUND;
    };

    mousePressed(MouseEvent e) {
        graphics {        // "named block"
            if (e.modifiers & BUTTON2_MASK)
                erasedrawable();
            moveto(e.coordinates.x, e.coordinates.y);
        }
    }

    mouseDragged(MouseEvent e) {
        double x = e.coordinates.x;
        double y = e.coordinates.y;

        graphics {        // "named block"
            settexture(img);
            lineto(x, y);
            stroke();
            moveto(x, y);
        }
    }
};

f.visible = TRUE;
defines MouseEvent handlers in a frame that stroke thick lines that track the cursor and are drawn using an image as the foreground. See what happens when you add tx and ty arguments to the settexture call.
 
 Return:   none
 
 See Also:   grestore, grestoreall, gsave, initclip, initgraphics, setcmykcolor, setdash, setfont, setgradient, setgray, sethsbcolor, setlinecap, setlinejoin, setlinewidth, setmiterlimit, setpath, setrgbcolor

 

Yoix is a registered trademark of AT&T Inc.