/** Adds a transformed axis-aligned quad to this batch. * {@code left, top, right, bottom} define the bounds of the quad. * {@code sl, st, sr, sb} define the texture coordinates. */ public void addQuad (int tint, AffineTransform xf, float left, float top, float right, float bottom, float sl, float st, float sr, float sb) { addQuad(tint, xf.m00, xf.m01, xf.m10, xf.m11, xf.tx, xf.ty, left, top, right, bottom, sl, st, sr, sb); }
/** Adds a transformed axis-aligned quad to this batch. * {@code m00, m01, m10, m11, tx, ty} define the affine transform applied to the quad. * {@code left, top, right, bottom} define the bounds of the quad. * {@code sl, st, sr, sb} define the texture coordinates. */ public void addQuad (int tint, float m00, float m01, float m10, float m11, float tx, float ty, float left, float top, float right, float bottom, float sl, float st, float sr, float sb) { addQuad(tint, m00, m01, m10, m11, tx, ty, left, top, sl, st, right, top, sr, st, left, bottom, sl, sb, right, bottom, sr, sb); }
@Override public void addToBatch (QuadBatch batch, int tint, AffineTransform tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { batch.addQuad(this, tint, tx, dx, dy, dw, dh, sx, sy, sw, sh); }
@Override public void addToBatch (QuadBatch batch, int tint, AffineTransform tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { batch.addQuad(this, tint, tx, dx, dy, dw, dh, sx, sy, sw, sh); }
/** Adds a transformed axis-aligned quad to this batch. * {@code left, top, right, bottom} define the bounds of the quad. * {@code sl, st, sr, sb} define the texture coordinates. */ public void addQuad (int tint, AffineTransform xf, float left, float top, float right, float bottom, float sl, float st, float sr, float sb) { addQuad(tint, xf.m00, xf.m01, xf.m10, xf.m11, xf.tx, xf.ty, left, top, right, bottom, sl, st, sr, sb); }
/** Adds a transformed axis-aligned quad to this batch. * {@code m00, m01, m10, m11, tx, ty} define the affine transform applied to the quad. * {@code left, top, right, bottom} define the bounds of the quad. * {@code sl, st, sr, sb} define the texture coordinates. */ public void addQuad (int tint, float m00, float m01, float m10, float m11, float tx, float ty, float left, float top, float right, float bottom, float sl, float st, float sr, float sb) { addQuad(tint, m00, m01, m10, m11, tx, ty, left, top, sl, st, right, top, sr, st, left, bottom, sl, sb, right, bottom, sr, sb); }
/** Adds {@code tex} as a transformed axis-aligned quad to this batch. * {@code dx, dy, dw, dh} define the size and position of the quad. * {@code sx, sy, sw, sh} define region of the texture which will be displayed in the quad. */ public void addQuad (Texture tex, int tint, AffineTransform xf, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { setTexture(tex); float texWidth = tex.displayWidth, texHeight = tex.displayHeight; addQuad(tint, xf, dx, dy, dx+dw, dy+dh, sx/texWidth, sy/texHeight, (sx+sw)/texWidth, (sy+sh)/texHeight); }
/** Adds {@code tex} as a transformed axis-aligned quad to this batch. * {@code dx, dy, dw, dh} define the size and position of the quad. * {@code sx, sy, sw, sh} define region of the texture which will be displayed in the quad. */ public void addQuad (Texture tex, int tint, AffineTransform xf, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { setTexture(tex); float texWidth = tex.displayWidth, texHeight = tex.displayHeight; addQuad(tint, xf, dx, dy, dx+dw, dy+dh, sx/texWidth, sy/texHeight, (sx+sw)/texWidth, (sy+sh)/texHeight); }
@Override public void addToBatch (QuadBatch batch, int tint, AffineTransform tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { batch.addQuad(texture(), tint, tx, dx, dy, dw, dh, tileX+sx, tileY+sy, sw, sh); } };
@Override public void addToBatch (QuadBatch batch, int tint, AffineTransform tx, float dx, float dy, float dw, float dh, float sx, float sy, float sw, float sh) { batch.addQuad(texture(), tint, tx, dx, dy, dw, dh, tileX+sx, tileY+sy, sw, sh); } };
/** Adds {@code tex} as a transformed axis-aligned quad to this batch. * {@code x, y, w, h} define the size and position of the quad. */ public void addQuad (Texture tex, int tint, AffineTransform xf, float x, float y, float w, float h) { setTexture(tex); float sr = tex.config.repeatX ? w/tex.displayWidth : 1; float sb = tex.config.repeatY ? h/tex.displayHeight : 1; addQuad(tint, xf, x, y, x+w, y+h, 0, 0, sr, sb); }
/** Adds {@code tex} as a transformed axis-aligned quad to this batch. * {@code x, y, w, h} define the size and position of the quad. */ public void addQuad (Texture tex, int tint, AffineTransform xf, float x, float y, float w, float h) { setTexture(tex); float sr = tex.config.repeatX ? w/tex.displayWidth : 1; float sb = tex.config.repeatY ? h/tex.displayHeight : 1; addQuad(tint, xf, x, y, x+w, y+h, 0, 0, sr, sb); }
/** * 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; }
/** * Fills a line between the specified coordinates, of the specified display unit width. */ public Surface drawLine (float x0, float y0, float x1, float y1, float width) { // swap the line end points if x1 is less than x0 if (x1 < x0) { float temp = x0; x0 = x1; x1 = temp; temp = y0; y0 = y1; y1 = temp; } float dx = x1 - x0, dy = y1 - y0; float length = FloatMath.sqrt(dx * dx + dy * dy); float wx = dx * (width / 2) / length; float wy = dy * (width / 2) / length; AffineTransform xf = new AffineTransform(); xf.setRotation(FloatMath.atan2(dy, dx)); xf.setTranslation(x0 + wy, y0 - wx); Transforms.multiply(tx(), xf, xf); if (patternTex != null) { batch.addQuad(patternTex, tint, xf, 0, 0, length, width); } else { batch.addQuad(colorTex, Tint.combine(fillColor, tint), xf, 0, 0, length, width); } return this; }
/** * Fills a line between the specified coordinates, of the specified display unit width. */ public Surface drawLine (float x0, float y0, float x1, float y1, float width) { // swap the line end points if x1 is less than x0 if (x1 < x0) { float temp = x0; x0 = x1; x1 = temp; temp = y0; y0 = y1; y1 = temp; } float dx = x1 - x0, dy = y1 - y0; float length = FloatMath.sqrt(dx * dx + dy * dy); float wx = dx * (width / 2) / length; float wy = dy * (width / 2) / length; AffineTransform xf = new AffineTransform(); xf.setRotation(FloatMath.atan2(dy, dx)); xf.setTranslation(x0 + wy, y0 - wx); Transforms.multiply(tx(), xf, xf); if (patternTex != null) { batch.addQuad(patternTex, tint, xf, 0, 0, length, width); } else { batch.addQuad(colorTex, Tint.combine(fillColor, tint), xf, 0, 0, length, width); } return this; }