Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add example in the doc #171

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
- Adding failsafe for non defined sys.stdout.buffer
- Adding list of tikz color
- Adding dev dependencies group in the pyproject.toml
- Adding autodoc to generate code doc
- Adding example section in the doc
### Changed
- Using style from new inkex
- Using path from new inkex
Expand Down
1 change: 1 addition & 0 deletions docs/code/articulated_leg_calf.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\path[draw=black,fill=white,line cap=round,line width=0.01855cm] (1.16312, 2.92339).. controls (1.11279, 2.78068) and (1.04991, 2.51646) .. (1.02337, 2.33625).. controls (0.96993, 1.97341) and (0.97082, 1.97911) .. (0.89825, 1.54901).. controls (0.86234, 1.33618) and (0.8471, 1.11987) .. (0.8573, 0.94698).. controls (0.8717, 0.65971) and (0.75582, 0.39403) .. (0.61336, 0.33848).. controls (0.5881, 0.32863) and (0.56201, 0.32539) .. (0.52692, 0.3324).. controls (0.41144, 0.3555) and (0.1986, 0.48976) .. (0.20932, 0.93085).. controls (0.21981, 1.27003) and (0.20895, 1.6992) .. (0.14059, 2.02779).. controls (0.06794, 2.37699) and (0.11809, 2.64748) .. (0.25717, 2.97495).. controls (0.33005, 3.13468) and (0.62011, 3.25057) .. (0.78457, 3.28224).. controls (0.81705, 3.28849) and (0.84463, 3.29146) .. (0.8778, 3.28371).. controls (1.00433, 3.25413) and (1.21223, 3.06852) .. (1.16312, 2.92339);
3 changes: 3 additions & 0 deletions docs/code/articulated_leg_coordinate.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
\newcommand{\hipArt}{(1.3537, 6.2435)}
\newcommand{\kneeArt}{(1.3537, 3.3575)}
\newcommand{\ankleArt}{(1.0781, 0.6906)}
1 change: 1 addition & 0 deletions docs/code/articulated_leg_foot.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\path[draw=black,fill=white,line cap=round,line width=0.01855cm] (0.2806, 0.01255).. controls (1.80006, 0.0098) and (2.46455, -0.02931) .. (1.55022, 0.25983).. controls (1.46244, 0.28759) and (1.25302, 0.35957) .. (1.08461, 0.48791).. controls (0.96181, 0.56917) and (0.77457, 0.60981) .. (0.61801, 0.62088).. controls (0.58522, 0.6232) and (0.55379, 0.62422) .. (0.52323, 0.62148).. controls (0.4078, 0.61131) and (0.30498, 0.54812) .. (0.17596, 0.464).. controls (0.13929, 0.19854) and (-0.05827, 0.01311) .. (0.2806, 0.0125) -- cycle;
27 changes: 27 additions & 0 deletions docs/code/articulated_leg_recombine.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
\begin{center}
\tikzsetnextfilename{Test_articulated_leg}
\begin{tikzpicture}[y=1cm, x=1cm, inner sep=0pt, outer sep=0pt]


\input{joints_def}
\input{articulated_leg/torso}

\begin{scope}[rotate around={30:(hipArt)}]

\input{articulated_leg/thigh}
\begin{scope}[rotate around={-20:(kneeArt)}]

\input{articulated_leg/calf}
\begin{scope}[rotate around={10:(ankleArt)}]

\input{articulated_leg/feet}
\end{scope}
\draw[line width=0.018cm] (ankleArt) circle(0.05);
\end{scope}
\draw[line width=0.018cm] (kneeArt) circle(0.05);
\end{scope}
\draw[line width=0.018cm] (hipArt) circle(0.05);


\end{tikzpicture}
\end{center}
15 changes: 15 additions & 0 deletions docs/code/articulated_leg_simple.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
\path[draw=black,fill=white,line cap=round,line width=0.01855cm] (0.18996, 6.67363).. controls (0.16754, 6.59255) and (0.16587, 6.586) .. (0.15354, 6.54586).. controls (0.14121, 6.50572) and (0.12729, 6.46367) .. (0.11179, 6.41973).. controls (-0.02653, 6.02751) and (-0.05811, 5.5991) .. (0.22882, 5.29253).. controls (0.35169, 5.23787) and (1.0929, 5.23726) .. (1.51182, 5.37904).. controls (1.51506, 5.42205) and (1.51951, 5.47389) .. (1.52318, 5.52894).. controls (1.53178, 5.65804) and (1.53761, 5.77619) .. (1.53855, 5.88105).. controls (1.5442, 5.91233) and (1.54938, 5.96152) .. (1.55409, 6.02865).. controls (1.55881, 6.09577) and (1.56455, 6.22178) .. (1.56682, 6.28381).. controls (1.5691, 6.34584) and (1.5715, 6.42702) .. (1.57298, 6.4857).. controls (1.57446, 6.54439) and (1.57524, 6.58326) .. (1.57734, 6.68764) -- cycle;



\path[draw=black,fill=white,line cap=round,line width=0.01855cm] (0.23489, 5.24417).. controls (0.24789, 5.18345) and (0.24593, 5.08146) .. (0.24092, 4.8556).. controls (0.23326, 4.50973) and (0.24308, 4.39896) .. (0.30338, 4.15382).. controls (0.37273, 3.87191) and (0.3952, 3.62892) .. (0.36992, 3.40372).. controls (0.4783, 3.10227) and (0.64618, 3.01406) .. (0.79016, 2.99682).. controls (0.81982, 2.99327) and (0.84847, 2.99273) .. (0.87976, 2.99622).. controls (1.00951, 3.01079) and (1.18465, 3.09504) .. (1.25524, 3.32276).. controls (1.25549, 3.39971) and (1.27522, 3.4903) .. (1.29886, 3.52406).. controls (1.40255, 3.67209) and (1.44593, 3.92328) .. (1.46142, 4.46525).. controls (1.4467, 4.78798) and (1.53565, 5.45383) .. (1.53855, 5.88103).. controls (1.54563, 6.16964) and (1.11475, 6.17171) .. (0.90207, 6.17244).. controls (0.84398, 6.17264) and (0.80216, 6.17274) .. (0.7554, 6.17204).. controls (0.50573, 6.16816) and (0.115, 6.14067) .. (0.23489, 5.24417);



\path[draw=black,fill=white,line cap=round,line width=0.01855cm] (1.16312, 2.92339).. controls (1.11279, 2.78068) and (1.04991, 2.51646) .. (1.02337, 2.33625).. controls (0.96993, 1.97341) and (0.97082, 1.97911) .. (0.89825, 1.54901).. controls (0.86234, 1.33618) and (0.8471, 1.11987) .. (0.8573, 0.94698).. controls (0.8717, 0.65971) and (0.75582, 0.39403) .. (0.61336, 0.33848).. controls (0.5881, 0.32863) and (0.56201, 0.32539) .. (0.52692, 0.3324).. controls (0.41144, 0.3555) and (0.1986, 0.48976) .. (0.20932, 0.93085).. controls (0.21981, 1.27003) and (0.20895, 1.6992) .. (0.14059, 2.02779).. controls (0.06794, 2.37699) and (0.11809, 2.64748) .. (0.25717, 2.97495).. controls (0.33005, 3.13468) and (0.62011, 3.25057) .. (0.78457, 3.28224).. controls (0.81705, 3.28849) and (0.84463, 3.29146) .. (0.8778, 3.28371).. controls (1.00433, 3.25413) and (1.21223, 3.06852) .. (1.16312, 2.92339);



\path[draw=black,fill=white,line cap=round,line width=0.01855cm] (0.2806, 0.01255).. controls (1.80006, 0.0098) and (2.46455, -0.02931) .. (1.55022, 0.25983).. controls (1.46244, 0.28759) and (1.25302, 0.35957) .. (1.08461, 0.48791).. controls (0.96181, 0.56917) and (0.77457, 0.60981) .. (0.61801, 0.62088).. controls (0.58522, 0.6232) and (0.55379, 0.62422) .. (0.52323, 0.62148).. controls (0.4078, 0.61131) and (0.30498, 0.54812) .. (0.17596, 0.464).. controls (0.13929, 0.19854) and (-0.05827, 0.01311) .. (0.2806, 0.0125) -- cycle;


1 change: 1 addition & 0 deletions docs/code/articulated_leg_thigh.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\path[draw=black,fill=white,line cap=round,line width=0.01855cm] (0.23489, 5.24417).. controls (0.24789, 5.18345) and (0.24593, 5.08146) .. (0.24092, 4.8556).. controls (0.23326, 4.50973) and (0.24308, 4.39896) .. (0.30338, 4.15382).. controls (0.37273, 3.87191) and (0.3952, 3.62892) .. (0.36992, 3.40372).. controls (0.4783, 3.10227) and (0.64618, 3.01406) .. (0.79016, 2.99682).. controls (0.81982, 2.99327) and (0.84847, 2.99273) .. (0.87976, 2.99622).. controls (1.00951, 3.01079) and (1.18465, 3.09504) .. (1.25524, 3.32276).. controls (1.25549, 3.39971) and (1.27522, 3.4903) .. (1.29886, 3.52406).. controls (1.40255, 3.67209) and (1.44593, 3.92328) .. (1.46142, 4.46525).. controls (1.4467, 4.78798) and (1.53565, 5.45383) .. (1.53855, 5.88103).. controls (1.54563, 6.16964) and (1.11475, 6.17171) .. (0.90207, 6.17244).. controls (0.84398, 6.17264) and (0.80216, 6.17274) .. (0.7554, 6.17204).. controls (0.50573, 6.16816) and (0.115, 6.14067) .. (0.23489, 5.24417);
2 changes: 2 additions & 0 deletions docs/code/articulated_leg_torso.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

\path[draw=black,fill=white,line cap=round,line width=0.01855cm] (0.18996, 6.67363).. controls (0.16754, 6.59255) and (0.16587, 6.586) .. (0.15354, 6.54586).. controls (0.14121, 6.50572) and (0.12729, 6.46367) .. (0.11179, 6.41973).. controls (-0.02653, 6.02751) and (-0.05811, 5.5991) .. (0.22882, 5.29253).. controls (0.35169, 5.23787) and (1.0929, 5.23726) .. (1.51182, 5.37904).. controls (1.51506, 5.42205) and (1.51951, 5.47389) .. (1.52318, 5.52894).. controls (1.53178, 5.65804) and (1.53761, 5.77619) .. (1.53855, 5.88105).. controls (1.5442, 5.91233) and (1.54938, 5.96152) .. (1.55409, 6.02865).. controls (1.55881, 6.09577) and (1.56455, 6.22178) .. (1.56682, 6.28381).. controls (1.5691, 6.34584) and (1.5715, 6.42702) .. (1.57298, 6.4857).. controls (1.57446, 6.54439) and (1.57524, 6.58326) .. (1.57734, 6.68764) -- cycle;
60 changes: 60 additions & 0 deletions docs/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
Example
=======

Let's see together how to use SVG2Tikz to convert an SVG to tikz code and include it in your work. Let's take this svg of articulated_leg:

.. image:: img/articulated_leg.svg

It's composed of several paths:

* A torso
* A Thigh
* A Calf
* A Foot
* 3 articulation joints: Ankle, knee and hip

With the file open in inkscape, we can directly go into Extension/export/Export to tikz path. This open a new window with multiple options in serveral tabs.

.. image:: img/inkscape_example_articulated_leg.png

First we can check the option `Export to clipboard`. Then in the Tikz option we set to export only the pathcode as we do not need any particular color definition and that we will use this tex file in an another code. We click on apply and we get the following output:

.. literalinclude:: code/articulated_leg_simple.tex
:language: latex

We can create macro for each articulation:

.. literalinclude:: code/articulated_leg_coordinate.tex
:language: latex

We separate each path into its own file:

torso.tex:

.. literalinclude:: code/articulated_leg_torso.tex
:language: latex

thigh.tex:

.. literalinclude:: code/articulated_leg_thigh.tex
:language: latex

calf.tex:

.. literalinclude:: code/articulated_leg_calf.tex
:language: latex

foot.tex:

.. literalinclude:: code/articulated_leg_foot.tex
:language: latex


We can then recombine our svg with the following code:

.. literalinclude:: code/articulated_leg_recombine.tex
:language: latex

It allows us to control the angle between each member

.. image:: img/articulated_leg_angled.png
Loading