/** Set the batch's transformation matrix, often with the result of {@link #computeTransform()}. Note this causes the batch to * be flushed. {@link #resetTransform(Batch)} will restore the transform to what it was before this call. */ protected void applyTransform (Batch batch, Matrix4 transform) { oldTransform.set(batch.getTransformMatrix()); batch.setTransformMatrix(transform); }
/** Set the batch's transformation matrix, often with the result of {@link #computeTransform()}. Note this causes the batch to * be flushed. {@link #resetTransform(Batch)} will restore the transform to what it was before this call. */ protected void applyTransform (Batch batch, Matrix4 transform) { oldTransform.set(batch.getTransformMatrix()); batch.setTransformMatrix(transform); }
/** Calculates window scissor coordinates from local coordinates using the batch's current transformation matrix. * @see ScissorStack#calculateScissors(Camera, float, float, float, float, Matrix4, Rectangle, Rectangle) */ public void calculateScissors (Rectangle localRect, Rectangle scissorRect) { Matrix4 transformMatrix; if (debugShapes != null && debugShapes.isDrawing()) transformMatrix = debugShapes.getTransformMatrix(); else transformMatrix = batch.getTransformMatrix(); viewport.calculateScissors(transformMatrix, localRect, scissorRect); }
/** Calculates window scissor coordinates from local coordinates using the batch's current transformation matrix. * @see ScissorStack#calculateScissors(Camera, float, float, float, float, Matrix4, Rectangle, Rectangle) */ public void calculateScissors (Rectangle localRect, Rectangle scissorRect) { Matrix4 transformMatrix; if (debugShapes != null && debugShapes.isDrawing()) transformMatrix = debugShapes.getTransformMatrix(); else transformMatrix = batch.getTransformMatrix(); viewport.calculateScissors(transformMatrix, localRect, scissorRect); }
public void draw (Batch batch, float parentAlpha) { // Use Stage#toScreenCoordinates, which we know is correct. toScreenCoordinates.set(testX, testY).sub(getOriginX(), getOriginY()).scl(getScaleX(), getScaleY()).rotate(getRotation()) .add(getOriginX(), getOriginY()).add(getX(), getY()); getStage().toScreenCoordinates(toScreenCoordinates, batch.getTransformMatrix()); // Do the same as toScreenCoordinates via Actor#localToParentCoordinates. localToAscendantCoordinates(null, localToParentCoordinates.set(testX, testY)); getStage().stageToScreenCoordinates(localToParentCoordinates); // System.out.println(name + " " + toScreenCoordinates + " " + localToParentCoordinates); batch.setColor(getColor()); batch.draw(region, getX(), getY(), getOriginX(), getOriginY(), getWidth(), getHeight(), getScaleX(), getScaleY(), getRotation()); super.draw(batch, parentAlpha); } }
/** Set the batch's transformation matrix, often with the result of {@link #computeTransform()}. Note this causes the batch to * be flushed. {@link #resetTransform(Batch)} will restore the transform to what it was before this call. */ protected void applyTransform (Batch batch, Matrix4 transform) { oldTransform.set(batch.getTransformMatrix()); batch.setTransformMatrix(transform); }
/** Calculates window scissor coordinates from local coordinates using the batch's current transformation matrix. * @see ScissorStack#calculateScissors(Camera, float, float, float, float, Matrix4, Rectangle, Rectangle) */ public void calculateScissors (Rectangle localRect, Rectangle scissorRect) { viewport.calculateScissors(batch.getTransformMatrix(), localRect, scissorRect); Matrix4 transformMatrix; if (debugShapes != null && debugShapes.isDrawing()) transformMatrix = debugShapes.getTransformMatrix(); else transformMatrix = batch.getTransformMatrix(); viewport.calculateScissors(transformMatrix, localRect, scissorRect); }
@Override public void draw(Batch batch) { dead = true; // assume we're death final Vector3 translation = batch.getTransformMatrix().getTranslation(new Vector3()); for (int i = shards.length; i-- != 0; ) { shards[i].draw(batch, Gdx.graphics.getDeltaTime()); dead &= translation.y + shards[i].pos.y + shards[i].size < 0; // all must be dead } }
public void draw(final Batch batch) { batch.setTransformMatrix(batch.getTransformMatrix().translate(pos.x, pos.y, 0)); for (int i = 0; i < cellCount; ++i) for (int j = 0; j < cellCount; ++j) cells[i][j].draw(batch); for (int i = effects.size; i-- != 0; ) { effects.get(i).draw(batch); if (effects.get(i).isDone()) effects.removeIndex(i); } batch.setTransformMatrix(batch.getTransformMatrix().translate(-pos.x, -pos.y, 0)); }
@Override public void draw(Batch batch) { final float dt = Gdx.graphics.getDeltaTime(); fallSpeed += fallAcceleration * dt; pos.y -= fallSpeed * dt; cellColor.set( cellColor.r, cellColor.g, cellColor.b, Math.max(cellColor.a - COLOR_SPEED * dt, 0.0f) ); dropColor.set( cellColor.r, cellColor.g, cellColor.b, Math.min(dropColor.a + COLOR_SPEED * dt, 1.0f) ); Cell.draw(cellColor, batch, pos.x, pos.y, cellSize); Cell.draw(dropTexture, dropColor, batch, pos.x, pos.y, cellSize); final Vector3 translation = batch.getTransformMatrix().getTranslation(new Vector3()); dead = translation.y + pos.y + dropTexture.getHeight() < 0; }
public Batch batchBegin() { Batch batch = super.getBatch(); batch.begin(); batch.setColor(Color.WHITE); oldTransform.set(batch.getTransformMatrix()); batch.setTransformMatrix(computeTransform()); return batch; }
@Override public void draw(Batch batch) { age += Gdx.graphics.getDeltaTime(); final float progress = age * INV_LIFETIME; final float currentSize = Interpolation.pow2In.apply(size, 0, progress); final float currentRotation = Interpolation.sine.apply(0, TOTAL_ROTATION, progress); final Matrix4 original = batch.getTransformMatrix().cpy(); final Matrix4 rotated = batch.getTransformMatrix(); final float disp = +0.5f * (size - currentSize) // the smaller, the more we need to "push" to center + currentSize * 0.5f; // center the cell for rotation rotated.translate(pos.x + disp, pos.y + disp, 0); rotated.rotate(0, 0, 1, currentRotation); rotated.translate(currentSize * -0.5f, currentSize * -0.5f, 0); // revert centering for rotation batch.setTransformMatrix(rotated); Cell.draw(color, batch, 0, 0, currentSize); batch.setTransformMatrix(original); }
public void draw(Batch batch, float a) { batch.end(); rend.setProjectionMatrix(batch.getProjectionMatrix()); rend.setTransformMatrix(batch.getTransformMatrix()); rend.setColor(getColor()); rend.begin(ShapeType.Line); rend.line(startX, startY, endX, endY); rend.end(); batch.begin(); } }
private ShapeRenderer renderer = new ShapeRenderer(); public void draw (Batch batch, float parentAlpha) { batch.end(); renderer.setProjectionMatrix(batch.getProjectionMatrix()); renderer.setTransformMatrix(batch.getTransformMatrix()); renderer.translate(getX(), getY(), 0); renderer.begin(ShapeType.Filled); renderer.setColor(Color.BLUE); renderer.rect(0, 0, getWidth(), getHeight()); renderer.end(); batch.begin(); }
public void draw() { rend.setProjectionMatrix(getBatch().getProjectionMatrix()); rend.setTransformMatrix(getBatch().getTransformMatrix()); rend.begin(ShapeType.Filled); drawBg(); drawBgTop(); drawLoad(); rend.end(); super.draw(); }
public void draw(Batch batch, float a) { batch.end(); rend.setProjectionMatrix(batch.getProjectionMatrix()); rend.setTransformMatrix(batch.getTransformMatrix()); rend.begin(ShapeType.Filled); rend.rect(getX(), getY(), getWidth(), getHeight(), col1, col2, col3, col4); rend.end(); batch.begin(); } }
public void draw(Batch batch, float a) { batch.end(); rend.setProjectionMatrix(batch.getProjectionMatrix()); rend.setTransformMatrix(batch.getTransformMatrix()); rend.setColor(getColor()); rend.begin(ShapeType.Line); // rend.line(startX, startY, endX, endY); rend.rect(startX, startY, endX, endY, getOriginX(), getOriginY(), getScaleX(), getScaleY(), getRotation()); rend.end(); batch.begin(); } }
public void draw(Batch batch, float a) { batch.end(); rend.setProjectionMatrix(batch.getProjectionMatrix()); rend.setTransformMatrix(batch.getTransformMatrix()); rend.begin(ShapeType.Filled); drawBgRect(getX(), getY(), getWidth(), getHeight()); drawCircleRect(getX() + 5, getY() + 5, getWidth() - 10, getHeight() - 10); rend.end(); batch.begin(); } }
/** * Draws the border. You have to call this method manually, because the * border is outside the actor and hence should be drawn at the very end, * otherwise it can get overwritten by UI element. * * @param batch */ public void drawBorder(Batch batch) { if (borderColor != null && 0 < borderSize) { final boolean reset = batch.isDrawing(); if (reset) batch.end(); final ShapeRenderer sr = getRenderer(); final Matrix4 m = batch.getTransformMatrix(); sr.setTransformMatrix(m); sr.begin(ShapeType.Filled); sr.setColor(borderColor); UIUtil.drawMarginsAround(sr, scrollPane.getX(), scrollPane.getY(), scrollPane.getWidth(), scrollPane.getHeight() - 1, borderSize, borderColor, borderStyle, 1f, 1f); sr.end(); if (reset) batch.begin(); } }
public void draw(Batch batch, float a) { batch.end(); rend.setProjectionMatrix(batch.getProjectionMatrix()); rend.setTransformMatrix(batch.getTransformMatrix()); rend.setColor(getColor()); rend.begin(ShapeType.Filled); for (int i = 0; i < path.size - 1; i++) { Vector2 now = path.get(i); Vector2 next = path.get(i + 1); rend.rectLine(now.x + getX(), now.y + getY(), next.x + getX(), next.y + getY(), strokeWidth); rend.circle(now.x + getX(), now.y + getY(), strokeWidth / 2); } rend.circle(path.peek().x + getX(), path.peek().y + getY(), strokeWidth / 2); rend.end(); batch.begin(); } }