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
rectmove (Rectangle rect, double dx, double dx) typedict.Graphics
rectmove (Number x, Number y, Number width, Number height, double dx, double dy)  
 
Copies the pixels contained in rect, or the rectangle that has (x, y) as its upper left corner and width and height as its dimensions, to the rectangle that has its upper left corner translated by dx and dy and then the source rectangle, minus any overlap with the destination, is erased. The arguments are all transformed to device space using CTM and results are used to select the source pixels and the destination rectangle. rectmove makes no use of or changes to the current path.
 
 Example:   The program,
import yoix.*.*;

JFrame f = {
    Array layout = {
        new JCanvas {
            Color background = Color.black;
            int   panandzoom = 0x000400;

            Graphics graphics = {
                String font = "Helvetica-bold-12";
            };

            Rectangle cell = {
                double x = 72;
                double y = 72;
                double width = 72;
                double height = 36;
            };

            Point pressedpoint = NULL;

            paint(rect) {
                Rectangle bounds = NULL;
                double    x;
                double    y;

                bounds = graphics.font.stringbounds("Drag Me");
                x = cell.x + (cell.width - bounds.width)/2;
                y = cell.y + (cell.height - bounds.height)/2 - bounds.y;

                graphics {
                    gsave();
                    setgray(.7);
                    rectbutton(cell, 72.0/32);
                    setrgbcolor(1, 0, 0);
                    moveto(x, y);
                    show("Drag Me");
                    grestore();
                }
            }

            mouseDragged(e) {
                double dx;
                double dy;

                if (pressedpoint) {
                    dx = e.coordinates.x - pressedpoint.x;
                    dy = e.coordinates.y - pressedpoint.y;
                    pressedpoint.x += dx;
                    pressedpoint.y += dy;
                    graphics.rectmove(cell, dx, dy);
                }
            }

            mousePressed(e) {
                if (pointInRect(e.coordinates, cell))
                    pressedpoint = e.coordinates;
            }

            mouseReleased(e) {
                pressedpoint = NULL;
            }
        },
    };
};

f.visible = TRUE;
paints a "raised" rectangle on the canvas using rectbutton, draws some text in that rectangle, and defines event handlers that let you drag it around on the canvas using rectmove. In addition we set panandzoom to enable the mouse wheel zooming.
 
 Return:   none
 
 See Also:   clip, clippath, drawablebbox, eoclip, eoerase, eofill, erase, erasedrawable, fill, ineofill, infill, instroke, rectbutton, rectclip, rectcopy, recterase, rectfill, rectstroke, stroke, strokepath

 

Yoix is a registered trademark of AT&T Inc.