How do I load an image from url, scale but keep the ratio?

Get help using Construct 2

Post » Thu Mar 27, 2014 10:40 am

Hey, right now I am using the load image from url event with keep current size. Is there any way to scale the images in such a way that they get parsed with their ratio intact? (So for ex say my image container is 100x50, I put in an 50x10 image, I'd like it to be fit as much as possible which would be 100x20 in this example)
B
7
S
2
G
2
Posts: 46
Reputation: 769

Post » Fri Mar 28, 2014 8:50 am

bump
B
7
S
2
G
2
Posts: 46
Reputation: 769

Post » Fri Mar 28, 2014 9:47 am

This could be complicated but a workaround way could be maybe to use conditions to determine which is more out of the proportion you need, width or height. Also have it update a variable of the original size. Resize the image to fit which ever axis was too large by the most (either width or height) use the original value and the new value to work out the percentage to reduce/enlarge the other axis.

I am only new to this and I am finding there is usually an easier way to everything but maybe this might help.
B
4
Posts: 8
Reputation: 216

Post » Fri Mar 28, 2014 10:06 am

whalan84 wrote:This could be complicated but a workaround way could be maybe to use conditions to determine which is more out of the proportion you need, width or height. Also have it update a variable of the original size. Resize the image to fit which ever axis was too large by the most (either width or height) use the original value and the new value to work out the percentage to reduce/enlarge the other axis.

I am only new to this and I am finding there is usually an easier way to everything but maybe this might help.


I did not think of this, and is in fact complicated but helpful (I like a challenge ^^) Let's see how far this will get me :)
B
7
S
2
G
2
Posts: 46
Reputation: 769

Post » Mon Mar 31, 2014 7:10 am

Okay, for the life of ..erm everything? x'D.. I cannot seem to figure this out... Anybody who wants to help a hand: feel free to..
B
7
S
2
G
2
Posts: 46
Reputation: 769

Post » Tue Apr 01, 2014 2:07 pm

I now have the following events:

CONDITION
sprite.Width > width (set to width of loaded image)
set height to round(imageDisplay.Height*(width/ImageDisplay.Width))
set sprite.Width to width (set to width of loaded image)

CONDITION
sprite.Height > height (height of loaded image)
set width to round(imageDisplay.Width*(height/imageDisplay.Height))
set sprite.Height to height (of loaded image)

However this does not resize (but when alerted gives correct sizes back).. What could be the issue of this?

If needed I am able to supply an capx file (through pm)
B
7
S
2
G
2
Posts: 46
Reputation: 769

Post » Wed Apr 02, 2014 7:59 am

Do people overlook this thread or does nobody know? :p
B
7
S
2
G
2
Posts: 46
Reputation: 769

Post » Wed Apr 02, 2014 10:00 am

Why don't you do a small test capx and uploaded it here. Not your full capx. Just a tester because Folks are busy and haven't the time to create a mock up to play around with. You might get more nibbles. This isn't a common thing that people play around with.
I know ashley did a tutorial on this awhile back (i think).
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708


Return to How do I....?

Who is online

Users browsing this forum: ksiads, marc254, marcinkowski, mtnboy22, Rable and 4 guests