@Override public void render(Canvas canvas, Rect2i bounds, TextRenderStyle defaultRenderStyle) { canvas.drawTexture(textureRegion, bounds); }
canvas.drawBackground(iconRegion); if (ratio - i >= 0.5f) { canvas.drawTexture(icon, iconRegion); } else if (ratio - i > 0f) { switch (halfIconMode) { halfSize.x /= 2; halfSize.y /= 2; canvas.drawTexture(icon, Rect2i.createFromMinAndSize(new Vector2i(offset.x + halfSize.x / 2, offset.y + halfSize.y / 2), halfSize)); break; break; default: canvas.drawTexture(icon, iconRegion); break;
@Override public void onDraw(Canvas canvas) { canvas.addInteractionRegion(connectListener); if (getTargetPort() != null) { canvas.drawTexture(active); } else { canvas.drawTexture(inactive); } }
/** * Draws the widget * * @param canvas The canvas to draw on. */ public void onDraw(Canvas canvas) { canvas.getRegion(); canvas.drawTexture(sectionTexture, sectionRegion); if (icon != null) { canvas.drawTexture(icon, innerRegion); } if (text != null) { canvas.drawText(text, innerRegion); } if (isSelected) { canvas.drawTexture(selectedTexture, sectionRegion); if (widget != null) { canvas.drawWidget(widget, infoRegion); } } }
@Override public void onDraw(Canvas canvas) { if (getChargeAmount() > 0 && !chargeStages.isEmpty()) { int state = TeraMath.floorToInt(getChargeAmount() * (chargeStages.size() - 1)); canvas.drawTexture(chargeStages.get(state)); } }
Rect2i region = Rect2i.createFromMinAndSize(selectionTopLeft.x, selectionTopLeft.y, selectionWidth, font.getLineHeight()); canvas.drawTexture(cursorTexture, region, textColor); canvas.drawTextRaw(FontUnderline.strip(FontColor.stripColor(selectionString)), font, textColor.inverse(), region);
/** * Draws the cursor in the text field. * * @param canvas The canvas on which the widget resides */ protected void drawCursor(Canvas canvas) { if (blinkCounter < BLINK_RATE) { Font font = canvas.getCurrentStyle().getFont(); String beforeCursor = text.get(); if (getCursorPosition() < text.get().length()) { beforeCursor = beforeCursor.substring(0, getCursorPosition()); } List<String> lines = TextLineBuilder.getLines(font, beforeCursor, canvas.size().x); // TODO: Support different alignments int lastLineWidth = font.getWidth(lines.get(lines.size() - 1)); Rect2i region = Rect2i.createFromMinAndSize(lastLineWidth, (lines.size() - 1) * font.getLineHeight(), 1, font.getLineHeight()); canvas.drawTexture(cursorTexture, region, canvas.getCurrentStyle().getTextColor()); } }
@Override public void onDraw(Canvas canvas) { if (image.get() != null) { if (ignoreAspectRatio) { ScaleMode scaleMode = canvas.getCurrentStyle().getTextureScaleMode(); canvas.getCurrentStyle().setTextureScaleMode(ScaleMode.STRETCH); canvas.drawTexture(image.get(), tint.get()); canvas.getCurrentStyle().setTextureScaleMode(scaleMode); } else { canvas.drawTexture(image.get(), tint.get()); } } }
@Override public void onDraw(Canvas canvas) { canvas.drawTexture(texture); BehaviorState status = getState(); String text = getData().displayName + " " + (status != null ? status : ""); if (collapsed) { text += "[+]"; } canvas.drawText(text); if (editor != null) { canvas.addInteractionRegion(moveListener, getData().description); } portList.onDraw(canvas); }
/** * Handles how the {@code UIButton} is drawn. * This is called every frame. * * @param canvas The {@link Canvas} on which this {@code UIButton} is drawn */ @Override public void onDraw(Canvas canvas) { if (image.get() != null) { canvas.drawTexture(image.get()); } canvas.drawText(text.get()); if (isEnabled()) { canvas.addInteractionRegion(interactionListener); } }
@Override public void onDraw(Canvas canvas) { if (getIcon() != null) { canvas.drawTexture(getIcon()); } else if (getMesh() != null && getMeshTexture() != null) { Quat4f rot = new Quat4f(TeraMath.PI / 6, -TeraMath.PI / 12, 0); canvas.drawMesh(getMesh(), getMeshTexture(), canvas.getRegion(), rot, new Vector3f(), 1.0f); } if (getQuantity() > 1) { canvas.drawText(Integer.toString(getQuantity())); } List<TooltipLine> tooltipLines = tooltip.getList(); if (tooltipLines != null && !tooltipLines.isEmpty()) { canvas.addInteractionRegion(listener); } }
@Override public void draw(T value, Canvas canvas) { // Drawing the icon TextureRegion texture = getTexture(value); if (texture != null) { if (marginTop + texture.getHeight() + marginBottom > canvas.size().y) { // Icon does not fit within the canvas - vertically shrinking it int iconHeight = canvas.size().y - marginTop - marginBottom; canvas.drawTexture(texture, Rect2i.createFromMinAndSize(marginLeft, marginTop, texture.getWidth(), iconHeight)); } else { // Icon fits within the canvas - vertically centering it int iconVerticalPosition = (canvas.size().y - texture.getHeight()) / 2; canvas.drawTexture(texture, Rect2i.createFromMinAndSize(marginLeft, iconVerticalPosition, texture.getWidth(), texture.getHeight())); } } // Drawing the text, adjusting for icon width String text = getString(value); int iconWidth; if (texture != null) { iconWidth = marginLeft + texture.getWidth() + marginRight; } else { iconWidth = 0; } Rect2i textRegion = Rect2i.createFromMinAndSize(iconWidth, 0, canvas.getRegion().width() - iconWidth, canvas.getRegion().height()); canvas.drawText(text, textRegion); }