Skip to content

Instantly share code, notes, and snippets.

@patsma
Created October 24, 2019 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patsma/94afdbbf4b8eb46d9a9d9dee5ec3316a to your computer and use it in GitHub Desktop.
Save patsma/94afdbbf4b8eb46d9a9d9dee5ec3316a to your computer and use it in GitHub Desktop.
var element = document.querySelector(prompt('Insert the querySelector to the svg element.', '#gear'));
var bbox = element.getBBox(),
x = bbox.x,
y = bbox.y,
w = bbox.width,
h = bbox.height
;
var result =
'center center' + "\n" +
(x + (w / 2)) + 'px ' +
(y + (h / 2)) + 'px;' +
"\n" +
"\n" +
'top left' + "\n" +
x + 'px ' +
y + 'px;' +
"\n" +
"\n" +
'top right' + "\n" +
(x + w) + 'px ' +
y + 'px;' +
"\n" +
"\n" +
'bottom right' + "\n" +
(x + w) + 'px ' +
(y + h) + 'px;' +
"\n" +
"\n" +
'bottom left' + "\n" +
x + 'px ' +
(y + h) + 'px;' +
"\n"
;
alert(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment