Set texture of UI element?

Thalassicus

Bytes and Nibblers
Joined
Nov 9, 2005
Messages
11,057
Location
Texas
How do I properly set the texture of a UI element? I tried this:

Code:
<Image ID="Divider" Anchor="L,B" Texture="bar900x2.dds" Size="930,1"/>
PHP:
controlTable.Divider:SetSize(Vector2(960, 5))
controlTable.Divider:SetAnchor("C,B")
controlTable.Divider:SetTexture("HorizontalTrim.dds")

The first two commands worked, but the texture was a blank grey placeholder instead of HorizontalTrim.dds.
 
It's not a blank grey placeholder but the HorizontalTrim file stretched and then "cut-up" to fit the space, unfortunately the UI drawing code does some very weird scaling of graphics when you change the image size via the API.

It will be quicker (and better for your sanity) to have two dividers - DividerBar and DividerTrim - defined in the UI XML of the correct size/placement and hide/show them as necessary
 
, unfortunately the UI drawing code does some very weird scaling of graphics when you change the image size via the API.

When you size something in xml, it is like a "cookie cutter" and will crop out (if size too small) or stretch the last pixel row (if size to big). So xml size should always match the dds size exactly.

However, once the element is created, you can use Lua size functions to stretch/shrink the element as needed. I find this works pretty well and use it to display portraits with arbitrary aspect ratios.
 
When you size something in xml, it is like a "cookie cutter" and will crop out (if size too small) or stretch the last pixel row (if size to big).
Pretty much what I've discovered as well, except you don't always want the size in xml to match the size of the texture, for example when you specifically want to see just a part of a compound texture (like the icons and the pipes)

However, once the element is created, you can use Lua size functions to stretch/shrink the element as needed. I find this works pretty well and use it to display portraits with arbitrary aspect ratios.

Except that doesn't always work as expected, sometimes the stretch occurs as expected (for example the horizontal and vertical pipes) and sometimes it doesn't (like the horizontal trim)

From what I've found the problems occur when you do change the aspect ratio, but if you keep it the same as the original image size by just changing the X/Y scaling equally things seem to be OK
 
Back
Top Bottom