Forum

> > CS2D > Scripts > Image scaling/resize
Forums overviewCS2D overview Scripts overviewLog in to reply

English Image scaling/resize

2 replies
To the start Previous 1 Next To the start

old Image scaling/resize

Friendly
User Off Offline

Quote
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).
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.

old Re: Image scaling/resize

Masea
Super User Off Offline

Quote
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

old Re: Image scaling/resize

Friendly
User Off Offline

Quote
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
Log in to reply Scripts overviewCS2D overviewForums overview