Forums > Javascript

Getting jsui's width

October 1, 2008 | 8:03 am

Hello,

Documentation for the Sketch object uses the "aspect" variable.

However when I want to use it in a personal script I get a "aspect
is not defined" error message.

I have been using the following code to define my jsui’s width but
isn’t there an easier way to get it?

my_rect = this.box.rect;
width = my_rect[2] – my_rect[0];
height = my_rect[3] – my_rect[1];
aspect = width/height;

Thank you in advance.

Roald Baudoux


October 1, 2008 | 8:16 am

On 1 oct. 08, at 10:03, Roald Baudoux wrote:

> I have been using the following code to define my jsui’s width but
> isn’t there an easier way to get it?
>
> my_rect = this.box.rect;
> width = my_rect[2] – my_rect[0];
> height = my_rect[3] – my_rect[1];
> aspect = width/height;

This is what I use, very close to yours and not much easier…

var width = box.rect[2] – box.rect[0];
var height = box.rect[3] – box.rect[1];

aspect = width/height;

What’s the problem with your code?

_____________________________
Patrick Delges

Centre de Recherches et de Formation Musicales de Wallonie asbl

http://www.crfmw.be/max


October 1, 2008 | 9:43 am


Viewing 3 posts - 1 through 3 (of 3 total)