How can I display a square image with nifty?

Hi,

how can I display a square image with nifty?

I make a square image in gimp, let it be 100x100

in nifty xml, I saw the option height and width

<image filename=“menu/newgame.png” x=“40%” y=“38%” height=“10%” width=“20%” >

if I let both of them 10% then I will get a rectangle.

I would like something like this

<image filename=“menu/newgame.png” x=“40%” y=“38%” height=“10%(of height)” width=“10%(of height)” >

are there any way to display the image square and relative to the width/height of display?

I think you may need to specify the coords in pixels like “100px” instead of percent

@Momoko_Fan

I thought about px too.

Currently I have a window, if later I let user go to fullscreen mode then it will be a mess.

I have an idea but dont know if it is possible to do

in xml I will let the height and width= 0%

then when the screen is called → call a java method to calculate and change their width + height to both 10% of height.

Hey. I had the same feature request a long time ago, and void was really nice to implement it. :slight_smile: I was already wondering if this is useful only for me… :slight_smile:

So here is the thing, you can use this:

<image filename=“menu/newgame.png” imageMode=“normal” width=“250%h” height=“50%” />

This means that you can fix one of the values to current width or height of the screen and the other to the first value. In this example, I fix my picture to be half of the screen in height, and its width is then always 2.5 times of height. In your example, to get a square, you would just use: width=“100%h” height=“X%” or width=“X%” height=“100%w”, where X is your desired percent of screen height or width value.

I find fixing a value to height extremely useful for supporting widescreen resolutions. You can for example test on 4:3 aspect ratio and if all your elements fit in, they will definitely fit in on 16:10 and other aspect ratios, although you will have nothing in left and right borders, unless you stretch your elements, which imho doesn’t always look good, especially for fixed pictures… :slight_smile:

1 Like

thanks @InShadow

it is useful not only for you, now it is useful for at least 2 of us and I think the counter will still go up and explode one day ^^

Yeah its useful to me too. It needs better syntax though, this one is kinda cryptic

Yes it was my idea what to put there, and void just did it (thanks again!). Maybe it just needs to be better documented? :slight_smile:

InShadow said:
Yes it was my idea what to put there, and void just did it (thanks again!). Maybe it just needs to be better documented? :)

Sad thing is that many people leave this forum with new knowledge (that they complain is not in the wiki) and then don't add it to the wiki :(

I agree that it is like a hidden ace, and needs to be better documented.

but in nifty wiki or here?



as a normal user who is not a native english speaker and never edited/created wiki, I dont know

  1. am I allowed to edit wiki? how to do it? (do I need authority)
  2. what happened if what I wrote is wrong or people cant understand it? will someone check and correct it



    for me those two question prevent me to edit wiki, and I think also for others who come and leave (or may be they are simple “clever” lazy bones )

I agree with @xieu90. I also don’t want to edit wikis, especially for things that I didn’t make and don’t know exactly how they work…

These questions are answered in the Website Manual and Contributors Handbook. Also, you get a confirmation here in the forum that it works this way… so you do know its right. All of that is just bad excuses for laziness, sorry. Please don’t ever complain about the wiki content again :stuck_out_tongue: