Questions about DrawImage

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
FEZ_GG
Posts: 1
Joined: Sat Oct 09, 2021 3:52 am

Questions about DrawImage

Post by FEZ_GG »

So I've been trying to figure out how to scale an image with StatusBarCore's DrawImage function, and I was having a tough time since the ZDoom Wiki only seems to document the SBARINFO function. At first I tried using the named argument for Scale in order to get what I wanted, but attempting to type that in threw a Script Error upon starting GZDoom, saying "Unknown Identifier 'Scale'". I was able to do this with Alpha to make my image more transparent, but I wasn't sure why it wasn't taking Scale.

Code: Select all

DrawImage("PSTRA0",(28,-10),Alpha=0.8, scale=(1,1));

After that I decided to type in values for all the arguments to make sure Scale was covered. Since the DrawImage page on ZDoom Wiki didn't mention some of these parameters like Scale of Box, I wasn't 100% sure what they all did, and simply put in the default values for them until I got to Scale.

Code: Select all

DrawImage("PSTRA0",(28,-60),0,0.8,(-1,1),(3,3));

With this line of code, I was generating an image that looked like it was about 1px in size, and would stay that way regardless of what values Scale had. It wasn't until I noticed that my Box value was (-1,1) and not the default (-1,-1) that I discovered Box needed to be changed alongside Scale. After changing Box to (300,300), I was able to get the image to scale how I wanted.

All that was resolved and I'm able to get the desired results. However I wanted to ask, did I miss something with the documentation, or was this new DrawImage function simply not documented on the Wiki? I wasn't able to find any information on it, and only learned about how Box and Scale work through trial and error. There's still quite a bit about this function and it's arguments that I don't know about, such as why I could include a named argument for Alpha, but not Scale.
phantombeta
Posts: 1971
Joined: Thu May 02, 2013 1:27 am
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Questions about DrawImage

Post by phantombeta »

FEZ_GG wrote:So I've been trying to figure out how to scale an image with StatusBarCore's DrawImage function, and I was having a tough time since the ZDoom Wiki only seems to document the SBARINFO function. At first I tried using the named argument for Scale in order to get what I wanted, but attempting to type that in threw a Script Error upon starting GZDoom, saying "Unknown Identifier 'Scale'". I was able to do this with Alpha to make my image more transparent, but I wasn't sure why it wasn't taking Scale.

Code: Select all

DrawImage("PSTRA0",(28,-10),Alpha=0.8, scale=(1,1));

All that was resolved and I'm able to get the desired results. However I wanted to ask, did I miss something with the documentation, or was this new DrawImage function simply not documented on the Wiki? I wasn't able to find any information on it, and only learned about how Box and Scale work through trial and error. There's still quite a bit about this function and it's arguments that I don't know about, such as why I could include a named argument for Alpha, but not Scale.

That's because you're using "=". What you're doing is the same as this:

Code: Select all

Alpha = 0.8;
scale = (1, 1);
DrawImage("PSTRA0",(28,-10),Alpha, scale);

For alpha, it works because the base status bar class has an "Alpha" field that also controls the alpha of everything drawn to the HUD. (This is very useful if you want to change the alpha of the whole HUD at once)
(of course, because you're doing it incorrectly, it's also passing those parameters to the wrong place, which isn't good)

Named arguments are specified by using a ":", like this:

Code: Select all

DrawImage("PSTRA0",(28,-10), alpha: 0.8, scale: (1, 1));

Return to “Scripting”