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.

\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] {};\\


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



\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};
\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};
\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};
\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};
\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};


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:

\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}}; 
\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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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