Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Confused on creating a rectangle and validating its size & position afterwards

$
0
0

If one creates a rectangle in a layer like this:

 

var childLayer = parentLayer.pathItems.rectangle(top, left, someWidth, someHeight);
childLayer.stroked = false;
childLayer.filled = true;

 

After creating the rectangle, would one read it back like this:

 

var bounds = childLayer.geometricBounds;
alert("bounds: "+bounds[0]+","+bounds[1]+","+bounds[2]+","+bounds[3]);

 

or should I use visibleBounds, or controlBounds? Or something else?

 

I know if stroke not used or can exclude can use geometric bounds? Or rather all 3 bounds could be the same in that case?

 

I'm confused right now because I'm assuming the bounds represent the four corners of the rectangle's position in the document and when read back out, the values (bounds[0] and bounds[1]) don't match against the top & left values originally passed in to create the rectangle. Shouldn't they be the same?

 

If not, how am I supposed to validate that the layer/object uses the same top & left values for it's position as when the rectangle was created (for say validation purposes)?

 

Also I assume I should be able to fetch the position of one corner using childLayer.top& childLayer.left as well right? For some reason, that doesn't match with top & left either.


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>