/** Translates the current transformation matrix by the given amount. */ public Surface translate (float x, float y) { tx().translate(x, y); return this; }
/** Multiplies the current transformation matrix by the given matrix. */ public Surface transform (float m00, float m01, float m10, float m11, float tx, float ty) { AffineTransform top = tx(); Transforms.multiply(top, m00, m01, m10, m11, tx, ty, top); return this; }
/** * Pre-concatenates {@code xf} onto this surface's transform. */ public Surface preConcatenate (AffineTransform xf) { AffineTransform txf = tx(); Transforms.multiply(xf.m00, xf.m01, xf.m10, xf.m11, xf.tx, xf.ty, txf, txf); return this; }
/** Scales the current transformation matrix by the specified amount on each axis. */ public Surface scale (float sx, float sy) { tx().scale(sx, sy); return this; }
/** Translates the current transformation matrix by the given amount. */ public Surface translate (float x, float y) { tx().translate(x, y); return this; }
/** Multiplies the current transformation matrix by the given matrix. */ public Surface transform (float m00, float m01, float m10, float m11, float tx, float ty) { AffineTransform top = tx(); Transforms.multiply(top, m00, m01, m10, m11, tx, ty, top); return this; }
/** * Pre-concatenates {@code xf} onto this surface's transform. */ public Surface preConcatenate (AffineTransform xf) { AffineTransform txf = tx(); Transforms.multiply(xf.m00, xf.m01, xf.m10, xf.m11, xf.tx, xf.ty, txf, txf); return this; }
@Override protected void paintClipped (Surface surf) { // save our current transform and restore it before painting each child paintTx.set(surf.tx()); // iterate manually to avoid creating an Iterator as garbage, this is inner-loop territory List<Layer> children = this.children; Layer.paintNestLevel += 1; for (int ii = 0, ll = children.size(); ii < ll; ii++) { surf.tx().set(paintTx); children.get(ii).paint(surf); } Layer.paintNestLevel -= 1; }
/** * Fills the specified rectangle. */ public Surface fillRect (float x, float y, float width, float height) { if (patternTex != null) { batch.addQuad(patternTex, tint, tx(), x, y, width, height); } else { batch.addQuad(colorTex, Tint.combine(fillColor, tint), tx(), x, y, width, height); } return this; }
/** * Fills the specified rectangle. */ public Surface fillRect (float x, float y, float width, float height) { if (patternTex != null) { batch.addQuad(patternTex, tint, tx(), x, y, width, height); } else { batch.addQuad(colorTex, Tint.combine(fillColor, tint), tx(), x, y, width, height); } return this; }
/** * Draws a tile at the specified location {@code (x, y)} and size {@code (w x h)}, with tint * {@code tint}. <em>Note:</em> this will override any tint and alpha currently configured on * this surface. */ public Surface draw (Tile tile, int tint, float x, float y, float w, float h) { if (!checkIntersection || intersects(x, y, w, h)) { tile.addToBatch(batch, tint, tx(), x, y, w, h); } return this; }
/** * Draws a scaled subset of an image (defined by {@code (sx, sy)} and {@code (w x h)}) at the * specified location {@code (dx, dy)} and size {@code (dw x dh)}, with tint {@code tint}. * <em>Note:</em> this will override any tint and alpha currently configured on this surface. */ public Surface draw (Tile tile, int tint, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { if (!checkIntersection || intersects(dx, dy, dw, dh)) { tile.addToBatch(batch, tint, tx(), dx, dy, dw, dh, sx, sy, sw, sh); } return this; }
/** * Draws a scaled subset of an image (defined by {@code (sx, sy)} and {@code (w x h)}) at the * specified location {@code (dx, dy)} and size {@code (dw x dh)}, with tint {@code tint}. * <em>Note:</em> this will override any tint and alpha currently configured on this surface. */ public Surface draw (Tile tile, int tint, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { if (!checkIntersection || intersects(dx, dy, dw, dh)) { tile.addToBatch(batch, tint, tx(), dx, dy, dw, dh, sx, sy, sw, sh); } return this; }
/** * Concatenates {@code xf} onto this surface's transform, accounting for the {@code origin}. */ public Surface concatenate (AffineTransform xf, float originX, float originY) { AffineTransform txf = tx(); Transforms.multiply(txf, xf.m00, xf.m01, xf.m10, xf.m11, xf.tx, xf.ty, txf); if (originX != 0 || originY != 0) txf.translate(-originX, -originY); return this; }
/** * Draws a tile at the specified location {@code (x, y)} and size {@code (w x h)}. */ public Surface draw (Tile tile, float x, float y, float w, float h) { if (!checkIntersection || intersects(x, y, w, h)) { tile.addToBatch(batch, tint, tx(), x, y, w, h); } return this; }
/** * Concatenates {@code xf} onto this surface's transform, accounting for the {@code origin}. */ public Surface concatenate (AffineTransform xf, float originX, float originY) { AffineTransform txf = tx(); Transforms.multiply(txf, xf.m00, xf.m01, xf.m10, xf.m11, xf.tx, xf.ty, txf); if (originX != 0 || originY != 0) txf.translate(-originX, -originY); return this; }
/** * Draws a scaled subset of an image (defined by {@code (sx, sy)} and {@code (w x h)}) at the * specified location {@code (dx, dy)} and size {@code (dw x dh)}. */ public Surface draw (Tile tile, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { if (!checkIntersection || intersects(dx, dy, dw, dh)) { tile.addToBatch(batch, tint, tx(), dx, dy, dw, dh, sx, sy, sw, sh); } return this; }
/** * Draws a tile at the specified location {@code (x, y)} and size {@code (w x h)}, with tint * {@code tint}. <em>Note:</em> this will override any tint and alpha currently configured on * this surface. */ public Surface draw (Tile tile, int tint, float x, float y, float w, float h) { if (!checkIntersection || intersects(x, y, w, h)) { tile.addToBatch(batch, tint, tx(), x, y, w, h); } return this; }
/** * Draws a tile at the specified location {@code (x, y)} and size {@code (w x h)}. */ public Surface draw (Tile tile, float x, float y, float w, float h) { if (!checkIntersection || intersects(x, y, w, h)) { tile.addToBatch(batch, tint, tx(), x, y, w, h); } return this; }
/** Returns whether the given rectangle intersects the render target area of this surface. */ public boolean intersects (float x, float y, float w, float h) { tx().transform(intersectionTestPoint.set(x, y), intersectionTestPoint); tx().transform(intersectionTestSize.set(w, h), intersectionTestSize); float ix = intersectionTestPoint.x, iy = intersectionTestPoint.y; float iw = intersectionTestSize.x, ih = intersectionTestSize.y; if (scissorDepth > 0) { Rectangle scissor = scissors.get(scissorDepth - 1); return scissor.intersects((int)ix, (int)iy, (int)iw, (int)ih); } float tw = target.width(), th = target.height(); return (ix + iw > 0) && (ix < tw) && (iy + ih > 0) && (iy < th); }