Determining dimensions of a layer

Jun 9, 2012 at 12:12pm

Determining dimensions of a layer

Dear Developers,

I’m wondering about your opinions on how to properly set a layer’s dimensions. My trouble is that jbox start layer expects me to tell the width and height of my future layer in advance (so, before starting to actually draw it), however, since I’m having quite complex stuff on my layer, it is really hard to guess the width and height of the full image in advance.

I have both ideas, but both of them have serious drawbacks. One solution would be to set the width and height values to +inf (or, if that doesn’t work for some reason, then some extemely huge number), which doesn’t sound to be very efficient. My other idea would be to actually compute the exact size of the layer in advance, which would probably take ages to implement (the image on the layer is built by a user-defined sequence of user-defined drawing commands, so if I wanted to compute the size of the image in advance, I would need to analyse each drawing command one after the other, taking into consideration all rotations etc, which is a tremendous work).

I could also imagine that first I would draw the image as a single path on an invisible layer with infinite boundaries, then somehow I would compute the path size (which I’m not sure how I could do — is there an API command to determine the surrounding box of a path? I didn’t find one until now…), and then I would create my actual layer based on the values that I got this way. However, my guess is that this solution would be super-CPU-consuming…

Is there some useful technique which you would recommend for defining the layer dimensions in such a scenario?

Thanks,
Ádám

#48595

You must be logged in to reply to this topic.