
1. Re: create rectangle proportionally
Jump_Over Mar 25, 2014 1:39 AM (in response to Unique)Hi,
use resize() method like this:
mRectangle.resize( CoordinateSpaces.INNER_COORDINATES, AnchorPoint.BOTTOM_RIGHT_ANCHOR, ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY, [wFactor, hFactor]);
where wFactor and hFactor are calculated regarding to page resize
Jarek


3. Re: create rectangle proportionally
[Jongware] Mar 25, 2014 2:43 AM (in response to Unique)1 person found this helpfulHow is your math? http://en.wikipedia.org/wiki/Lineline_intersection tells you all you need to know (Or, it does after logically figuring out your construction.)
with (app.layoutWindows[0].activePage) x1 = Math.min(bounds[1],bounds[3]), y1 = Math.max(bounds[0],bounds[2]), x2 = Math.max(bounds[1],bounds[3]), y2 = .5*(bounds[0]+bounds[2]), x3 = x2, y3 = Math.max(bounds[0],bounds[2]), x4 = x31, y4 = y31; px = ((x1*y2y1*x2)*(x3x4)(x1x2)*(x3*y4y3*x4))/((x1x2)*(y3y4)(y1y2)*(x3x4)); py = ((x1*y2y1*x2)*(y3y4)(y1y2)*(x3*y4y3*x4))/((x1x2)*(y3y4)(y1y2)*(x3x4)); app.layoutWindows[0].activePage.rectangles.add({geometricBounds:[y3,x3,py,px],strokeWeight:1,strokeColor:app.activeDocument.swatches.item("Black")});

4. Re: create rectangle proportionally
Jump_Over Mar 25, 2014 3:00 AM (in response to Unique)Hi,
It changed, right, but by same factor as pages, I guess.
Check this with below code:
var changedPageSize = [130,170], lastPage = app.activeDocument.pages[1], currentPageSize = [ lastPage.bounds[3]  lastPage.bounds[1], lastPage.bounds[2]  lastPage.bounds[0] ], k, wFactor = changedPageSize[0]/currentPageSize[0], hFactor = changedPageSize[1]/currentPageSize[1], mPage = lastPage.duplicate(), mItems = mPage.pageItems.everyItem().getElements(); mPage.resize( CoordinateSpaces.INNER_COORDINATES, AnchorPoint.BOTTOM_RIGHT_ANCHOR, ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY, [wFactor, hFactor]); for (k = 0; k < mItems.length; k++) mItems[k].resize( CoordinateSpaces.INNER_COORDINATES, AnchorPoint.BOTTOM_RIGHT_ANCHOR, ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY, [wFactor, hFactor]);
Place your shapes at the last page and set new size in 1st line.
Compare it with new last page added by the code.
Jarek

5. Re: create rectangle proportionally
Marc Autret Mar 25, 2014 10:06 PM (in response to Unique)1 person found this helpfulHi people,
Unique wrote:
which should be proportionally, equally in size both widht and height  touch the graphic Line till the page width and height.
I'm afraid I didn't clearly understand the question but, according to your screenshots you seem to just want to draw a square (?) below the GraphicLine—with respect to size constraints.
Let W denotes the page width, H the half of the page height, and x the square edge.
The Intercept theorem (Thales) leads to x = ( W × H ) / ( W + H ).
From then you could easily create this shape at the bottom right corner. Here is a raw implementation (assuming uniform measurement units and no weird transformations applied):
var pg = app.layoutWindows[0].activePage, bs = pg.bounds, w = (bs[3]bs[1]), // page width h = (bs[2]bs[0])/2, // half of the page height x = (w*h)/(w+h); bs[0]=bs[2]x; bs[1]=bs[3]x; pg.rectangles.add({fillColor:'Black',geometricBounds:bs});
Am I wrong?
@+
Marc