Skip to content

Commit

Permalink
ADD: support for S letter command
Browse files Browse the repository at this point in the history
  • Loading branch information
ldevillez committed Sep 24, 2024
1 parent 53c28dc commit 62067a2
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## [Unreleased]

### Added
- Adding support for the S command letter in svg
### Changed
### Deprecated
### Removed
Expand Down
3 changes: 2 additions & 1 deletion svg2tikz/tikz_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -1124,8 +1124,9 @@ def convert_path_to_tikz(self, path):
s += f" -- {self.coord_to_tz(tparams[0])}"

# cubic bezier curve
elif letter == "C":
elif letter in ["C", "S"]:
s += f".. controls {self.coord_to_tz(tparams[0])} and {self.coord_to_tz(tparams[1])} .. {self.coord_to_tz(tparams[2])}"
# s_point = 2 * tparams[2] - tparams[1]

# quadratic bezier curve
elif letter == "Q":
Expand Down
7 changes: 7 additions & 0 deletions tests/test_complete_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,13 @@ def test_arc_direction(self):
# Exemple taken from svg of the flag of the state of California
filename = "R_letter_with_arc"
create_test_from_filename(filename, self)
c

def test_arc_direction(self):
"""Test svg with S command inside it"""
# Exemple taken from svg of the flag of the state of California
filename = "s_command_letter"
create_test_from_filename(filename, self)


if __name__ == "__main__":
Expand Down
62 changes: 62 additions & 0 deletions tests/testfiles/s_command_letter.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions tests/testfiles/s_command_letter.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\begin{document}
\definecolor{cff5555}{RGB}{255,85,85}
\definecolor{c003cff}{RGB}{0,60,255}


\def \globalscale {1.000000}
\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt]
\path[fill=cff5555] (6.6514, -0.2902).. controls (6.6119, -0.2902) and (6.5775, -0.2762) .. (6.5487, -0.2479).. controls (6.5199, -0.2196) and (6.5053, -0.1852) .. (6.5053, -0.1442).. controls (6.5053, -0.1032) and (6.5199, -0.0709) .. (6.5487, -0.0426).. controls (6.5775, -0.0143) and (6.6119, 0.0) .. (6.6514, 0.0).. controls (6.6908, 0.0) and (6.7265, -0.0143) .. (6.754, -0.0426).. controls (6.7815, -0.0709) and (6.7956, -0.1048) .. (6.7956, -0.1442).. controls (6.7956, -0.1836) and (6.7818, -0.2196) .. (6.754, -0.2479).. controls (6.7265, -0.2762) and (6.6921, -0.2902) .. (6.6514, -0.2902) -- cycle(6.5429, -1.4923) -- (6.5429, -0.5054) -- (6.7598, -0.5054) -- (6.7598, -1.4923) -- cycle;



\path[fill=c003cff] (6.6514, -0.2902).. controls (6.6119, -0.2902) and (6.5775, -0.2762) .. (6.5487, -0.2479).. controls (6.5199, -0.2196) and (6.5053, -0.1852) .. (6.5053, -0.1442).. controls (6.5053, -0.1032) and (6.5199, -0.0709) .. (6.5487, -0.0426).. controls (6.5775, -0.0143) and (6.6119, -0.0) .. (6.6514, -0.0).. controls (6.6908, -0.0) and (6.7265, -0.0143) .. (6.754, -0.0426).. controls (6.7815, -0.0709) and (6.7956, -0.1048) .. (6.7956, -0.1442).. controls (6.7956, -0.1836) and (6.7818, -0.2196) .. (6.754, -0.2479).. controls (6.7265, -0.2762) and (6.6921, -0.2902) .. (6.6514, -0.2902) -- cycle;




\end{tikzpicture}
\end{document}

0 comments on commit 62067a2

Please sign in to comment.