Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unclear behavior of SCALE_INTO IPF #3985

Open
sevu opened this issue Mar 15, 2019 · 0 comments
Open

unclear behavior of SCALE_INTO IPF #3985

sevu opened this issue Mar 15, 2019 · 0 comments
Labels
Graphics Issues that involve the graphics engine or assets. Help In-game Help functions Question Issues that are actually questions rather than problem reports.

Comments

@sevu
Copy link
Member

sevu commented Mar 15, 2019

I looked into the source which generates the help pages for units. The line I was looking for is:

ss << "<img>src='" << male_portrait << "~FL(horiz)~SCALE_INTO(" << sz << ',' << sz << ")' box='no' align='right' float='yes'</img> ";

sz is the number of pixels, in my case 400. So, it uses the portrait, the FL() IPF and the SCALE_INTO() IPF.

Let's compare three values for the portrait (set as small_profile in WML).
For simplicity, assume that the by cropping removed part was transparent.

  • "portraits/worker.png"
  • "portraits/worker.png~CROP(0,0,362,450)"
  • "portraits/worker.png~CROP(0,0,362,450)~SCALE_INTO(400,400)"

With the above code, it should end up as:

  • "portraits/worker.png~FL(horiz)~SCALE_INTO(400,400)"
  • "portraits/worker.png~CROP(0,0,362,450)~FL(horiz)~SCALE_INTO(400,400)"
  • "portraits/worker.png~CROP(0,0,362,450)~SCALE_INTO(400,400)~FL(horiz)~SCALE_INTO(400,400)"

The cropping removes the right part of the image, which is latter flipped, so it's missing the left part. Images in the help are right aligned, meaning that in all three cases, the image should have each pixel at the same spot, with the non cropped having more pixels on the left (transparent or not)

It turns out, that:
1 & 3 have the pixels on the same spots.
Variant 2 misses a few pixels on the right (~5). How can this happen?

The image I used is a slightly modified 450x450 Drake Fighter portrait (without weapon, lvl 0 unit). I want to crop a transparent part away, so that the image is smaller and the text doesn't need to wrap.
I still want to have the pixels at the same place like the lvl 1 Drake Fighter, because it looks better to not see a 5px shift when switching from the lvl 0 help page to the lvl 1 help page.

For testing, add ~CROP(0,0,362,450) to the Drake Warrior.

@sevu sevu added Graphics Issues that involve the graphics engine or assets. Help In-game Help functions Question Issues that are actually questions rather than problem reports. labels Mar 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Graphics Issues that involve the graphics engine or assets. Help In-game Help functions Question Issues that are actually questions rather than problem reports.
Projects
None yet
Development

No branches or pull requests

1 participant