render tripleplay element to a layer

3 views
Skip to first unread message

Andres Q

unread,
Apr 10, 2020, 11:35:13 AM4/10/20
to PlayN
Hi

Many times I want to use tripleplay's styling code to, for example, render text with shadows or a fancy background into a layer that then I can use in an animator to move around, rotate, etc.

I know that it's not what tripleplay it's meant to do :D but maybe there's a way to "render to layer"  an element or root?

Here's what I'm currently doing:

   private Layer labelToLayer(Label lbl) {
      Root root = iface.createRoot(new AbsoluteLayout(), Stylesheet.builder().create());
      root.add(AbsoluteLayout.at(lbl, 0, 0));
      root.pack();

      return root.layer;
   }

this works fine except that the returned layer has size (0,0) so it fails when I want to center it on screen for example. I'm working around it by returning the Root, which does have size, and use that to calculate.

An ugly hack, indeed.

Any suggestions?

Michael Bayne

unread,
Apr 10, 2020, 3:22:32 PM4/10/20
to pl...@googlegroups.com
Since the UI system knows the size of elements, it seems reasonable to propagate that to the GroupLayer that underlies each Element, so I just made that change and pushed it.

So now you should be able to do what you're doing already and the size will be correct.

--

---
You received this message because you are subscribed to the Google Groups "PlayN" group.
To unsubscribe from this group and stop receiving emails from it, send an email to playn+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/playn/461e81ee-9edd-43f5-b982-c657f93b1d63%40googlegroups.com.


--

Andres Q

unread,
Apr 11, 2020, 7:14:09 AM4/11/20
to pl...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages