public void vflip() { for (PipAnimateFramePiece piece : pieces) { if (piece instanceof PipAni4AniFramePiece) { piece.dy = -piece.dy; } else { piece.transition = PipImage.vflip(piece.transition); piece.dy = -piece.dy - piece.getHeight(); if (piece.rotate != 0) { int angle = ((piece.rotate % 360) + 360) % 360; piece.rotate = (piece.rotate - angle) + (360 - angle); } } } }
public Rectangle getBounds(int repImg, int src, int tgt, int offx, int offy) { int minx = 0; int miny = 0; int maxx = 0; int maxy = 0; for (int i = 0; i < pieces.size(); i++) { PipAnimateFramePiece piece = pieces.get(i); boolean replace = false; if (piece.getImageID() == repImg && piece.getFrame() == src) { piece.setFrame(tgt); piece.setDx(piece.getDx() + offx); piece.setDy(piece.getDy() + offy); replace = true; } int px = piece.getDx(); int py = piece.getDy(); int pw = piece.getWidth(); int ph = piece.getHeight(); if (px < minx) { minx = px; } if (py < miny) { miny = py; } if (px + pw > maxx) { maxx = px + pw; } if (py + ph > maxy) { maxy = py + ph; } if (replace) { piece.setFrame(src); piece.setDx(piece.getDx() - offx); piece.setDy(piece.getDy() - offy); } } Rectangle rect = new Rectangle(minx, miny, maxx - minx, maxy - miny); if (rect.isEmpty()) { rect = new Rectangle(0, 0, 16, 16); } return rect; }