Hi all,
I have a bunch of groups of class "screw", each comprised of a circle screwhead and a smaller square in the center called a screwsquare. In every instance of "screw", screwhead and screwsquare have identical x, y, height, width and r dimensions. Each screw's position is determined by the screw group's transform=translate(xadjust, yadjust). This is done automatically by Inkscape, and furthermore, it's easy to set manually with:
myElement.setAttribute('transform','translate(xadjust,yadjust)');
The trouble comes in when you want to *get* that transform. Getting the transform is necessary when you want to move element whatever2 in relation to the location of screw1. Getting the translation is one of the worst documented things I've seen, but the concensus seems to be something like the following (for my screw case where the group has the transform):
=============================================================== function screw_coords(screw){ matrix = screw.transform.baseVal.getItem(0).matrix; var coords = []; shead = screw.querySelector('.screwhead'); coords[0] = shead.cx.animVal.value + matrix.e; coords[1] = shead.cy.animVal.value + matrix.f; return(coords); } ===============================================================
The preceding is ugly and fragile for a whole number of reasons, it's inobvious and horribly undocumented. But the real problem is it appears to be deprecated:
https://developer.mozilla.org/en-US/docs/Web/API/SVGMatrix
The preceding article says not to use SVGMatrix, and to update code as soon as possible, but remains mute on what you use instead. How the hell do you read a translation? It's a mystery.
The following article gives a crazy train regex kludge method to read a translate:
https://stackoverflow.com/questions/10349811/how-to-manipulate-translate-tra...
If anybody knows the proper secret handshake to read a translate in a non-deprecated, browser independent, non-kludgificent way, please let me know, perhaps with some URLs of docs for such a functionality.
Thanks,
SteveT
Steve Litt May 2017 featured book: Twenty Eight Tales of Troubleshooting http://www.troubleshooters.com/28