dice.camp is one of the many independent Mastodon servers you can use to participate in the fediverse.
A Mastodon server for RPG folks to hang out and talk. Not owned by a billionaire.

Administered by:

Server stats:

1.7K
active users

Alien_Sunset

any SVG wizards here?

I'm having a problem, & I'm not sure how to fix it, & i just cannot find anything on
developer.mozilla.org/en-US/do
to help.

essentially I want to center a <g> within a larger <SVG> but the <g> is randomly generated so I do not know how wide it will be.

because of the platform its to go on, I can't use any outside scripts or JS or CSS/<div> etc.

help? nm see reply

{edit} glitch project for anyone who wants to poke it
( glitch.com/edit/#!/draft-inkle )

MDN Web DocsSVG: Scalable Vector Graphics | MDNScalable Vector Graphics (SVG) is an XML-based markup language for describing two-dimensional based vector graphics.

@Alien_Sunset
Speaking as an unemployed Linux-monkey, have you considered 300 lines of undocumented sed?

Or - better yet - one 3,000 character line of undocumented awk?

@Alien_Sunset
sed 's/undocumented/minified/g'

...there, much more professional!

@Alien_Sunset If you say it's randomly generated, what level of control do you have?

As in: do you know the value of the root's height and width attribute? It's viewBox?

What goes into the g element?

Trying to understand the scope a little better.

(I build web games in SVG as side projects)

@Alien_Sunset i learned SVG before there was much in the way of tooling so I'd do it with perl, but I'm guessing that's not the best answer nowadays. Maybe some kind of inkscape script? I don't even know if you can run those without opening the whole application gui, though?

@Alien_Sunset How much control do you have over the CSS itself? Can you edit it before it reaches the platform? Can you add `<style>` inside the SVG?

@Alien_Sunset hmm, thats indeed tricky! weird idea: do you have access to the svg header? maybe you can put a script tag in there that centers your group?