/** * Renders the main scene graph into the OpenGL frame buffer. */ protected void paintScene () { viewSurf.saveTx(); viewSurf.begin(); viewSurf.clear(cred, cgreen, cblue, calpha); try { rootLayer.paint(viewSurf); } finally { viewSurf.end(); viewSurf.restoreTx(); } }
patted.begin().clear().setFillPattern(ttex).fillRect(0, 0, 100, 100).end().close(); ypos = ygap + addTest(170, ypos, new ImageLayer(patted.texture), "SurfaceImage patterned fillRect"); setFillColor(0xFFFF0000).fillRect(0, 0, 5, 5).fillRect(5, 5, 5, 5). setFillColor(0xFF0000FF).fillRect(5, 0, 5, 5).fillRect(0, 5, 5, 5). end().close(); ImageLayer dotl = new ImageLayer(dot.texture); dotl.setTranslation(dotBox.x + (float)Math.random()*(dotBox.width-10), setFillColor(c1).fillRect(0, 0, 50, 50). setFillColor(c2).fillRect(50, 50, 50, 50). end(); }));
@Override public void init () { // remove the background layer added by default game.rootLayer.disposeAll(); // add a grey square TextureSurface surf = game.createSurface(width, height); surf.begin().setFillColor(Color.rgb(200, 200, 200)).fillRect(0, 0, width, height).end().close(); ImageLayer square = new ImageLayer(surf.texture); game.rootLayer.add(square); conns.add(game.paint.connect(clock -> { float t = clock.tick / 1000f; IDimension vsize = game.plat.graphics().viewSize; square.setTranslation((FloatMath.cos(t) + 1) * (vsize.width() - width)/2, (FloatMath.sin(t) + 1) * (vsize.height() - height)/2); })); } }
setFillColor(Color.rgb(255, 255, 255)).fillRect(0, 0, bwidth, bheight). setFillColor(Color.rgb(0, 0, 255)).fillRect(0, bwidth/2, bwidth, bheight/2). end().close(); game.rootLayer.add(new ImageLayer(bg.texture)); surf.begin().clear().draw(imtex, 0, 0).end().close(); game.rootLayer.addAt(new ImageLayer(surf.texture), offset + width, offset); game.rootLayer.addAt(new ImageLayer(surf.texture), offset + width, offset + 2*height);
otile.width(), otile.height(), Texture.Config.DEFAULT.repeat(true, true)); new TextureSurface(game.graphics, game.defaultBatch, subtex).begin(). clear().draw(otile, 0, 0).end().close();
setFillColor(Color.rgb(255, 255, 255)).fillRect(0, 0, fullWidth, fullHeight). setFillColor(Color.rgb(0, 0, 255)).fillRect(0, 2*height, fullWidth, height). end().close(); rootLayer.add(new ImageLayer(bg.texture)); surf1.begin().clear().setAlpha(0.5f).draw(imtex, 0, 0).end().close(); groupLayer.addAt(new ImageLayer(surf1.texture), x, y0); addDescrip("surface a=0.5\nimg layer a=1", x, y1, width); surf2.begin().clear().draw(imtex, 0, 0).end().close(); groupLayer.addAt(new ImageLayer(surf2.texture).setAlpha(0.5f), x, y0); addDescrip("surface a=1\nimg layer a=0.5", x, y1, width);
si.begin().setFillColor(0xFF99CCFF).fillRect(0, 0, 100, 50).end().close(); ImageLayer s1 = new ImageLayer(si.texture); s1.setOrigin(s1.width()/2, s1.height()/2);