0
Well, I have the following code by which I take the contents of the "d" attribute of a <path>
SVG, however, need updated coordinates after using scale
to increase the size of the drawing, because when I request to increase or decrease the scale, I have the same values as the initial coordinates.
<!doctype html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.xxx {
color:blue;
}
</style>
</head>
<body>
<svg>
<path id="xxx" d="M100,10 L150,10 L150,60"
style="stroke: #6666ff; stroke-width: 1px; fill: none;
marker-start: url(#markerCircle);
marker-end: url(#markerArrow);"
/>
</svg>
<script>
console.log(document.getElementById('xxx').getAttribute('d'));
document.getElementById('xxx').style.transform='scale(2)';
console.log(document.getElementById('xxx').getAttribute('d'));
</script>
</body>
</html>
Any hint!
Guy doesn’t know exactly the application there, but the interesting thing would be the SVG having a viewbox, and the
d
begin in0,0
of that viewbox, from there you make the Scale() of the SVG as a whole– hugocsl
Sorry for the delay. It’s just that the way you suggested it doesn’t fit because the
d
need to have freedom to be positioned in any position on the screen. There is no function that stores the coordinates of the<path>
the moment he is staggered?– Fernandes
Ai can’t say, but maybe you can put a svg on top of each other all with 100% of the height and width of the element that are overlapping, but I don’t know if it would help you in something, you can also lock the Transform-oringe in the top left for example to try to keep x y fixed in one place
– hugocsl
Hey, when I said whether there’s a function that stores the coordinates of the
<path>
when staggered, I meant the new value of the coordinates, because I want to be able to access the coordinates of the position of the drawing on the screen, after ascale
, understood? I mean, when I have:<path id="xxx" d="M100,10 L150,10 L150,60"
and usescale(5)
, for example, I want the coordinates of the drawing already in the new size. However, in the DOM, the value ofd
continues the initial.– Fernandes