Which tikz tool can be used to create a tikz image from a image template? for example, I have a png file as below, I just want to create the same image with tikz. Maybe tool to load the image firstly, then draw on it to get tikz code, then remove the original image to get a tikz copy.
Asked
Active
Viewed 1,184 times
0
-
1No special "tool" (actually, what you mean with this?) is necessary. Just start to draw ... by help of TikZ & PGF manual this should not be difficult. If you will stuck in some detail, ask here, how to solve your problem. – Zarko Dec 30 '16 at 15:54
-
1Doing such things manually will give better code, but it is a possibility to trace an image in Inkscape (either manually or automatically), and then export to TikZ code from Inkscape. – Torbjørn T. Dec 30 '16 at 16:12
-
Try a WYSIWYG TikZ editor. – Skeleton Bow Dec 30 '16 at 18:11
-
See also http://tex.stackexchange.com/q/80418/82389 – David R Dec 30 '16 at 18:48
-
@SkeletonBow: do you have any suggestions about WYSIWYG-TikZ-editors? Any experiences? I think, the OP did exactly want to know, which WYSIWYG-editors exist. Just answering: try one is not really helpful? – Jan Dec 31 '16 at 00:51
-
@Jan I've only used this one, but it seems like there is a question with a list, which is nice! Hopefully that helps. – Skeleton Bow Jan 06 '17 at 23:49
1 Answers
8
Even though there is a way to draw on an image, however, it is much simpler to draw the diagram directly if you have all the details which in your case, it seems to me you have it. Drawing your diagram is trivial and can be easily done by Tikz. This is a result of the following code
\documentclass[border={10pt}]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw[very thick,rounded corners]
(-.2,.2) -- (8.2,0.2) -- (8.2,-1.2) -- (7.2,-2.2) -- (0.8,-2.2) -- (-.2,-1.2) -- cycle;
\draw[thin,rounded corners]
(-.1,.1) -- (8.1,0.1) -- (8.1,-1.1) -- (7.1,-2.1) -- (0.9,-2.1) -- (-.1,-1.1) -- cycle;
\fill[gray!20, draw=black, very thick,rounded corners]
(0,0) -- (8,0) -- (8,-1) -- (7,-2) -- (1,-2) -- (0,-1) -- cycle;
\draw[thick] (2,.2) -- ( 2.1,.28) -- (2.4,.28) -- (2.5,.2);
\draw[thick] (3.75,.2) -- ( 3.85,.28) -- (4.15,.28) -- (4.25,.2);
\draw[thick] (6,.2) -- ( 5.9,.28) -- (5.6,.28) -- (5.5,.2);
\filldraw[fill=white, draw=black] (2,-.01) rectangle (6,-1);
\filldraw[fill=white, draw=black] (1,.9) rectangle (1.6,0.22);
\filldraw[fill=white, draw=black] (6.4,.9) rectangle (7,0.22);
\filldraw[fill=yellow, draw=black] (2.2,-.5) rectangle node[yshift=1.6cm]{\Large 5} (2.6,-1.3) ;
\filldraw[fill=white, draw=black] (2.2,-1.3) rectangle (2.6,-1.6);
\filldraw[fill=yellow, draw=black] (3.0,-.5) rectangle node[yshift=1.6cm]{\Large 4} (3.4,-1.3);
\filldraw[fill=white, draw=black] (3.0,-1.3) rectangle (3.4,-1.6);
\filldraw[fill=yellow, draw=black] (3.8,-.5) rectangle node[yshift=1.6cm]{\Large 3} (4.2,-1.3);
\filldraw[fill=white, draw=black] (3.8,-1.3) rectangle (4.2,-1.6);
\filldraw[fill=yellow, draw=black] (4.6,-.5) rectangle node[yshift=1.6cm]{\Large 2}(5.0,-1.3);
\filldraw[fill=white, draw=black] (4.6,-1.3) rectangle (5.0,-1.6);
\filldraw[fill=yellow, draw=black] (5.4,-.5) rectangle node[yshift=1.6cm]{\Large 1} (5.8,-1.3);
\filldraw[fill=white, draw=black] (5.4,-1.3) rectangle (5.8,-1.6);
\node at (4,-2.8) {\textbf{Micro USB Male connector}};
\end{tikzpicture}
\end{document}
CroCo
- 5,902
-
-
1instead of your last
\node-command, use this code\node at (2.2, .8) {\textbf{5}}; \node at (3, .8) {\textbf{4}}; \node at (3.8, .8) {\textbf{3}}; \node at (4.6, .8) {\textbf{2}}; \node at (5.4, .8) {\textbf{1}};. This will place the numbers directly above the yellow connectors. – Jan Dec 31 '16 at 00:59 -
1@Jan, Oops. I was up all the night. You're right about numbers. I wasn't paying attention to them but a better way is to place a node above the rectangle and shift it up. see my update. Thanks again. – CroCo Dec 31 '16 at 02:29
-
1Cool, for the three round polygons, can we just draw one then shrink it a little bit to create the other two? Since the shape is the same but size different, I guess it's doable but not sure. – lucky1928 Jan 01 '17 at 03:36
-

