English Image scaling/resize

2 replies
Goto Page
To the start Previous 1 Next To the start
13.07.20 10:19:42 pm
Up
Friendly
User
Offline Off
Hi,

I have simple image hud with 16x16 pixel, i need horizontal line, so i have to use imagescale to programmatically resize/rescale the image, but it's affect both side (left & right).
Code:
1
2
local img = image('gfx/white.png', w / 2, h / 2, 2)
imagescale(img, 2.5, 1)

My question is, how to resize/rescale image just for one side?
Thank you.
13.07.20 11:04:06 pm
Up
Masea
Super User
Offline Off
There are two ways:
• Rescale the image along with repositioning it. Requires some math knowledge, could be easily found on the web.
• Traditional way I've seen all these years in CS2D servers is that just rescale the image which is specifically drawn for this kind of usage. If you consider the image as two sides, the left should be completely empty (transparent) and your actual image goes to the right. So in-game, nothing will technically be changed but since there's nothing in the left side, you will only see the right side scaling up or down. This means the image will potentially be two times wider. Like this: https://imgur.com/wLMR3yG. You better download it to notice the difference.

This technic is mostly used for progress bars.
edited 3×, last 13.07.20 11:16:58 pm
Create your UI easy and fast: UI Framework | Go deeper into the darkness and test your bravery: file cs2d Outlast II Modification (28)
13.07.20 11:40:24 pm
Up
Friendly
User
Offline Off
Yes, i am trying to make progress bar for ammo and health, a bit off-topic, i have C- in math.

Thank you user Masea for the information, i love you.
To the start Previous 1 Next To the start