Page 1 of 1

Rube image x

Posted: Fri Sep 13, 2013 8:36 pm
by Rogerboy
So the images in rube have a height in world units which is for example 20 but what about the width in world units? how am I supposed to work this out? I cant figure out anything, for example images.json has the background image as height 20 and aspect 1, there does not seem to be a width variable.

Re: Rube image x

Posted: Sat Sep 14, 2013 3:46 am
by iforce2d
The width will depend on the dimensions of the image file. As an example, suppose the image file is 100 pixels wide, and 50 pixels high. This is an aspect ratio of 2:1, let's call this the 'natural' aspect ratio of the image.

If the image in the scene has a height in world units of 20 as you mention, then the width in world units would be 40, to keep the image at its natural aspect ratio of 2:1.

The 'aspectScale' property is not commonly used, but it allows you to stretch or squash the image, by adjusting the aspect ratio. For example, an aspectScale value of 2 would stretch the image to twice the normal width. For the example above, instead of using the natural ratio of 2:1 you would use 4:1 and the width of the image in world units would be 80.

Re: Rube image x

Posted: Sat Sep 14, 2013 4:24 pm
by Rogerboy
Thanks I understand it now,
To anyone wondering how to do this: http://www.digitalrebellion.com/webapps ... _calc.html
Get the ratio and times it by the height units.