Reversing an SVG Path
Asked Answered
Z

3

7

Is there a simple method for reversing an SVG path? How can I make this start at the top left, rather than the bottom right?

<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="548.9px" height="620px" viewBox="0 0 548.9 620" xml:space="preserve">
    <path d="M305.3,461.7c-13.6,2.2-66,1.3-99.6-21.9c-77.4-53.3-42.5-147.1-95.4-204.1c-42.2-45.6-98-59.2-60-131.7"/>
</svg>
Zany answered 19/1, 2016 at 3:20 Comment(1)
transform="scale(-1,-1)" perhaps. You'll need a translae too though.Internationalism
W
17

Use Inkscape:

  1. Open this svg file in Inkscape.
  2. select the path
  3. click Menu -> Path -> Reverse
  4. save the file or open the xml editor in Inkscape to find the new path data.

Or use javascript. get and reverse each path segment.

Willams answered 19/1, 2016 at 9:37 Comment(2)
almost the same in Sketch )Crone
in order to open the XML editor click on Edit > XML EditorHeliotrope
S
12

You can use svgpathtools.

from svgpathtools import parse_path
path = parse_path("M305.3,461.7c-13.6,2.2-66,1.3-99.6-21.9c-77.4-53.3-42.5-147.1-95.4-204.1c-42.2-45.6-98-59.2-60-131.7")

print(path.reversed().d())
Stanwin answered 10/7, 2016 at 22:5 Comment(0)
I
1

If you use Figma, you can paste the SVG as "vector", then right-click and choose "Flip Horintally" or "Flip Vertically" (can be both).

Ignaciaignacio answered 26/10, 2023 at 14:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.