/** Returns a clone of this text format with the font configured as specified. */ public TextFormat withFont(Font font) { return new TextFormat(font, this.antialias); } /** Returns a clone of this text format with the font configured as specified. */
/** Returns a clone of this text format with the font configured as specified. */ public TextFormat withFont(Font font) { return new TextFormat(font, this.antialias); } /** Returns a clone of this text format with the font configured as specified. */
/** Returns a clone of this text format with {@link #antialias} configured as specified. */ public TextFormat withAntialias(boolean antialias) { return new TextFormat(this.font, antialias); }
/** Returns a clone of this text format with the font configured as specified. */ public TextFormat withFont(Font font) { return new TextFormat(font, this.wrapWidth, this.align, this.antialias); }
/** Returns a clone of this text format with {@link #antialias} configured as specified. */ public TextFormat withAntialias(boolean antialias) { return new TextFormat(this.font, this.wrapWidth, this.align, antialias); }
/** Returns a clone of this text format with {@link #antialias} configured as specified. */ public TextFormat withAntialias(boolean antialias) { return new TextFormat(this.font, antialias); }
/** @deprecated Use {@link Graphics#layoutText(String,TextFormat,TextWrap)} and render the * wrapped lines individually. */ @Deprecated public TextFormat withWrapWidth(float wrapWidth) { return new TextFormat(this.font, wrapWidth, this.align, this.antialias); }
/** @deprecated Use {@link Graphics#layoutText(String,TextFormat,TextWrap)} and render the * wrapped lines individually (aligning them as desired). */ @Deprecated public TextFormat withAlignment(Alignment align) { return new TextFormat(this.font, this.wrapWidth, align, this.antialias); }
/** @deprecated Use {@link Graphics#layoutText(String,TextFormat,TextWrap)} and render the * wrapped lines individually. */ @Deprecated public TextFormat withWrapping(float wrapWidth, Alignment align) { return new TextFormat(this.font, wrapWidth, align, this.antialias); }
public UI (TestsGame game) { this.game = game; BUTTON_FMT = new TextFormat(new Font("Helvetica", 24)); TEXT_FMT = new TextFormat(new Font("Helvetica", 12)); }
protected void updateDisplay() { StringBuffer buf = new StringBuffer(); if (notifications.isEmpty()) { buf.append("No notifications. Pause and resume the game to generate some."); } else { buf.append("Notifications:\n"); for (String note : notifications) buf.append(note).append("\n"); } TextLayout layout = game.graphics.layoutText(buf.toString(), new TextFormat()); Canvas canvas = game.graphics.createCanvas(layout.size); canvas.setFillColor(0xFF000000).fillText(layout, 0, 0); layer.setTile(canvas.toTexture()); } }
protected void updateDisplay() { StringBuffer buf = new StringBuffer(); if (notifications.isEmpty()) { buf.append("No notifications. Pause and resume the game to generate some."); } else { buf.append("Notifications:\n"); for (String note : notifications) buf.append(note).append("\n"); } TextLayout layout = graphics().layoutText(buf.toString(), new TextFormat()); CanvasImage image = graphics().createImage(layout.width(), layout.height()); image.canvas().setFillColor(0xFF000000); image.canvas().fillText(layout, 0, 0); layer.setImage(image); } }
protected Texture makeLabel(String label) { TextLayout layout = game.graphics.layoutText(label, new TextFormat()); Canvas canvas = game.graphics.createCanvas(layout.size); canvas.setFillColor(0xFF000000).fillText(layout, 0, 0); return canvas.toTexture(); }
public void draw(Canvas canvas) { // draw a rounded rect directly canvas.setFillGradient(graphics().createLinearGradient( 0, 0, 100, 100, new int[] { 0xFF0000FF, 0xFF00FF00 }, new float[] { 0, 1 })); TextLayout capF = graphics().layoutText("F", new TextFormat().withFont(F_FONT.derive(96))); canvas.fillText(capF, 15, 5); } });
protected void addInfo (Canvas canvas, float cx, float y) { TextFormat infoFormat = new TextFormat(new Font("Helvetica", 12)); TextLayout ilayout = game.graphics.layoutText(canvas.width + "x" + canvas.height, infoFormat); Canvas iimage = game.graphics.createCanvas(ilayout.size); iimage.setFillColor(0xFF000000).fillText(ilayout, 0, 0); game.rootLayer.addAt(new ImageLayer(iimage.toTexture()), cx - iimage.width/2, y); } }
protected Image makeLabel(String label) { TextLayout layout = graphics().layoutText(label, new TextFormat()); CanvasImage image = graphics().createImage(layout.width(), layout.height()); image.canvas().setFillColor(0xFF000000); image.canvas().fillText(layout, 0, 0); return image; }
public void draw(Canvas canvas) { canvas.setFillColor(0xFFCCCCCC).fillRect(0, 0, 50, 50); canvas.setFillColor(0xFFCCCCCC).fillRect(50, 50, 50, 50); TextLayout capF = graphics().layoutText("F", new TextFormat().withFont(F_FONT)); float theta = -FloatMath.PI/4, tsin = FloatMath.sin(theta), tcos = FloatMath.cos(theta); canvas.setFillColor(0xFF000000).fillText(capF, 0, 0); canvas.transform(tcos, -tsin, tsin, tcos, 50, 50); canvas.setFillColor(0xFF000000).fillText(capF, 0, 0); } });
@Override public void init() { String text = "The quick brown fox jumped over the lazy dog."; TextFormat format = new TextFormat(new Font("Helvetica", 18)); TextBlock block = new TextBlock(game.graphics.layoutText(text, format, new TextWrap(100))); float x = 5; for (float scale : new float[] { 1f, 2f, 3f }) { float swidth = block.bounds.width() * scale, sheight = block.bounds.height() * scale; Canvas canvas = game.graphics.createCanvas(swidth, sheight); canvas.setStrokeColor(0xFFFFCCCC).strokeRect(0, 0, swidth-0.5f, sheight-0.5f); canvas.scale(scale, scale); canvas.setFillColor(0xFF000000); block.fill(canvas, TextBlock.Align.RIGHT, 0, 0); game.rootLayer.addAt(new ImageLayer(canvas.toTexture()), x, 5); addInfo(canvas, x + swidth/2, sheight + 10); x += swidth + 5; } }
protected Texture makeTextImage() { TextFormat format = new TextFormat(new Font(font.value(), style.value(), 24)); float wrapWidth = wrap.value() == 0 ? Float.MAX_VALUE : game.graphics.viewSize.width()*wrap.value()/100; TextBlock block = new TextBlock( game.graphics.layoutText(sample, format, new TextWrap(wrapWidth))); float awidth = adjustWidth(block.bounds.width()), aheight = adjustHeight(block.bounds.height()); float pad = 1/game.graphics.scale().factor; Canvas canvas = game.graphics.createCanvas(awidth+2*pad, aheight+2*pad); canvas.translate(pad, pad); canvas.setStrokeColor(0xFFFFCCCC).strokeRect(0, 0, awidth, aheight); render(canvas, block, align.value(), lineBounds.value()); return canvas.toTexture(); }
protected Image makeTextImage() { TextFormat format = new TextFormat(graphics().createFont(font.value(), style.value(), 24), true); float wrapWidth = wrap.value() == 0 ? Float.MAX_VALUE : graphics().width()*wrap.value()/100; TextBlock block = new TextBlock(graphics().layoutText(sample, format, new TextWrap(wrapWidth))); float awidth = adjustWidth(block.bounds.width()), aheight = adjustHeight(block.bounds.height()); float pad = TextBlock.pad(); CanvasImage image = graphics().createImage(awidth+2*pad, aheight+2*pad); image.canvas().translate(pad, pad); image.canvas().setStrokeColor(0xFFFFCCCC).strokeRect(0, 0, awidth, aheight); render(image.canvas(), block, align.value(), lineBounds.value()); return image; }