Is smooth scaling of an image object, smaller to larger or vice versa, possible in Corona?

My tutor and I have both tried in our own seperate code to smooth scale an image whilst being placed on a rotating sine wave. Both the attempts had the same result which is the image instantly went super large, filling the screen then went back to the images original smaller size with no apparent scaling at all.

Since these were only tests to see if smooth scaling of an image object was possible within Corona, I will not be posting the code I used.

Could you please tell us, is smooth scaling of an object, from a small size to a large size, or vice versa possible within Corona? And if possible could someone post a small piece of code demonstrating this, as it will be usefull to use this ability within our own code and games?

Scaling objects works fine for me. Can you provide the code you attempted to use to scale your objects?

As it was a test to see if scaling was possible and the test failed the code was deleted. So you are saying that smooth scaling is possible, ie a large image can gradually reduce size to a smaller image and vice versa?

Would it be possible for you to post a small example code which I could place my own image in to demonstrate to my tutor and I how this works.

We were thinking that, in our own code, the scaling value’s were too large (even though we compensated for this code wise) thus Corona was not able to cope and therefore had the above reaction. Seeing a working example would help us greatly. (The example does’nt neccessarily have to be on a sine-wave, as I said, it was just a test to see if smooth scaling is possible). Any help from anyone would be appreciated.

 local cloud3 = display.newRect(0,0,75,25) cloud3.x = 100 cloud3.y = display.screenOriginY+50 cloud3.alpha = 1 local function trans1() local function trans2() transition.to(cloud3, {time=8000,xScale=1.1, yScale=1.1 ,onComplete=trans1}) end transition.to(cloud3, {time=8000,xScale=.85, yScale=.85, onComplete=trans2}) end trans1()

Try that out.

I have tried this on an image object and with a slight bit of tweaking it works silky smooth.

Thank you very much Panc :slight_smile: I’m a happy chappy.

As a side note, after seeing this my original test values must have been way too large since even at 1.5 scaling within your code my current image fills a third of the display size.

I’d love to see what you tried to get this to work. My code doesn’t relate to sine waves so perhaps that was your problem.

If you want to scale dynamicaly use .xScale and .yScale properties not object:scale().
Second one scales image and ‘saves’ scaled version in memory so after few operation smoothnes can be degradated. Using properties will always scale original one before displaying, keeping original intact.

Reply for Panc,

The sine wave code I used (I don’t know about my tutor’s code), as an example, rotated circles on a sine wave. So eg. instead of just going up and down, it gave you the impression of going in and out as well. As I said, unfortunately, I deleted the code (last week), but whilst using it I checked (using print) the values coming out of it to see if I could use it to test smooth scaling of an object.

As you already know, an objects scale is 1, anything less scales the object down, and 2 is 200% scaling, so I new I had to use small values to make this work. The sine wave was chucking out values up to 680, so I had to adapt the code to scale this value down to an acceptable level. In the end, even with a lot of tweaking we had the same problem as indicated above. So we went on to other things. But now you have shown us it is possible with Corona, the skys the limit :slight_smile:

Thanks piotrz55, that clears up a bit of ambiguity from reading the documentation.

Just to clarify, for anyone else who reads this, what you are saying is that:

object:scale saves the scaled image to memory therefore overwriting the original. So the end result when you scale back up after using this a few times is that the smaller scaled image will be scaled up (not the original larger image) resulting in a degraded and less sharp looking image.

So using object.xScale and object.yscale properties is the best solution as it references the original image at all times, so therefore there is no image degradation.

Scaling objects works fine for me. Can you provide the code you attempted to use to scale your objects?

As it was a test to see if scaling was possible and the test failed the code was deleted. So you are saying that smooth scaling is possible, ie a large image can gradually reduce size to a smaller image and vice versa?

Would it be possible for you to post a small example code which I could place my own image in to demonstrate to my tutor and I how this works.

We were thinking that, in our own code, the scaling value’s were too large (even though we compensated for this code wise) thus Corona was not able to cope and therefore had the above reaction. Seeing a working example would help us greatly. (The example does’nt neccessarily have to be on a sine-wave, as I said, it was just a test to see if smooth scaling is possible). Any help from anyone would be appreciated.

 local cloud3 = display.newRect(0,0,75,25) cloud3.x = 100 cloud3.y = display.screenOriginY+50 cloud3.alpha = 1 local function trans1() local function trans2() transition.to(cloud3, {time=8000,xScale=1.1, yScale=1.1 ,onComplete=trans1}) end transition.to(cloud3, {time=8000,xScale=.85, yScale=.85, onComplete=trans2}) end trans1()

Try that out.

I have tried this on an image object and with a slight bit of tweaking it works silky smooth.

Thank you very much Panc :slight_smile: I’m a happy chappy.

As a side note, after seeing this my original test values must have been way too large since even at 1.5 scaling within your code my current image fills a third of the display size.

I’d love to see what you tried to get this to work. My code doesn’t relate to sine waves so perhaps that was your problem.

If you want to scale dynamicaly use .xScale and .yScale properties not object:scale().
Second one scales image and ‘saves’ scaled version in memory so after few operation smoothnes can be degradated. Using properties will always scale original one before displaying, keeping original intact.

Reply for Panc,

The sine wave code I used (I don’t know about my tutor’s code), as an example, rotated circles on a sine wave. So eg. instead of just going up and down, it gave you the impression of going in and out as well. As I said, unfortunately, I deleted the code (last week), but whilst using it I checked (using print) the values coming out of it to see if I could use it to test smooth scaling of an object.

As you already know, an objects scale is 1, anything less scales the object down, and 2 is 200% scaling, so I new I had to use small values to make this work. The sine wave was chucking out values up to 680, so I had to adapt the code to scale this value down to an acceptable level. In the end, even with a lot of tweaking we had the same problem as indicated above. So we went on to other things. But now you have shown us it is possible with Corona, the skys the limit :slight_smile:

Thanks piotrz55, that clears up a bit of ambiguity from reading the documentation.

Just to clarify, for anyone else who reads this, what you are saying is that:

object:scale saves the scaled image to memory therefore overwriting the original. So the end result when you scale back up after using this a few times is that the smaller scaled image will be scaled up (not the original larger image) resulting in a degraded and less sharp looking image.

So using object.xScale and object.yscale properties is the best solution as it references the original image at all times, so therefore there is no image degradation.