e596. scaling, shearing, translating, and rotating a drawn image.txt

来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 24 行

TXT
24
字号
See also e575 The Quintessential Drawing Program and e594 Reading an Image or Icon from a File. 
    public void paint(Graphics g) {
        Graphics2D g2d = (Graphics2D) g;
        AffineTransform tx = new AffineTransform();
    
        double scalex = .5;
        double scaley = 1;
        tx.scale(scalex, scaley);
    
        double shiftx = .1;
        double shifty = .3;
        tx.shear(shiftx, shifty);
    
        double x = 50;
        double y = 50;
        tx.translate(x, y);
    
        double radians = -Math.PI/4;
        tx.rotate(radians);
    
        g2d.drawImage(image, tx, this);
    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?