@Override // from Transform public AffineTransform copy () { return new AffineTransform(m00, m01, m10, m11, tx, ty); }
@Override // from Transform public AffineTransform copy () { return new AffineTransform(m00, m01, m10, m11, tx, ty); }
/** * Returns an initializer that configures a particle with the same transform (scale, rotation, * position) as the supplied layer. This will be the fully computed transform, not the layer's * local transform. */ public static Initializer layer (final Layer layer) { return new Initializer() { @Override public void willInit (int count) { // concatenate the transform of all layers above our target layer xform.setTransform(1, 0, 0, 1, 0, 0); Layer xlayer = layer; while (xlayer != null) { Transforms.multiply(xlayer.transform(), xform, xform); xlayer = xlayer.parent(); } xform.get(_matrix); } @Override public void init (int index, float[] data, int start) { System.arraycopy(_matrix, 0, data, start + ParticleBuffer.M00, 6); } protected final AffineTransform xform = new AffineTransform(); protected final float[] _matrix = new float[6]; }; }
@Override // from Transform public Transform lerp (Transform other, float t) { if (generality() < other.generality()) { return other.lerp(this, -t); // TODO: is this correct? } AffineTransform ot = (other instanceof AffineTransform) ? (AffineTransform)other : new AffineTransform(other); return new AffineTransform( m00 + t*(ot.m00 - m00), m01 + t*(ot.m01 - m01), m10 + t*(ot.m10 - m10), m11 + t*(ot.m11 - m11), tx + t*(ot.tx - tx ), ty + t*(ot.ty - ty )); }
@Override // from Transform public Transform lerp (Transform other, float t) { if (generality() < other.generality()) { return other.lerp(this, -t); // TODO: is this correct? } AffineTransform ot = (other instanceof AffineTransform) ? (AffineTransform)other : new AffineTransform(other); return new AffineTransform( m00 + t*(ot.m00 - m00), m01 + t*(ot.m01 - m01), m10 + t*(ot.m10 - m10), m11 + t*(ot.m11 - m11), tx + t*(ot.tx - tx ), ty + t*(ot.ty - ty )); }
@Override // from Transform public AffineTransform invert () { // compute the determinant, storing the subdeterminants for later use float det = m00*m11 - m10*m01; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible throw new NoninvertibleTransformException(this.toString()); } float rdet = 1f / det; return new AffineTransform( +m11 * rdet, -m10 * rdet, -m01 * rdet, +m00 * rdet, (m10*ty - m11*tx) * rdet, (m01*tx - m00*ty) * rdet); }
@Override // from Transform public AffineTransform invert () { // compute the determinant, storing the subdeterminants for later use float det = m00*m11 - m10*m01; if (Math.abs(det) == 0f) { // determinant is zero; matrix is not invertible throw new NoninvertibleTransformException(this.toString()); } float rdet = 1f / det; return new AffineTransform( +m11 * rdet, -m10 * rdet, -m01 * rdet, +m00 * rdet, (m10*ty - m11*tx) * rdet, (m01*tx - m00*ty) * rdet); }
@Override // from Transform public Transform preConcatenate (Transform other) { if (generality() < other.generality()) { return other.concatenate(this); } if (other instanceof AffineTransform) { return Transforms.multiply((AffineTransform)other, this, new AffineTransform()); } else { AffineTransform oaff = new AffineTransform(other); return Transforms.multiply(oaff, this, oaff); } }
@Override // from Transform public Transform concatenate (Transform other) { if (generality() < other.generality()) { return other.preConcatenate(this); } if (other instanceof AffineTransform) { return Transforms.multiply(this, (AffineTransform)other, new AffineTransform()); } else { AffineTransform oaff = new AffineTransform(other); return Transforms.multiply(this, oaff, oaff); } }
@Override // from Transform public Transform concatenate (Transform other) { if (generality() < other.generality()) { return other.preConcatenate(this); } if (other instanceof AffineTransform) { return Transforms.multiply(this, (AffineTransform)other, new AffineTransform()); } else { AffineTransform oaff = new AffineTransform(other); return Transforms.multiply(this, oaff, oaff); } }
@Override // from Transform public Transform preConcatenate (Transform other) { if (generality() < other.generality()) { return other.concatenate(this); } if (other instanceof AffineTransform) { return Transforms.multiply((AffineTransform)other, this, new AffineTransform()); } else { AffineTransform oaff = new AffineTransform(other); return Transforms.multiply(oaff, this, oaff); } }
/** * Creates a surface which will render to {@code target} using {@code defaultBatch} as its * default quad renderer. */ public Surface (Graphics gfx, RenderTarget target, QuadBatch defaultBatch) { this.target = target; this.batch = defaultBatch; transformStack.add(lastTrans = new AffineTransform()); colorTex = gfx.colorTex(); scale(target.xscale(), target.yscale()); }
/** * Creates a surface which will render to {@code target} using {@code defaultBatch} as its * default quad renderer. */ public Surface (Graphics gfx, RenderTarget target, QuadBatch defaultBatch) { this.target = target; this.batch = defaultBatch; transformStack.add(lastTrans = new AffineTransform()); colorTex = gfx.colorTex(); scale(target.xscale(), target.yscale()); }
/** * 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; }
final AffineTransform af = new AffineTransform(). scale(game.graphics.scale().factor, game.graphics.scale().factor). translate(160, (ygap + 150));