Refine search
public void draw (Batch batch, float x, float y, float width, float height) { Color batchColor = batch.getColor(); temp.set(batchColor); batch.setColor(batchColor.mul(color)); float regionWidth = region.getRegionWidth(), regionHeight = region.getRegionHeight(); int fullX = (int)(width / regionWidth), fullY = (int)(height / regionHeight); float remainingX = width - regionWidth * fullX, remainingY = height - regionHeight * fullY; y = startY; for (int ii = 0; ii < fullY; ii++) { batch.draw(region, x, y, regionWidth, regionHeight); y += regionHeight; y = startY; for (int ii = 0; ii < fullY; ii++) { batch.draw(texture, x, y, remainingX, regionHeight, u, v2, u2, v); y += regionHeight; batch.draw(texture, x, y, remainingX, remainingY, u, v2, u2, v); x = startX; for (int i = 0; i < fullX; i++) { batch.draw(texture, x, y, regionWidth, remainingY, u, v2, u2, v); x += regionWidth; batch.setColor(temp);
public void draw () { Camera camera = viewport.getCamera(); camera.update(); if (!root.isVisible()) return; Batch batch = this.batch; batch.setProjectionMatrix(camera.combined); batch.begin(); root.draw(batch, 1); batch.end(); if (debug) drawDebug(); }
/** 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); }
float height = getHeight(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); float bgLeftWidth = 0, bgRightWidth = 0; if (background != null) { float yOffset = font.isFlipped() ? -textHeight : 0; if (displayText.length() == 0) { if (!focused && messageText != null) { BitmapFont messageFont = style.messageFont != null ? style.messageFont : font; if (style.messageFontColor != null) { messageFont.setColor(style.messageFontColor.r, style.messageFontColor.g, style.messageFontColor.b, style.messageFontColor.a * color.a * parentAlpha); } else messageFont.setColor(0.7f, 0.7f, 0.7f, color.a * parentAlpha); messageFont.draw(batch, messageText, x + bgLeftWidth, y + textY + yOffset, 0, messageText.length(), width - bgLeftWidth - bgRightWidth, textHAlign, false, "...");
float width = getWidth(), height = getHeight(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); if (background != null) background.draw(batch, x, y, width, height); height -= background.getBottomHeight() + background.getTopHeight(); x += background.getLeftWidth(); y += (int)(height / 2 + background.getBottomHeight() + font.getData().capHeight / 2); } else { y += (int)(height / 2 + font.getData().capHeight / 2); font.setColor(fontColor.r, fontColor.g, fontColor.b, fontColor.a * parentAlpha); drawItem(batch, font, selected, x, y, width);
if (text.length() > 4) text = text.substring(0, text.lastIndexOf('.') + 3); text = "duration: " + text + " s (ctrl + scroll to change)"; stage.getBatch().begin(); list.getStyle().font.draw(stage.getBatch(), text, bottomLeftX + graphSize / 2, bottomLeftY + graphSize + list.getStyle().font.getLineHeight(), 0, Align.center, false); stage.getBatch().end();
public void draw (Batch spriteBatch, int start, int end) { if (pageVertices.length == 1) { // 1 page. spriteBatch.draw(font.getRegion().getTexture(), pageVertices[0], start * 20, (end - start) * 20); return; } // Determine vertex offset and count to render for each page. Some pages might not need to be rendered at all. Array<TextureRegion> regions = font.getRegions(); for (int i = 0, pageCount = pageVertices.length; i < pageCount; i++) { int offset = -1, count = 0; // For each set of glyph indices, determine where to begin within the start/end bounds. IntArray glyphIndices = pageGlyphIndices[i]; for (int ii = 0, n = glyphIndices.size; ii < n; ii++) { int glyphIndex = glyphIndices.get(ii); // Break early if the glyph is out of bounds. if (glyphIndex >= end) break; // Determine if this glyph is within bounds. Use the first match of that for the offset. if (offset == -1 && glyphIndex >= start) offset = ii; // Determine the vertex count by counting glyphs within bounds. if (glyphIndex >= start) // && gInd < end count++; } // Page doesn't need to be rendered. if (offset == -1 || count == 0) continue; // Render the page vertex data with the offset and count. spriteBatch.draw(regions.get(i).getTexture(), pageVertices[i], offset * 20, count * 20); } }
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(); } }
public void draw (Batch spriteBatch) { Array<TextureRegion> regions = font.getRegions(); for (int j = 0, n = pageVertices.length; j < n; j++) { if (idx[j] > 0) { // ignore if this texture has no glyphs float[] vertices = pageVertices[j]; spriteBatch.draw(regions.get(j).getTexture(), vertices, 0, idx[j]); } } }
batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); float textOffsetY = selectedDrawable.getTopHeight() - font.getDescent(); font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha); for (int i = 0; i < items.size; i++) { if (cullingArea == null || (itemY - itemHeight <= cullingArea.y + cullingArea.height && itemY >= cullingArea.y)) { if (touchDown == i && style.down != null) drawable = style.down; drawable.draw(batch, x, y + itemY - itemHeight, width, itemHeight); font.setColor(fontColorSelected.r, fontColorSelected.g, fontColorSelected.b, fontColorSelected.a * parentAlpha); } else if (overIndex == i && style.over != null) // style.over.draw(batch, x, y + itemY - itemHeight, width, itemHeight);
protected void drawStageBackground (Batch batch, float parentAlpha, float x, float y, float width, float height) { Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); style.stageBackground.draw(batch, x, y, width, height); }
@Override public void draw (Batch batch, float parentAlpha) { validate(); Color color = getColor(); float alpha = color.a * parentAlpha; applyTransform(batch, computeTransform()); if (firstWidget != null && firstWidget.isVisible()) { batch.flush(); getStage().calculateScissors(firstWidgetBounds, tempScissors); if (ScissorStack.pushScissors(tempScissors)) { firstWidget.draw(batch, alpha); batch.flush(); ScissorStack.popScissors(); } } if (secondWidget != null && secondWidget.isVisible()) { batch.flush(); getStage().calculateScissors(secondWidgetBounds, tempScissors); if (ScissorStack.pushScissors(tempScissors)) { secondWidget.draw(batch, alpha); batch.flush(); ScissorStack.popScissors(); } } batch.setColor(color.r, color.g, color.b, alpha); style.handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height); resetTransform(batch); }
private void renderKoala (float deltaTime) { // based on the koala state, get the animation frame TextureRegion frame = null; switch (koala.state) { case Standing: frame = stand.getKeyFrame(koala.stateTime); break; case Walking: frame = walk.getKeyFrame(koala.stateTime); break; case Jumping: frame = jump.getKeyFrame(koala.stateTime); break; } // draw the koala, depending on the current velocity // on the x-axis, draw the koala facing either right // or left Batch batch = renderer.getBatch(); batch.begin(); if (koala.facesRight) { batch.draw(frame, koala.position.x, koala.position.y, Koala.WIDTH, Koala.HEIGHT); } else { batch.draw(frame, koala.position.x + Koala.WIDTH, koala.position.y, -Koala.WIDTH, Koala.HEIGHT); } batch.end(); }
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); } }
public void draw (Batch batch, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation) { batch.draw(region, x, y, originX, originY, width, height, scaleX, scaleY, rotation); }
public Batch batchBegin() { Batch batch = super.getBatch(); batch.begin(); batch.setColor(Color.WHITE); oldTransform.set(batch.getTransformMatrix()); batch.setTransformMatrix(computeTransform()); return batch; }
public void draw (Batch batch, float parentAlpha) { validate(); if (isTransform()) { applyTransform(batch, computeTransform()); drawBackground(batch, parentAlpha, 0, 0); if (clip) { batch.flush(); float padLeft = this.padLeft.get(this), padBottom = this.padBottom.get(this); if (clipBegin(padLeft, padBottom, getWidth() - padLeft - padRight.get(this), getHeight() - padBottom - padTop.get(this))) { drawChildren(batch, parentAlpha); batch.flush(); clipEnd(); } } else drawChildren(batch, parentAlpha); resetTransform(batch); } else { drawBackground(batch, parentAlpha, getX(), getY()); super.draw(batch, parentAlpha); } }