6

I want to make a macro which draw a enlighten match using TikZ in my document. I'm successful :

\newcommand\allumette[2]{
    \fill [PeachPuff] (#1,#2) rectangle (#1+4,#2+0.2);
    \fill [PeachPuff!60!Black] (#1,#2) -- ++(4,0)-- ++(0.1,-0.05) -- ++(-4,0) -- ++(-0.1,0.05);
    \draw (#1,#2) -- ++(0,0.2) -- ++(4,0) -- ++(0,-0.2) -- ++(0.1,-0.05) -- ++(-4,0) -- ++(-0.1,0.05);
    \shade[ball color=red] (#1+4,#2+0.1) ellipse (0.25cm and 0.22cm);
    \draw (#1+4,#2+0.1) ellipse (0.25cm and 0.22cm);
}

Output :

output

However, I'm not successful while trying to draw the flame over the tip.

Edit : Here is a minimal working example :

\documentclass{article}

\usepackage[svgnames]{xcolor}
\usepackage{tikz}


\newcommand\allumette[2]{
    \fill [PeachPuff] (#1,#2) rectangle (#1+4,#2+0.2);
    \fill [PeachPuff!60!Black] (#1,#2) -- ++(4,0)-- ++(0.1,-0.05) -- ++(-4,0) -- ++(-0.1,0.05);
    \draw (#1,#2) -- ++(0,0.2) -- ++(4,0) -- ++(0,-0.2) -- ++(0.1,-0.05) -- ++(-4,0) -- ++(-0.1,0.05);
    \shade[ball color=red] (#1+4,#2+0.1) ellipse (0.25cm and 0.22cm);
    \draw (#1+4,#2+0.1) ellipse (0.25cm and 0.22cm);
}

\begin{document}

\begin{tikzpicture}
\allumette{0}{0}
\end{tikzpicture}

\end{document}
Enzo S.
  • 97
  • 1
    Would you include a Minimum Working Example? That should include the \documentclass command and \begin{document} \end{document}. – mirkom Dec 18 '16 at 14:33
  • Welcome! It would be good if you would complete your code. Have to looked at tikzsymbols? I think it includes a flame or something similar. – cfr Dec 18 '16 at 14:41
  • Some other examples: http://tex.stackexchange.com/questions/121822/best-way-to-draw-matchstick-pictures/164580#164580 – Ignasi Dec 18 '16 at 20:24

1 Answers1

4

You can draw a generic flame. I stole it from How to create Candle Symbol in LaTeX. I used yellow in the absence of the definition of the colors.

\begin{tikzpicture}
\newcommand\allumette[2]{
    \fill [yellow] (#1,#2) rectangle (#1+4,#2+0.2);
    \fill [yellow!60!black] (#1,#2) -- ++(4,0)-- ++(0.1,-0.05) -- ++(-4,0) -- ++(-0.1,0.05);
    \draw (#1,#2) -- ++(0,0.2) -- ++(4,0) -- ++(0,-0.2) -- ++(0.1,-0.05) -- ++(-4,0) -- ++(-0.1,0.05);
    \shade[ball color=red] (#1+4,#2+0.1) ellipse (0.25cm and 0.22cm);
    \draw (#1+4,#2+0.1) ellipse (0.25cm and 0.22cm);
}
\allumette{0.1}{0.2}
\filldraw[orange,scale=0.5,shift={(8.2,1.2)}]  (0,0) .. controls (-1.5,1.25) and (.5,2) .. (-.2,4) .. controls (1,2.5) and (1,.5) .. (0,0);
\end{tikzpicture}

enter image description here

But depends on how much you want to procrastinate. Instead of a new command you can define a /.pic for this and turn the flame on and off or refer to nodes in it etc.

percusse
  • 157,807
  • It looks like I want, but I'm using a macro because I need to integrate it in more complexe figures. I would like to have a macro for the match only, and one for the match and the flame, but I do not understand the placement of the flame in the command you've given. – Enzo S. Dec 18 '16 at 14:56
  • Edit : I finally understood, I modified your command to adapt to the given coordinates. – Enzo S. Dec 18 '16 at 19:50