public Span (Graphics gfx, String text, TextStyle style) { super(gfx, text, style); _layout = gfx.layoutText(text, style); }
public TextLogger(float wid, int lines, TextFormat format) { super(wid, game.graphics.layoutText(".", format).size.height() * lines, format); this.lineCount = lines; }
public void update () { _layout = _game.plat.graphics().layoutText(String.valueOf(label.get()), _fmt); } public float labelWidth () { return 0; }
public TextLogger(float wid, int lines, TextFormat format) { super(wid, graphics().layoutText(".", format).height() * lines, format); this.lineCount = lines; }
public TextMapper(float wid, int lines, TextFormat format) { super(wid, graphics().layoutText(".", format).height() * lines, format); }
public Texture wrapText(String text, float width, TextBlock.Align align) { TextLayout[] layouts = game.graphics.layoutText(text, TEXT_FMT, new TextWrap(width)); Canvas canvas = new TextBlock(layouts).toCanvas(game.graphics, align, 0xFF000000); return canvas.toTexture(); }
public void update () { _vlayout = _game.plat.graphics().layoutText(String.valueOf(value.get()), _fmt); _size.setSize(llayout.size.width() + GAP + _vlayout.size.width(), Math.max(llayout.size.height(), _vlayout.size.height())); } public float labelWidth () { return llayout.size.width(); }
public Block (Graphics gfx, String text, TextStyle style, TextWrap wrap, TextBlock.Align align) { super(gfx, text, style); assert wrap != null && align != null; this.wrap = wrap; this.align = align; _layouts = gfx.layoutText(text, style, wrap); _bounds = TextBlock.getBounds(_layouts, new Rectangle()); _bounds.width = style.effect.adjustWidth(_bounds.width); _bounds.height = style.effect.adjustHeight(_bounds.height); }
protected static CanvasImage wrapText(String text, float width, TextBlock.Align align) { TextLayout[] layouts = graphics().layoutText(text, TEXT_FMT, new TextWrap(width)); return new TextBlock(layouts).toImage(align, 0xFF000000); }
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; }
protected ImageLayer createLabel(String text, GroupLayer parent, int fg, int bg, float x, float y, float padding) { TextLayout layout = game.graphics.layoutText(text, baseFormat); float twidth = layout.size.width() + padding * 2; float theight = layout.size.height() + padding * 2; Canvas canvas = game.graphics.createCanvas(twidth, theight); if (bg != 0) canvas.setFillColor(bg).fillRect(0, 0, twidth, theight); canvas.setFillColor(fg).fillText(layout, padding, padding); ImageLayer imageLayer = new ImageLayer(canvas.toTexture()); parent.addAt(imageLayer, x, y); return imageLayer; }
public Texture formatText (TextFormat format, String text, boolean border) { TextLayout layout = game.graphics.layoutText(text, format); float margin = border ? 10 : 0; float width = layout.size.width()+2*margin, height = layout.size.height()+2*margin; Canvas canvas = game.graphics.createCanvas(width, height); if (border) canvas.setFillColor(0xFFCCCCCC).fillRect(0, 0, canvas.width, canvas.height); canvas.setFillColor(0xFF000000).fillText(layout, margin, margin); if (border) canvas.setStrokeColor(0xFF000000).strokeRect(0, 0, width-1, height-1); return canvas.toTexture(); }
protected static CanvasImage formatText (TextFormat format, String text, boolean border) { TextLayout layout = graphics().layoutText(text, format); float margin = border ? 10 : 0; float width = layout.width()+2*margin, height = layout.height()+2*margin; CanvasImage image = graphics().createImage(width, height); image.canvas().setStrokeColor(0xFF000000); image.canvas().setFillColor(0xFF000000); image.canvas().fillText(layout, margin, margin); if (border) image.canvas().strokeRect(0, 0, width-1, height-1); 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); } });
protected void addInfo (CanvasImage image, float cx, float y) { TextLayout ilayout = graphics().layoutText(image.width() + "x" + image.height(), infoFormat); CanvasImage iimage = graphics().createImage(ilayout.width(), ilayout.height()); iimage.canvas().setFillColor(0xFF000000).fillText(ilayout, 0, 0); graphics().rootLayer().addAt(graphics().createImageLayer(iimage), cx - iimage.width()/2, y); }
public static Image makeButtonImage(String label) { TextLayout layout = graphics().layoutText(label, BUTTON_FMT); CanvasImage image = graphics().createImage(layout.width()+10, layout.height()+10); image.canvas().setFillColor(0xFFCCCCCC); image.canvas().fillRect(0, 0, image.width(), image.height()); image.canvas().setFillColor(0xFF000000); image.canvas().fillText(layout, 5, 5); image.canvas().setStrokeColor(0xFF000000); image.canvas().strokeRect(0, 0, image.width()-1, image.height()-1); return image; }
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; }