How to draw shapes in libgdx table? -


i want draw graph (math function), , want insert table cell. try insert shaperenderer table, not working. how can this? thank you!

i try use that:

table table = new table();  shaperenderer shaperen = new shaperenderer(); shaperen.begin(shapetype.filled); shaperen.setcolor(1,1,1,1); shaperen.rect(0,0,50,50); shaperen.end();  table.add(shaperen); 

i know, not right. =) can me make that?

you can't add shaperenderer table not actor, if wanna use within table, guess following.

public class mygdxgame extends applicationadapter {     table table;     shaperenderer shaperen;     stage stage;      @override     public void create () {         stage = new stage();         table = new table();         table.setdebug(true);         table.row().pad(20).size(200, 50);         table.add();         table.row().pad(20).size(200, 50);         table.add();         table.setposition(gdx.graphics.getwidth()/2, gdx.graphics.getheight()/2);          stage.addactor(table);         shaperen = new shaperenderer();     }      @override     public void render () {         stage.draw();         drawshapes();     }      public void drawshapes() {         shaperen.begin(shaperenderer.shapetype.filled);         shaperen.setcolor(1,1,1,1);         shaperen.rect(table.getx() - table.getprefwidth()/2 + table.getcells().get(0).getpadleft(),table.gety() + table.getprefheight()/2 - table.getcells().get(0).getprefheight() - table.getcells().get(0).getpadtop(),50,50);         shaperen.end();     } } 

the output this: result in desktop


Comments