Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Does anybody know how could I draw nails-like with tikz? Something like those here.

enter image description here

I thought this could be achieved using polygon something like the following.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes,calendar,matrix,backgrounds,folding}
\begin{document}    
\begin{tikzpicture}
\matrix[nodes={draw, thick, fill=red!20,minimum size=1cm},
    row sep=0.3cm,column sep=0.5cm] {
\node[regular polygon,regular polygon sides=7] {};&
\node[star,star points=4] {};&
\node[star,star points=5,star point ratio=0.8] {};&
\node[star,star points=7,star point ratio=0.8] {};&
\node[star,star points=10] {};\\
};
\end{tikzpicture}

\end{document}
share|improve this question
    
Can you please provide a link to an image of the shape you want to obtain? –  Gonzalo Medina Feb 4 at 1:37
    
Somethign like those: tillynailart.files.wordpress.com/2013/11/… –  user45367 Feb 4 at 1:43
    
Do you want to define shapes or do you just want to draw them? –  Gonzalo Medina Feb 4 at 1:45
    
I want to draw and color them. –  user45367 Feb 4 at 1:46

1 Answer 1

up vote 8 down vote accepted

I just used paths with rounded corners instead of polygons. Here is the code:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
%Oval
\draw[rounded corners=5pt,line width=1pt,densely dashed] (.5,0)--(1,0)--(1,.7) arc (0:180:.5 and 1.5)--(0,0)--(.5,0);
\node at (.5,-.5) {Oval};
%Square
\begin{scope}[xshift=2cm]
\draw[rounded corners=5pt,line width=1pt,densely dashed] (.5,0)--(1,0)--(1,2.2)--(0,2.2)--(0,0)--(.5,0);
\node at (.5,-.5) {Square};
\end{scope}
%Squoval
\begin{scope}[xshift=4cm]
\draw[rounded corners=10pt,line width=1pt,densely dashed] (.5,0)--(1,0)--(1,2.2)--(0,2.2)--(0,0)--(.5,0);
\node at (.5,-.5) {Squoval};
\end{scope}
%Round
\begin{scope}[xshift=6cm]
\draw[rounded corners=7pt,line width=1pt,densely dashed] (0,1.7)--(0,0)--(1,0)--(1,1.7);
\draw[line width=1pt,densely dashed] (1,1.7) arc (0:180:.5);
\node at (.5,-.5) {Round};
\end{scope}
%Stiletto
\begin{scope}[xshift=8cm]
\draw[rounded corners=9pt,line width=1pt,densely dashed] (.5,0)--(1,0)--(1,.7)--(.5,2.3)--(0,.7)--(0,0)--(.5,0);
\node at (.5,-.5) {Stiletto};
\end{scope}
\end{tikzpicture}

\end{document}

And here is the result:

enter image description here

Had to do some tweaking to make the dashed lines look ok. To take care of some work for you, it may be useful to use --cycle; at the end of a path, instead of starting and ending in the middle of a smooth section, as I have. I tried using that, but the dashed lines and rounded corners caused me some problems. You can change how round the paths are by adjusting the rounded corners= parameter.

And to color them, just put in fill=red (for instance, for red) inside the square brackets of the \draw command, separating it from the other instructions with a comma ,.

Edit for picture fill:

To put a picture in one of the shapes, use the clip command. For example, say you wanted some kittens inside the oval, and you have the picture kittens.jpg in the same directory as your .tex file. With everything else as before, inside the tikzpicture environment use the following code:

%Oval-picture
\begin{scope}
\clip[rounded corners=5pt] (.5,0)--(1,0)--(1,.7) arc (0:180:.5 and 1.5)--(0,0)--(.5,0);; 
\node at (.25,.7) {\includegraphics[width=4cm]{kittens.jpg}}; 
\end{scope}
%Oval-path
\draw[rounded corners=5pt,line width=1pt,densely dashed] (.5,0)--(1,0)--(1,.7) arc (0:180:.5 and 1.5)--(0,0)--(.5,0);
\node at (.5,-.5) {Oval};

You can change the positioning (by adjusting the coordinates of the \node) and size (by adjusting the size of width=) of the picture easily. The result is this:

enter image description here

So all that you do is start a new scope environment for all that you want to be clipped, and use the same path that you have for the shape. To not lose the thickness of the path of the shape, do this before the shape is actually drawn.

share|improve this answer
    
That is really amazing, thanks a lot. Is it that difficult to plot an image inside of each shape? –  user45367 Feb 4 at 2:36
    
What sort of image? And I think it won't be, since you can always scale and shift things with TikZ. –  jlv Feb 4 at 3:15
1  
@user45367: Are you refering to something like how-to-clip-an-external-image-inside-an-ellipse ? –  Ignasi Feb 4 at 8:20
    
Yes, fill the area with an image. Something like "fill=image". –  user45367 Feb 4 at 12:38
    
I added some basic ideas on how to do that. Check my updated response. –  jlv Feb 4 at 19:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.