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
copyArea (Object obj, Number x, Number y, Number w, Number h, Number dx, Number dy) yoix.graphics
 
Copies pixels in obj, which must be an Image or a drawable component (i.e., a Swing or AWT component, like a JCanvas, JFrame, or Canvas, that supports a paint function), from the user space rectangle that is w units wide, h units high, and has its upper left corner at the point (x,y) to the corresponding user space rectangle that has its upper left corner at the point (x+dx,y+dy). We use clipping to try to improve the behavior of copyArea in rotated coordinate systems, however clipping support in Java's implementation of copyArea() only appeared in Java 1.6, so versions of Java older than 1.6 will still misbehave.
 
 Example:   The program,
import yoix.*.*;

Image img = {
    String source = "";
    Dimension size = {
        int  height = 72;
        int  width = 2*72;
    };
    Graphics graphics = {
        String font = "Helvetica-plain-12";
        Color  foreground = Color.blue;
    };
    paint(clip) {
        int x = 10;
        int y = graphics.font.ascent; 
        int width = stringWidth(this, "Testing...");
        int height = graphics.font.ascent + graphics.font.descent;

        drawString(this, "Testing", x, y);
        copyArea(this, x, 0, width, height, 10, 2*height);
    }
};

JFrame frame = {
    Image backgroundimage = img;
    int   backgroundhints = SCALE_TILE;
};

frame.visible = TRUE;
sleep(5);
exit(0);
defines a paint function in an image that prints Testing near the image's upper left corner, copies that string to a different part of the image using copyArea, and then the tiles a frame with the image.
 
 See Also:   clearRect, drawArc, drawImage, drawLine, drawOval, drawPolygon, drawPolyline, drawRect, drawRoundRect, drawString, fillArc, fillOval, fillPolygon, fillRect, fillRoundRect, pointInPolygon, pointInRect, rectContainsRect, rectIntersectionRect, rectIntersectsRect, rectUnionRect, stringBounds, stringWidth

 

Yoix is a registered trademark of AT&T Inc.