Before I go off and try to reinvent the wheel, does anyone have a script

that will proportionally scale objects within a group relative to each

other?

Scott Rossi has answered his own question, but FWIW here's my similar approach 
to the same problem. It does not assume that the scaled group stays in the same 
location, but it does require that the intended new rectangle of the group (not 
just a scaling factor) be specified--e.g., "set the groupRect of pGroup to 
100,100,400,400"

David Epstein



on storeStartingGroupRects gID
-- load a custom property set of group id gID storing its rect and the rects of 
its members
  repeat with n = 1 to the number of controls in group id gID
    set the startingRects[n] of group id gID to the rect of control n of group 
id gID
  end repeat
  set the startingRects[0] of group id gID to the rect of group id gID
end storeStartingGroupRects


setProp groupRect r
-- target group's new rect is r; set its members' rects accordingly
  put the short id of the target into gID
  if the startingRects[0] of group id gID is not empty then
    repeat with n = 1 to the number of controls in group id gID
      set the rect of control n of group id gID to scaledRect(the 
startingRects[n] of group id gID,the startingRects[0] of group id gID,r)
    end repeat
  end if
end groupRect

function scaledRect rA,rB,rY
-- return a rectangle "rX" whose position and size relative to rY is the same 
as rA's position relative to rB
  repeat for each char k in "12"
    put comma & relativeF(item k of rA,item k of rY,item k+2 of rY,item k of 
rB,item k+2 of rB) after hold
  end repeat
  repeat for each char k in "34"
    put comma & relativeF(item k of rA,item k-2 of rY,item k of rY,item k-2 of 
rB,item k of rB) after hold
  end repeat
  return char 2 to -1 of hold
end scaledRect

function relativef q,e,g,p,r
-- return value "f" whose value relative to e and g is the same as q's value 
relative to p and r (rounded)
  return round(e+(q-p)/(r-p)*(g-e))
end relativeF
_______________________________________________
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to