@Override public float width() { return graphics().width(); } @Override
@Override public void error(Throwable err) { addDescrip("Error: " + err.getMessage(), 10, errY, graphics().width()-20); errY += 30; } private float errY = 10;
protected void displayText (String text) { output.setImage(wrapText(text, graphics().width()-20, TextBlock.Align.LEFT)); }
private void addTestLayer(int width, int height, Layer layer) { // if this layer won't fit in this row, wrap down to the next if (nextX + width > graphics().width()) { nextY += (maxY + GAP); nextX = GAP; maxY = 0; } layer.setTranslation(nextX, nextY); graphics().rootLayer().add(layer); // update our positioning info nextX += (width + GAP); maxY = Math.max(maxY, height); }
public void render(Surface surf) { surf.setFillColor(0xFFFFFFFF).fillRect(0, 0, graphics().width(), graphics().height()); } });
protected void addToRow (ImageLayer layer) { graphics().rootLayer().add(layer.setTranslation(row.x + row.width, row.y)); row.width += layer.width() + 45; row.height = Math.max(row.height, layer.height()); if (row.width > graphics().width() * .6f) newRow(); }
@Override public void paint(float alpha) { float t = (time + alpha*UPDATE_RATE) / 1000; square.setTranslation((FloatMath.cos(t) + 1) * (graphics().width() - width) / 2, (FloatMath.sin(t) + 1) * (graphics().height() - height) / 2); } }
@Override public void paint(float alpha) { float t = (time + alpha) / 1000; square.setTranslation((FloatMath.cos(t) + 1) * (graphics().width() - width) / 2, (FloatMath.sin(t) + 1) * (graphics().height() - height) / 2); } }
public void render(Surface surf) { surf.setFillColor(Color.rgb(255, 255, 255)); surf.fillRect(0, 0, graphics().width(), graphics().height()); } });
private void addTestLayer(String descrip, int width, int height, Layer layer) { // if this layer won't fit in this row, wrap down to the next if (nextX + width > graphics().width()) { nextY += (maxY + GAP); nextX = GAP; maxY = 0; } // add the layer and its description below graphics().rootLayer().addAt(layer, nextX, nextY); ImageLayer dlayer = createDescripLayer(descrip, width); graphics().rootLayer().addAt(dlayer, nextX + Math.round((width-dlayer.width())/2), nextY + height + 2); // update our positioning info nextX += (width + GAP); maxY = Math.max(maxY, height+dlayer.height()+2); }
public void render (Surface surf) { surf.setFillColor(0xFFFFCC99); surf.fillRect(0, 0, graphics().width(), graphics().height()); // fill a rect that will be covered except for one pixel by the clipped immediate layer surf.setFillColor(0xFF000000); surf.fillRect(99, 99, 202, 202); } });
public void render (Surface surf) { surf.setFillColor(0xFFFFCC99); surf.fillRect(0, 0, graphics().width(), graphics().height()); // fill a rect that will be covered except for one pixel by the clipped immediate layers surf.setFillColor(0xFF000000); surf.fillRect(29, 29, 202, 202); surf.fillRect(259, 29, 102, 102); surf.fillRect(259, 159, 102, 102); } }));
@Override public void update(int delta) { canvas.clear(); canvas.setStrokeWidth(3); canvas.setStrokeColor(0x88ff0000); noSegs += direction; if (noSegs > 50) direction = -1; if (noSegs < 20) direction = 1; final float r = 100; for (int ii = 0; ii < noSegs; ii++) { float angle = 2*FloatMath.PI * ii / noSegs; float x = (r * FloatMath.cos(angle)) + graphics().width() / 2; float y = (r * FloatMath.sin(angle)) + graphics().height() /2; canvas.strokeCircle(x, y, 100); } } }
@Override public void init() { CanvasImage canvasImage = graphics().createImage(graphics().width(), graphics().height()); canvas = canvasImage.canvas(); graphics().rootLayer().add(graphics().createImageLayer(canvasImage)); }
void startTest(Test test) { clearTest(); currentTest = test; // setup root layer for next test clearRoot(); GroupLayer root = graphics().rootLayer(); root.add(createWhiteBackground()); log().info("Starting " + currentTest.getName()); log().info(" Description: " + currentTest.getDescription()); currentTest.init(); if (currentTest.usesPositionalInputs()) { // slap on a Back button if the test is testing the usual means of backing out ImageLayer back = Test.createButton("Back", new Runnable() { public void run () { displayMenuLater(); } }); root.addAt(back, graphics().width() - back.width(), 0); } }
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; }
if (x + button.width() > graphics().width() - gap) { x = gap; y += maxHeight + gap;