From 3c52e41235b5121fe6b5b744eb13a5af3ec7917c Mon Sep 17 00:00:00 2001 From: ldevillez Date: Tue, 28 Nov 2023 10:21:49 +0100 Subject: [PATCH] FEAT: scaling of nodes --- CHANGELOG.md | 1 + svg2tikz/tikz_export.py | 4 ++-- tests/test_tikz_path_exporter.py | 4 ++-- tests/testfiles/blocs_and_groups.tex | 2 +- tests/testfiles/circle.tex | 2 +- tests/testfiles/circle_verbose.tex | 2 +- tests/testfiles/curves.tex | 2 +- tests/testfiles/display_none_in_group.tex | 2 +- tests/testfiles/ellipse.tex | 2 +- tests/testfiles/image.tex | 2 +- tests/testfiles/line.tex | 2 +- tests/testfiles/lines_style.tex | 2 +- tests/testfiles/pentagone_round_corner.tex | 2 +- tests/testfiles/polylines_polygones.tex | 2 +- tests/testfiles/rectangle.tex | 2 +- tests/testfiles/rectangle_wrap.tex | 2 +- tests/testfiles/switch_simple.tex | 2 +- tests/testfiles/symbol_and_use.tex | 2 +- tests/testfiles/text.tex | 2 +- tests/testfiles/text_fill_color.tex | 2 +- tests/testfiles/transform.tex | 2 +- 21 files changed, 23 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e63cfc7..eee9817 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Adding dev dependencies group in the pyproject.toml - Adding autodoc to generate code doc - Adding example section in the doc +- Adding scaling on nodes ### Changed - Using style from new inkex - Using path from new inkex diff --git a/svg2tikz/tikz_export.py b/svg2tikz/tikz_export.py index b2330d8..a9eb8b8 100644 --- a/svg2tikz/tikz_export.py +++ b/svg2tikz/tikz_export.py @@ -216,7 +216,7 @@ def filter_tag(node): %(gradientcode)s \def \globalscale {%(scale)f} \begin{tikzpicture}[y=1%(unit)s, x=1%(unit)s, yscale=%(ysign)s\globalscale,""" - r"""xscale=\globalscale, inner sep=0pt, outer sep=0pt%(extraoptions)s] + r"""xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt%(extraoptions)s] %(pathcode)s \end{tikzpicture} \end{document} @@ -229,7 +229,7 @@ def filter_tag(node): %(gradientcode)s \def \globalscale {%(scale)f} \begin{tikzpicture}[y=1%(unit)s, x=1%(unit)s, yscale=%(ysign)s\globalscale,""" - r"""xscale=\globalscale, inner sep=0pt, outer sep=0pt%(extraoptions)s] + r"""xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt%(extraoptions)s] %(pathcode)s \end{tikzpicture} """ diff --git a/tests/test_tikz_path_exporter.py b/tests/test_tikz_path_exporter.py index 41857ad..88cad12 100644 --- a/tests/test_tikz_path_exporter.py +++ b/tests/test_tikz_path_exporter.py @@ -194,7 +194,7 @@ def test_effect(self): \def \globalscale {0.800000} -\begin{tikzpicture}[y=1mm, x=1mm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1mm, x=1mm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \end{tikzpicture} \end{document} @@ -230,7 +230,7 @@ def test_convert(self): \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=blue,line width=0.02cm] (0.01, 3.99) rectangle (11.99, 0.01); diff --git a/tests/testfiles/blocs_and_groups.tex b/tests/testfiles/blocs_and_groups.tex index d999366..05ab142 100644 --- a/tests/testfiles/blocs_and_groups.tex +++ b/tests/testfiles/blocs_and_groups.tex @@ -11,7 +11,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \begin{scope}[cm={ 1.3333,-0.0,-0.0,-1.3333,(0.0, -36.301)}] \begin{scope}[cm={ 0.3225,-0.0,-0.0,0.3225,(5.3871, -49.2583)}] \begin{scope}[shift={(-11.1595, -11.4859)}] diff --git a/tests/testfiles/circle.tex b/tests/testfiles/circle.tex index 81aed3c..e60366f 100644 --- a/tests/testfiles/circle.tex +++ b/tests/testfiles/circle.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=black,line cap=,line width=0.2cm] (2.7319, 26.8727) circle (2.2948cm); diff --git a/tests/testfiles/circle_verbose.tex b/tests/testfiles/circle_verbose.tex index 0e5f110..a93bf36 100644 --- a/tests/testfiles/circle_verbose.tex +++ b/tests/testfiles/circle_verbose.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \begin{scope}[]%% layer1 %path1573 \path[draw=black,line cap=,line width=0.2cm] (2.7319, 26.8727) circle (2.2948cm); diff --git a/tests/testfiles/curves.tex b/tests/testfiles/curves.tex index 5a09fb7..56732ef 100644 --- a/tests/testfiles/curves.tex +++ b/tests/testfiles/curves.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=black,line cap=butt,line join=miter,line width=0.0265cm] (0.2646, 3.8353) .. controls (1.7639, 5.07) and (3.2632, 5.07) .. (4.7625, 3.8353); diff --git a/tests/testfiles/display_none_in_group.tex b/tests/testfiles/display_none_in_group.tex index 7dc8c62..5b5b6c2 100644 --- a/tests/testfiles/display_none_in_group.tex +++ b/tests/testfiles/display_none_in_group.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=red,fill=red,opacity=0.7,draw opacity=0.9925,line width=0.1502cm,rounded corners=1.5536cm] (5.0181, 25.6783) rectangle (10.8699, 21.1104); diff --git a/tests/testfiles/ellipse.tex b/tests/testfiles/ellipse.tex index fa9d124..45fa906 100644 --- a/tests/testfiles/ellipse.tex +++ b/tests/testfiles/ellipse.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=black,fill opacity=0.1632,line width=0.1cm,miter limit=4.0] (3.0, 27.7) ellipse (2.0cm and 1.0cm); diff --git a/tests/testfiles/image.tex b/tests/testfiles/image.tex index 38b4c84..52af4a5 100644 --- a/tests/testfiles/image.tex +++ b/tests/testfiles/image.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] % Image image2668 not included. Base64 still not supported; diff --git a/tests/testfiles/line.tex b/tests/testfiles/line.tex index 135f117..e8edf1f 100644 --- a/tests/testfiles/line.tex +++ b/tests/testfiles/line.tex @@ -8,7 +8,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=cdddddd,line width=0.0529cm,miter limit=10.0] (0.0, 12.8058) -- (10.5833, 2.2225); diff --git a/tests/testfiles/lines_style.tex b/tests/testfiles/lines_style.tex index acb1544..7284619 100644 --- a/tests/testfiles/lines_style.tex +++ b/tests/testfiles/lines_style.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=black,line cap=butt,line join=miter,line width=0.1cm] (0.7578, 10.9077) -- (7.7347, 10.9077); diff --git a/tests/testfiles/pentagone_round_corner.tex b/tests/testfiles/pentagone_round_corner.tex index ffcf3db..a3586ea 100644 --- a/tests/testfiles/pentagone_round_corner.tex +++ b/tests/testfiles/pentagone_round_corner.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[fill] (6.4182, 11.8297).. controls (-3.346, 16.7118) and (3.1158, 4.2643) .. (4.7416, 15.0593).. controls (6.3675, 25.8543) and (-3.4739, 15.8623) .. (7.2951, 17.6519).. controls (18.0642, 19.4414) and (5.5201, 25.7135) .. (10.5499, 16.0245).. controls (15.5796, 6.3355) and (17.6684, 20.2038) .. (10.0079, 12.4262).. controls (2.3474, 4.6485) and (16.1824, 6.9476) .. (6.4182, 11.8297) -- cycle; diff --git a/tests/testfiles/polylines_polygones.tex b/tests/testfiles/polylines_polygones.tex index 50e2a41..ab46da4 100644 --- a/tests/testfiles/polylines_polygones.tex +++ b/tests/testfiles/polylines_polygones.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=black,fill,line join=round,line width=0.3cm,cm={ 4.7668,-0.0,-0.0,4.7668,(-18.2373, -115.945)}] (5.1, 29.7) -- (4.6, 30.0) -- (4.6, 29.4) -- (5.1, 29.7)-- cycle;; diff --git a/tests/testfiles/rectangle.tex b/tests/testfiles/rectangle.tex index 45c5676..593c7e4 100644 --- a/tests/testfiles/rectangle.tex +++ b/tests/testfiles/rectangle.tex @@ -9,7 +9,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=black,line cap=,line width=0.2cm] (0.7985, 28.9408) rectangle (5.0753, 27.1111); diff --git a/tests/testfiles/rectangle_wrap.tex b/tests/testfiles/rectangle_wrap.tex index 44805b8..ea84fdb 100644 --- a/tests/testfiles/rectangle_wrap.tex +++ b/tests/testfiles/rectangle_wrap.tex @@ -9,7 +9,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=black,line cap=,line width=0.2cm] (0.7985, 28.9408) rectangle (5.0753, 27.1111); diff --git a/tests/testfiles/switch_simple.tex b/tests/testfiles/switch_simple.tex index 3f84a92..83b98f4 100644 --- a/tests/testfiles/switch_simple.tex +++ b/tests/testfiles/switch_simple.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=black,miter limit=10.0] (3.2015, 5.5298) -- (1.2171, 5.5298) -- (1.2171, 4.3754); diff --git a/tests/testfiles/symbol_and_use.tex b/tests/testfiles/symbol_and_use.tex index 0abcb1d..aa0b740 100644 --- a/tests/testfiles/symbol_and_use.tex +++ b/tests/testfiles/symbol_and_use.tex @@ -8,7 +8,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=pink] (0.0, -0.2646) -- (2.1167, -0.2646)(0.2646, 0.0) -- (0.2646, -0.5292)(0.6615, 0.0) -- (0.6615, -0.5292)(1.0583, 0.0) -- (1.0583, -0.5292)(1.4552, 0.0) -- (1.4552, -0.5292)(1.8521, 0.0) -- (1.8521, -0.5292); diff --git a/tests/testfiles/text.tex b/tests/testfiles/text.tex index 2d872e3..945ae3d 100644 --- a/tests/testfiles/text.tex +++ b/tests/testfiles/text.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \node[line width=0.0265cm,anchor=south west] (text3) at (1.0, 28.7){Normal Text}; diff --git a/tests/testfiles/text_fill_color.tex b/tests/testfiles/text_fill_color.tex index d3414ed..b55b4f9 100644 --- a/tests/testfiles/text_fill_color.tex +++ b/tests/testfiles/text_fill_color.tex @@ -8,7 +8,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \node[anchor=south] (text2) at (3.385, 6.5697){Default}; diff --git a/tests/testfiles/transform.tex b/tests/testfiles/transform.tex index da63e99..489eadf 100644 --- a/tests/testfiles/transform.tex +++ b/tests/testfiles/transform.tex @@ -7,7 +7,7 @@ \def \globalscale {1.000000} -\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, every node/.append style={scale=\globalscale}, inner sep=0pt, outer sep=0pt] \path[draw=black,line cap=,line width=0.2cm] (1.0186, 28.5295) rectangle (3.3265, 26.2215);