Getting jsui's width

Oct 1, 2008 at 8:03am

Getting jsui's width

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

#40090
Oct 1, 2008 at 8:16am

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

#141508
Oct 1, 2008 at 9:43am

#141509

You must be logged in to reply to this topic.