@Override protected void paintImpl (Surface surf) { surf.setFillColor(0xFFFFFFFF); surf.fillRect(0, 0, _size.width, _size.height); float left = 1, top = 1, right = _size.width, bot = _size.height; surf.setFillColor(0xFF7f7F7F); for (float x = 0; x < _size.width; x += tick) { surf.drawLine(x, top, x, bot, 1); } for (float y = 0; y < _size.height; y += tick) { surf.drawLine(left, y, right, y, 1); } surf.setFillColor(0xFFFF7F7F); surf.drawLine(left - 1, top, right, top, 2); surf.drawLine(right - 1, top - 1, right - 1, bot, 2); surf.drawLine(left, top - 1, left, bot, 2); surf.drawLine(left - 1, bot - 1, right, bot - 1, 2); } });
public void render (Surface surf) { surf.setFillColor(0xFF0000FF).fillRect(0, 0, 100, 25); // these two alpha fills should look the same surf.setFillColor(0x80FF0000).fillRect(0, 0, 50, 25); surf.setAlpha(0.5f).setFillColor(0xFFFF0000).fillRect(50, 0, 50, 25).setAlpha(1f); } }, 100, 25, "left and right half both same color");
public void render (Surface surf) { // fill some shapes with patterns surf.setFillPattern(pattern).fillRect(10, 0, 100, 100); // use same fill pattern for the triangles surf.translate(0, 160); // render a sliding window of half of our triangles to test the slice rendering surf.fillTriangles(verts, offset*4, (hsamples+1)*4, indices, offset*6, hsamples*6, offset*2); offset += doff; if (offset == 0) doff = 1; else if (offset == hsamples) doff = -1; } private int offset = 0, doff = 1;
TextureSurface bg = game.createSurface(bwidth, bheight); bg.begin(). 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);
@Override protected void paintImpl (Surface surf) { surf.setFillColor(0xFFCCCCCC); surf.fillRect(0, 0, width, height); } };
patted.begin().clear().setFillPattern(ttex).fillRect(0, 0, 100, 100).end().close(); ypos = ygap + addTest(170, ypos, new ImageLayer(patted.texture), "SurfaceImage patterned fillRect"); TextureSurface dot = game.createSurface(10, 10); dot.begin(). 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), int c1 = (0xFF << 24) | (sinColor << 16) | (cosColor << 8); int c2 = (0xFF << 24) | (cosColor << 16) | (sinColor << 8); paintUpped.begin().clear(). 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 graphics().rootLayer().clear(); // add a grey square square = graphics().createSurfaceLayer(width, height); square.surface().setFillColor(Color.rgb(200, 200, 200)); square.surface().fillRect(0, 0, square.surface().width(), square.surface().height()); graphics().rootLayer().add(square); }
@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); })); } }
@Override protected void paintImpl (Surface surface) { IDimension size = group.size(); position.point.get().resolve(size, pt); surface.saveTx(); surface.setFillColor(Colors.BLACK); surface.fillRect(pt.x - 2, pt.y - 2, 5, 5); surface.restoreTx(); } }.setDepth(1));
protected void paintClipped (Surface surf) { // this fill should be clipped to our bounds surf.setFillColor(0xFF99CCFF); surf.fillRect(-50, -50, 200, 200); // and this image should be clipped to our bounds surf.draw(cirtex, 80, -25); } };
@Override protected void paintImpl (Surface surf) { surf.saveTx(); surf.scale(_destScale, _destScale); Float alpha = Scale9Background.this.alpha; if (alpha != null) surf.setAlpha(alpha); if (_tint != Tint.NOOP_TINT) surf.setTint(_tint); // issue the 9 draw calls for (int yy = 0; yy < 3; ++yy) for (int xx = 0; xx < 3; ++xx) { drawPart(surf, xx, yy); } if (alpha != null) surf.setAlpha(1); // alpha is not part of save/restore surf.restoreTx(); }
public void render (Surface surf) { // this fill should be clipped to our bounds surf.setFillColor(0xFF99CCFF); surf.fillRect(-50, -50, 300, 300); // and this image should be clipped to our bounds surf.drawImage(circle, 125, -25); } });
@Override public void render(Surface surface) { surface.setFillColor(0xff000000); float t = 0.5f, l = 0.5f, b = layer.height() - 0.5f, r = layer.width() - 0.5f; surface.drawLine(l, t, l, b, 1); surface.drawLine(r, t, r, b, 1); surface.drawLine(l, b, r, b, 1); surface.drawLine(l, t, r, t, 1); } }
@Override public void paint(float alpha) { for (ImageLayer dot : dots) { if (random() > 0.95) { dot.setTranslation(dotBox.x + random()*(dotBox.width-10), dotBox.y + random()*(dotBox.height-10)); } } if (paintUpped != null) { float now = (elapsed + UPDATE_RATE*alpha)/1000; float sin = Math.abs(FloatMath.sin(now)), cos = Math.abs(FloatMath.cos(now)); int sinColor = (int)(sin * 255), cosColor = (int)(cos * 255); int c1 = (0xFF << 24) | (sinColor << 16) | (cosColor << 8); int c2 = (0xFF << 24) | (cosColor << 16) | (sinColor << 8); paintUpped.surface().clear(); paintUpped.surface().setFillColor(c1).fillRect(0, 0, 50, 50); paintUpped.surface().setFillColor(c2).fillRect(50, 50, 50, 50); } }