SVG <image, <rect anchor?

Discuss SVG code, accessible via the XML Editor.
Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

SVG <image, <rect anchor?

Postby Vectorator » Wed Mar 18, 2015 2:05 pm

Is there any way to anchor images and rects by the centre, as you can with text?
ie. text-anchor:middle;

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: SVG <image, <rect anchor?

Postby brynn » Wed Mar 18, 2015 3:20 pm

I probably shouldn't even try to answer, since I'm not very familiar with SVG/XML code. But my simple answer might lead you to discover the answer.

On the canvas, objects can be aligned in many different ways. They don't have anchors like text does. Have you looked at any tutorials? I was just helping to create the new page on the website About SVG and found quite a few tutorials on SVG/XML code -- many more than we could list there! (I found them by using "learn" and "SVG", together (without any boolean) in a search engine :D)

Vectorator
Posts: 96
Joined: Tue Oct 21, 2014 1:40 pm
Location: Australia

Re: SVG <image, <rect anchor?

Postby Vectorator » Wed Mar 18, 2015 4:45 pm

Hello,

Yes I have read tutorials and couldn't find anything.

Although this answer seems to confirm that there isn't anything unfortunately.
http://stackoverflow.com/questions/1972 ... -attribute

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: SVG <image, <rect anchor?

Postby Lazur » Wed Mar 18, 2015 10:08 pm

You can enable snapping to bounding boxes, and to their centres.

But to preserve the position in the codes, is a different problem.
Paths are described by node positions, related to a coordinate system.
By that, the origo could be considered as an anchor (?).
Thus you would need to preserve transformation values that would shift the origo to the objects bounding box centres?
It could be done I guess, though it would lead to a more complicated structure.

An ugly solution would be converting the objects to markers and assigning them to path starting nodes in position.


Return to “SVG / XML Code”