[solved] Rotate rectangle to same angle as another object

Post questions on how to use or achieve an effect in Inkscape.
User avatar
Grobe
Posts: 411
Joined: Tue Feb 02, 2010 2:20 am

[solved] Rotate rectangle to same angle as another object

Postby Grobe » Tue Apr 05, 2011 2:56 am

Hi.

I have a map as background image (locked layer) and put text on it. To make the text more visible, I draw a rectangle with colored sides and white background. White background being about 50-70 percent transparent. So far so good, and it looks good too :D

So to the question (this lead to understand the question, I hope). I find myself often drawing text before rectangle, and sometimes I put the text along a river (on the map) and rotate that text so it lines up to the river. When I put the rectangle on the text, I seldom get it rotated properly so it has exact same direction as the text. I always misses by a degree or two.

The workarounds I have found so far:
  • Ctrl+Shift+X to open XML editor. Select the Transform attribute (ref as Tatt hereafter) and delete it. Do this with both text and rectangle, and then align them to center of each other, first vertically then horisontally. Group them, rotate them and try align them to the river again.
  • XML editor for text. (Assumes both text and rectangle is rotated a bit at least, otherwise Transform mttribute might not appear.)
    Select Tatt and copy. Close XML editor. Select rectangle, open XML Editor, select Tatt and paste the value. The rectangle will now be rotated exactly the same degrees as the text. Then use the Align/distribute and do a "Center on horisontal axis" and a "Center on vertical axis" to the text/rectangle. Done.

Is there a more efficient method to achieve this? To make two objects being rotated exactly the same?


Thanks
Last edited by Grobe on Thu Apr 07, 2011 5:00 am, edited 1 time in total.
:lol:

User avatar
hellocatfood
Posts: 193
Joined: Fri Aug 29, 2008 8:49 pm
Contact:

Re: Rotate rectangle to same angle as another object

Postby hellocatfood » Tue Apr 05, 2011 5:36 am

I can't find a way to do this unfortunately but I did come across a reason why this is. When you transform an object in Inkscape via the handles it converts this into a matrix() instead of using scale() and rotation() etc.

Here's two bug reports you should follow to find updates on when this is fixed:
bug 171826
bug 179309
I'm on The Web | Flickr | tumblr

User avatar
Grobe
Posts: 411
Joined: Tue Feb 02, 2010 2:20 am

Re: Rotate rectangle to same angle as another object

Postby Grobe » Tue Apr 05, 2011 5:48 am

hellocatfood wrote:Here's two bug reports you should follow to find updates on when this is fixed:
bug 171826
bug 179309
Hi. The first one where more relevant. Thank you.
:lol:

User avatar
RobA
Posts: 335
Joined: Fri Aug 10, 2007 1:22 am

Re: Rotate rectangle to same angle as another object

Postby RobA » Wed Apr 06, 2011 4:10 am

You can use Object to guides (on a duplicate) to get a set of guidelines that will tell you the angle that can be manually applied using the Object Transform dialog and typing in the angle.

If you are more visual, use Object to Guides to make guidelines and then draw a horizontal line under the text and group it with the text. You can then (with node snapping on) move the rotation center of the group to one endpoint of the guideline, grad the group to snap on the guideline, then rotate the group to snap the other end to the guideline.

-Rob A>

User avatar
Grobe
Posts: 411
Joined: Tue Feb 02, 2010 2:20 am

Re: Rotate rectangle to same angle as another object

Postby Grobe » Wed Apr 06, 2011 5:43 am

RobA wrote:You can use Object to guides (on a duplicate) to get a set of guidelines that will tell you the angle that can be manually applied using the Object Transform dialog and typing in the angle.
Hi. Don't work. I get the angle to the relationship between bounding box width/height. The angle of text doesn't have the same angle.

RobA wrote:If you are more visual, use Object to Guides to make guidelines and then draw a horizontal line under the text and group it with the text. You can then (with node snapping on) move the rotation center of the group to one endpoint of the guideline, grad the group to snap on the guideline, then rotate the group to snap the other end to the guideline.
Hi. The whole point of this is to let the text stay untouched.
:lol:

User avatar
RobA
Posts: 335
Joined: Fri Aug 10, 2007 1:22 am

Re: Rotate rectangle to same angle as another object

Postby RobA » Wed Apr 06, 2011 10:05 am

Grobe wrote:
RobA wrote:You can use Object to guides (on a duplicate) to get a set of guidelines that will tell you the angle that can be manually applied using the Object Transform dialog and typing in the angle.
Hi. Don't work. I get the angle to the relationship between bounding box width/height. The angle of text doesn't have the same angle.

RobA wrote:If you are more visual, use Object to Guides to make guidelines and then draw a horizontal line under the text and group it with the text. You can then (with node snapping on) move the rotation center of the group to one endpoint of the guideline, grad the group to snap on the guideline, then rotate the group to snap the other end to the guideline.
Hi. The whole point of this is to let the text stay untouched.


Sorry - I thought you were creating the rectangle first and wanted the text to align with it.

P.S. What kind of maps are you making?

-Rob A>

User avatar
Grobe
Posts: 411
Joined: Tue Feb 02, 2010 2:20 am

Re: Rotate rectangle to same angle as another object

Postby Grobe » Thu Apr 07, 2011 1:36 am

RobA wrote:P.S. What kind of maps are you making?

-Rob A>
Bitmaps files in background layer.
:lol:

User avatar
druban
Posts: 1917
Joined: Fri Nov 20, 2009 10:48 pm

Re: Rotate rectangle to same angle as another object

Postby druban » Thu Apr 07, 2011 3:26 am

The key here is to note that Inkscape lets you snap to text baseline.

1. Pull a guide out and snap the guide node to text baseline.
2. Shift drag rotates the guide, snap it to the bottom of the text.
3. Draw a rectangle from the guide (or snap the corner to the guide after drawing), and drag the rotation center to the corner that is snapped.
4. Rotate the rectangle and snap the other bottom corner to the guide. Now the text and rectangle are parallel.
IMPORTANT: PLEASE READ ~SUV's COMMENT FOLOWING THIS POST REGARDING ROTATION SNAPPING.
(Thanks for catching that, ~s)
Without rotation snapping you will have to align by eye, which is quite acceptable in this particular context, since the lines will be right on each other.
5. Move the rectangle control handles to get the right size. Since neither the text or the rectangle has been converted to paths they retain all their editability. In particular the rectangle can be resized at exactly the same angle of rotation.
Hope this gives you the desired result.
g3362.png
g3362.png (175.4 KiB) Viewed 3604 times


Off topic:
Another way to make text stand out in a map is to give it a thick stroke of translucent white, which has much the same effect as the translucent rectangle, but allows the text to be curved along a path for rivers, mountain ranges etc...
Last edited by druban on Thu Apr 07, 2011 3:57 am, edited 5 times in total.
Your mind is what you think it is.

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Rotate rectangle to same angle as another object

Postby ~suv » Thu Apr 07, 2011 3:36 am

druban wrote:4. Rotate the rectangle and snap the other bottom corner to the guide. Now the text and rectangle are parallel.

Please do not forget to mention that snapping nodes while rotating is only available in unstable development builds, but not in the stable Inkscape 0.48.x versions. Not everybody here prefers to or can work with the latest development builds, and will be frustrated if these steps don't work in their installed Inkscape.

User avatar
Grobe
Posts: 411
Joined: Tue Feb 02, 2010 2:20 am

Two solution possible

Postby Grobe » Thu Apr 07, 2011 4:44 am

Thanks Druban, I got it to work now :D

You remember the first method I told about? Copying the transform attribute text. And that I struggled with the objects often moved far out of the canvas. I got a dead simple solution for that too, actually.
I noticed that after a transform attribute was saved, the object was still selected. So I can simply Shift+click the other object (text), get the Align dialog box, select Relative to = Last selected and then just do the center alignment.

I use this tripple alignment so often that If I was able to program I would have writed an extension that would first copied the transform attribute from first to second object and then do a vertical+horisontal alignment.
:lol:


Return to “Help with using Inkscape”