# Tikz - How to determine the coordinates in fill

How to create Candle Symbol in LaTeX

I previously asked a question about making candle light and got amazing answers. To todd's answer I have another question which would help understand basics of such problems. In the answer \fill[color=#2] (0,0) .. controls (-1.5,1.25) and (.5,2) .. (-.2,4) .. controls (1,2.5) and (1,.5) .. (0,0);

How to find the coordinates, it can not be shear hit and trial, there must be some reason behind it. its better to learn how to fish then ask ask for a fish :), so lets learn it from TeX Gurus. Really appreciate all your help.

• You can use a graphics tool(e.g. inkscake), to make the curves, and then either export to tikz(and maybe edit the code, and round numbers), or read the coordinates from the screen. – hpekristiansen Feb 9 '12 at 14:38

While our gurus are busy with their extensive answers here is a quick stab:

There is an involved process to compute these curves and I don't think I can do justice with an answer that can fit here (although my work involves such interpolations pretty often). However I would like to quote the paragraph from the manual (p.25) which pretty much gives the basic idea.

For this, TikZ provides a special syntax. One or two control points are needed. The math behind them is not quite trivial, but here is the basic idea: Suppose you are at point x and the first control point is y. Then the curve will start going in the direction of y at x that is, the tangent of the curve at x will point toward y. Next, suppose the curve should end at z and the second support point is w. Then the curve will, indeed, end at z and the tangent of the curve at point z will go through w.

In our special and quite beautiful example, I have tried to show the locations and the tangents with dots and arrows to illustrate the choices. You can also use the show curve control option (PGF manual v2.10 p.327) as Jake commented to this answer. However to save space I did it manually below.

\begin{tikzpicture}
\draw[style=help lines] (-2,0) grid[step=1cm] (2,4);
\fill[color=red] (0,0) .. controls (-1.5,1.25) and (.5,2) .. (-.2,4) .. controls (1,2.5) and (1,.5) .. (0,0);
\foreach[count=\xi] \x in {(-1.5,1.25),(0.5,2),(-0.2,4),(1,2.5),(1,0.5)}{
\node[draw,circle,fill=yellow,inner sep=1pt] (p\xi) at \x {};
}
\draw[thick,blue] (0,0) -- (p1) (p3) -- (p2);
\draw (p3) -- (p4) (p5) -- (0,0);
\end{tikzpicture}


As you can see from the tangent points, when the curve starts it points towards the first control point and when it finishes the first (left) segment, the curve reaches to the endpoint with a tangent that points towards the second control point. Obviously same applies to the right segment (drawn with black lines).

The remaining detail is the magnitude of the control point distance and that, roughly speaking, defines the emphasis of that control point. To see this please make control points further away but on the same direction and check how this affects the time spent going in that direction. I have added one such example to show the difference for the first control point for the left segment.  • Very nice explanation. For showing the control points and handles, you can also use the show curve controls style that's provided in the manual (page 327 of the 2.10 manual), which is very handy. It requires \usetikzlibrary{decorations.pathreplacing, shapes.misc} – Jake Feb 9 '12 at 14:29
• @Jake Ah, finally a chance to use that key! I totally forgot about that. Thanks for the reminder. I will update the answer whenever I have the chance. – percusse Feb 9 '12 at 15:45