Y
Y
yarovikov2019-01-22 12:18:19
JavaScript
yarovikov, 2019-01-22 12:18:19

How to add element inside svg via js and prevent it from scaling?

Hi all. I don't know how to do something.
There is an svg (scheme in one patch), where you need to add points with reference to the place so that they do not move anywhere when the scheme is scaled.
File example:

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 758.43 374.25">
  <rect x="220" y="200" width="50" height="50" rx="50" />
  <path d="M756.91 87.14c-0.87 0-1.63-0.48-2.47-0.63 -0.55-0.1-1.11-0.03-1.66-0.11 -1.64-0.25-0.9-1.06 0.32-1.24 0.63-0.09 1.31-0.32 1.93-0.33 0.76-0.02 1.56 0.42 2.26 0.69 0.43 0.17 1.23 0.36 1.13 0.97C758.33 87.05 757.35 87.14 756.91 87.14zM754.54 85.15c-0.43 0.23-2.49-0.03-2.61 0.52 -0.14 0.62 2.36 0.54 2.71 0.59 0.39 0.06 3.8 1.32 3.31-0.07C757.69 85.46 755.16 84.71 754.54 85.15zM607.1 213.35c-0.51 0.13 0.62 3.07 1.97 2.64C610.48 215.54 608.03 213.14 607.1 213.35zM609.04 215.69c-1.22 0.39-1.63-1.23-1.82-2.09C607.69 213.7 609.9 215.42 609.04 215.69zM341.19 103c0.84 0 2.32-2.12 1.23-2.16C341.73 100.82 340.56 103 341.19 103zM342.27 101.18c1.17-0.41-1.12 1.92-1.07 1.69C341.08 102.3 341.84 101.48 342.27 101.18zM730.04 279.97c-0.83-0.23-3.06 0.69-1.85 1.67C729.61 282.8 731.38 280.35 730.04 279.97zM729.68...

Accordingly, two questions:
1. How to make a fixed size rect regardless of the screen size?
2. What is the best way to add new rects to svg? And yes - inlining it is not an option, there is a size of hundreds of lines.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
RAX7, 2019-01-22
@weart

E
Eugene, 2019-01-22
@iamd503

one.

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 758.43 374.25" width="758px" height="374px">

2. inline

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question