2 Replies Latest reply on Oct 19, 2010 8:30 AM by Joe.Charles

    Rotated rectangle with text frame inside

    Joe.Charles Level 1

      Hi all


      I have a graphic rectangle, and want to add a info text frame inside, adjusted at the whole top border:




              label.contents="some info";



      The problem is when the rectangle is rotated. It doesn´t fit fine, and get´s rotated itself.


      Any idea of how to do this work?



        • 1. Re: Rotated rectangle with text frame inside
          [Jongware] Most Valuable Participant

          The answer depends on what you'd want the text frame to do. If you place it not rotated but still with the same size as the rotated rectangle, it'll stick out.


          It doesn´t fit fine, and get´s rotated itself.


          You could set the rotation to the inverse of the rectangle rotation:


          label.absoluteRotationAngle = -imageItem.absoluteRotationAngle;


          or possibly set its own rotation to 0:


          label.rotationAngle = 0;


          (there ought to be a difference between the two, so maybe it's the other way around).


          The size difference comes from using the geometric bounds; these always describe a rectangle around the object, so for an unrotated rectangle it's the rectangle itself, but for a rotated one, the width will become cos(angle)*width+sin(angle)*height, and the inverse for the height -- don't quote me on that, it's from memory. You could try to do the reverse calculations -- but I think all that you can get is (width+height) -- or simply save the current angle, set it to 0, use geometricBounds, reapply the original angle.

          • 2. Re: Rotated rectangle with text frame inside
            Joe.Charles Level 1

            Hi Jongware


            For better understanding about what´s happening, I removed fit instruction, and result is this -both rectangles has a 30º rotation-



            Keeping geometric bounds instruction, text frame geometric bounds are completely different from rectangle ones (¿?).

            It seems like if the text frame has a shear angle, but it didn´t. I can´t understand what´s happening.


            One posibility is what you said: reset angle, reassign geometric bounds, and restore original angle, but I prefer to keep original item intact.