3 Replies Latest reply on Feb 19, 2009 9:29 AM by Applied CD

    Scaling rectangles making my head hurt…

    Applied CD Level 1
      I’ve got four rectangles: the main stage, a sprite (an LDM), the stage within the LDM, and a boundingRect of objects within the LDM (so the coordinates are relative to the LDM stage, not the main stage). I need a transform (scale, rotate, and translate) that when applied to the LDM sprite produces a best fit between the boundingRect within the LDM and the main stage. The rotation will either be 0 or 90. The following code gets the scale and rotation but I’m having trouble figuring out the translation once a scale has been applied. It looks like the map() method should help but so far I haven’t been able to make use of it.
        • 1. Re: Scaling rectangles making my head hurt…
          James Newton, ACP Level 3
          Could you post an annotated sketch of the various rectangles? It would help if you could give a couple of examples of how you imagine the input rect and the output rect will look.
          • 2. Re: Scaling rectangles making my head hurt…
            Applied CD Level 1
            I’m sure I’ll get this if I just work through it methodically but maybe someone will beat me to it. The following two links show the pre-scale and post-scale arrangement of rectangles drawn at 25% scale. Some notes:
            The small colored boxes represent sprites within the LDM.
            The bounding box around these sprites is calculated on the fly (the sprites are positioned by the user)
            The main stage size is fixed.
            The LDM sprite starting size is fixed but its position on the main stage is not (it can be scrolled by the user).
            The LDM sprite must be scaled, rotated, and translated such that the bounding box (which scales within the LDM) achieves a best fit on the main stage.

            http://www.appliedcd.com/FTP-Guest/pre_scale.jpg
            http://www.appliedcd.com/FTP-Guest/post_scale.jpg

            PS: <soapbox>It would be nice if Adobe enabled inline picts or attachements. There have been a couple of times when I thought an illustration would help.</soapbox>
            • 3. Re: Scaling rectangles making my head hurt…
              Applied CD Level 1
              Bah, my bad. I figured this out except for the rotation and suddenly realized it wasn’t the best approach at all. The ultimate goal is to print the objects within the LDM but not include the empty space using Print-o-matic’s printStage method. Instead of a complex transform to scale the LDM to the stage and loosing tons of print resolution in the process, it’s much easier to resize the stage to match the bounding box, then move the LDM so the bounding box is centered on the stage. Print-o-matic will automatically handle the scaling and paper orientation for best fit based on the paper size. Once the print job is done just put everything back the way it was, print problem solved and no rectangles to worry about.