defining SVG 'center point'

Discuss SVG code, accessible via the XML Editor.
doctorSpoc
Posts: 2
Joined: Sat Jan 05, 2013 6:04 am

defining SVG 'center point'

Postby doctorSpoc » Sat Jan 05, 2013 6:45 am

I'm creating SGV files that will be used as pins on an open streets map, map.

I need to set the center point/(0,0) at the bottom center so that the pin gets located at the right point on the map. The dev. doing the map part of this can offset the location to adjust for this but it means more computations (potentially 100s of pin points) and slower load times.

Terrence.

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: defining SVG 'center point'

Postby ragstian » Sat Jan 05, 2013 3:29 pm

Hi doctorSpoc

As a new Inkscape user; as far as I know there are no way to do this from Inkscape.
(Hopefully someone with more knowledge will "chime in" on this thread).
It is however fully possible to do this by modifying the SVG file manually or by a program.
To test I created a page 100x100 pixels in Inkscape and created a vertical arrow with the arrowhead at the bottom - midway across the page.
( Inkscape coordinates x=50 and y=0 ).
By editing the saved SVG file with a g-tag I "moved" the arrow to the lower left corner.
"<g> transform="translate(-50,-952.36218) </g>" (The -952 is a "leftover" from starting Inkscape with an A4 page)
Both arrows got the exact same data.
Image
For more info on SVG transforms see the spec; http://www.w3.org/TR/SVG/coords.html - scroll down to the Example NewCoordSys section
Be aware that the origin (0,0) of a SVG page is the upper left corner whereas the Inkscape screen (0,0) is the lower left corner.

Good Luck!
RGDS
Ragnar
Last edited by ragstian on Sat Jan 05, 2013 4:18 pm, edited 2 times in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: defining SVG 'center point'

Postby ragstian » Sun Jan 06, 2013 1:57 pm

Hi.

What happened to the original third post in this thread - the solution was far better than mine and now it's gone!!

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: defining SVG 'center point'

Postby ragstian » Sun Jan 06, 2013 4:03 pm

Hi Pilosopong Tasyo.
Off topic:
Hi ragstian. You were probably referring to my reply. I deleted it after realizing that my answer may have been totally irrelevant to the OP's problem. The first time I read it, I focused on the keywords "center point" skipping the other stuff, hence posting a technique/workaround I would use. I only noticed several hours later when I got back to the forum that the topic was posted under the SVG/XML Code sub-forum (totally different ballgame vis-a-vis to the Help with using Inkscape sub-forum), and re-reading the original post a few more times about pins and street maps gave me the impression that my advice was probably no good under the circumstance. So, I decided to remove it. :oops:

It's no biggie reposting my reply. Before I deleted it, I copied and saved it to my computer, along with the screencaps, for those "just in case" moments. I'm still not sure if it is relevant, though. So, if it doesn't help in addressing the OP's question, just ignore it. :?

This is quite funny! After reading your original reply with the ingenious workaround I came to the conclusion that my reply was irrelevant and looked for a way to delete it!
I figured it could not be deleted as it was not the last post on the thread.

Keep up the good work!
RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

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

Re: defining SVG 'center point'

Postby brynn » Sun Jan 06, 2013 9:38 pm

Off topic:
Not to take this topic too far off course, but you should be able to delete your own messages. Look for small to tiny X button right between the Edit and Report buttons. Maybe I only see it because of moderator permissions. But I'm pretty sure you can delete your own messages ;-)

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: defining SVG 'center point'

Postby ragstian » Mon Jan 07, 2013 1:57 am

Hi brynn.

This is what I see on my own posts: Image - no delete icon!
(If my message are the last one in a thread then the x is there.)

Out of curiosity; can you explain what the different icons to the left of the thread topic is supposed to show; Image
Some are black, some are red and some got "scrolling text", I have not been able to find any info on the board FAQ side about this.
Might be self-explanatory but my brain is not that good! (and never was!)

RGDS
Ragnar
Last edited by ragstian on Mon Jan 07, 2013 2:05 pm, edited 2 times in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

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

Re: defining SVG 'center point'

Postby brynn » Mon Jan 07, 2013 1:29 pm

Off topic:
Hi Ragnar,
Wow, I'm shocked! I thought a user could delete their own messages! Well, thanks for taking the time to explain that for me. Of course I once was a regular member too, but it's been awhile. I thought I recalled being able to delete my own messages. I think I'll ask microUgly about that, to see if it's possible to change that.

Actually PT, I don't think those things are configurable in this particular forum. Only one forum theme is available for everyone. This is my interpretation of those icons, since I can't find any convenient explanations either. I suspect they could be found at the phpBB forum site...somewhere.

The red icon indicates that there is at least one new message in that topic, since the last time you looked at it. You'll also see a tiny, mostly red square in front of the topic title, which I have no idea what it's supposed to be. But it's a link which will take you directly to the first message that you haven't read yet. If that icon has a red star in it, it means you have posted a message in that topic. No star means that you haven't replied to it.

The black icon means that there are no new messages since the last time you looked at it.
The scrolling one means that there are more than some number of replies. In other forum software, I've seen those "busy" or "hot" topics id'd by a flame.

PS - I don't know why the OT tags aren't working.

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

Re: defining SVG 'center point'

Postby brynn » Mon Jan 07, 2013 2:17 pm

Off topic:
I don't think Prosilver works -- OH! Well look at that! I tried it a few years ago, but it didn't work. I might have to use it for awhile! I'm getting tired of the orange :roll: .

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

Re: defining SVG 'center point'

Postby brynn » Mon Jan 07, 2013 2:25 pm

brynn wrote:
Off topic:
Hi Ragnar,
Wow, I'm shocked! ....

PS - I don't know why the OT tags aren't working.


Ah-HA! The OT tags don't work in the prosilver theme! So the prosilver theme must have some bugs, I guess. So oh well, back to the orange :lol:

doctorSpoc
Posts: 2
Joined: Sat Jan 05, 2013 6:04 am

Re: defining SVG 'center point'

Postby doctorSpoc » Tue Jan 08, 2013 5:16 am

Thanks for the help guys... much appreciated!

Using either of these two methods, how do I get the portion of the icon that is now outside of the "viewport" (?) to not get cut off when it gets displayed?

just a note, I'm a total newbie to this, so the more detail you can provide the better.

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

Re: defining SVG 'center point'

Postby brynn » Wed Jan 09, 2013 4:18 am

doctorSpoc wrote:Using either of these two methods, how do I get the portion of the icon that is now outside of the "viewport" (?) to not get cut off when it gets displayed?

Well, that was my concern from the very beginning, which is why I didn't reply to the original topic. Of course you can easily hide the page border (Doc Props). But in some situations, depending on how the image will either be used, or be displayed, only the parts of the image that lie within the border are visible, whether the border itself is visible or not. So if you need this to remain an SVG file, using 0,0 for the center of the drawing, there's no way to have the whole drawing inside the border.

If you were able to use a PNG though.... Of course with the border hidden, you can export the whole drawing, no matter where it lies on the page. I've never experimented with the x0, y0, x1, y1 settings. But it looks like you could adjust the export so that 0,0 is where you want it. Although note that I may not have the correct understanding of those settings....but without consulting the manual, that's what it looks like to me.

Or....I have no idea what are the requirements of the map guy. It sounds like maybe he's going to have a script, or some way of automating the placement of the pins, which he wants to define as 0,0. If there were some kind of manual placement as an option, perhaps some of Inkscape's snapping features (which recently have become quite sophisticated!) could be used to guide the placement. For example, "snapping to and from the midpoint of bounding box edges" is exactly what you're describing!

Or....well, if he is indeed using a script or something like it, couldn't he set the alignment coordinates to anything? I mean, if the code says "put the pin at (0,0)", couldn't he change that to "put the pin at (20,0)??

Ok, so there's a bit of brainstorming, for whatever it's worth :D


Return to “SVG / XML Code”