The implementation of "Middle" parameter on themes syntax

  • 2 Replies
  • 324 Views
The implementation of "Middle" parameter on themes syntax
« on: 07 January 2020, 14:49:11 »
Hi Texus! Could you tell me how you implemented the "Middle" parameter on themes syntax? How do you scale given rect of texture and remain unchanged other parts?

*

texus

  • *****
  • 1586
    • View Profile
    • Texus's Blog
Re: The implementation of "Middle" parameter on themes syntax
« Reply #1 on: 07 January 2020, 18:40:55 »
The middle is passed as a (left, top, width, height) rect. If top is 0 and height is equal to the texture height then it splits the image in 3 parts. In this case the left and right parts will keep their ratio while the center part is stretched to fill the remaining of the area.
If the middle part doesn't has the same height as the texture and divides the image in 9 parts then 9-slice scaling is performed. The corners will not be scaled, the top and bottom bar will be stretched only horizontally, the left and right bars will only be stretched vertically and the center part is stretched to fill the remaining area.

The implementation itself is just a matter of creating triangles with the right texture coordinates.

Re: The implementation of "Middle" parameter on themes syntax
« Reply #2 on: 08 January 2020, 07:45:35 »
Wow! I don’t have to implement it myself. I just can use tgui::Texture and tgui::Sprite! Thank you very much for your library! It is very useful to me. I am very grateful to you.