How are quadratic Bezier curves drawn by TikZ?
As Paul Gaborit said in his comments (a) .. controls (b) .. (c)
is not a quadratic Bézier curve, but the cubic one (a) .. controls (b) and (b) .. (c)
.
If you want to draw a quadratic curve in TikZ you can define your own to path
style. Here is an an example of how to do it using calc
library.
\documentclass[tikz,border=7pt,convert={density=1400}]{standalone}
\usetikzlibrary{calc}
\tikzset{
quadratic/.style={
to path={
(\tikztostart) .. controls
($#1!1/3!(\tikztostart)$) and ($#1!1/3!(\tikztotarget)$)
.. (\tikztotarget)
}
}
}
\begin{document}
\begin{tikzpicture}[nodes={scale=2,text opacity=1}]
\draw[help lines] (0,0) grid (2,4);
\filldraw[fill opacity=.07]
(0,0) coordinate[label=center:.](A)
--(1,0) coordinate[label=center:.](B)
--(2,4) coordinate[label=center:.](C);
\draw[blue] (A)..controls (B)..(C);
\draw[red,very thick] (A) to[quadratic={(B)}] (C); % <- The quadratic curve
\draw[white,domain=0:2] plot (\x,\x^2);
\end{tikzpicture}
\end{document}
And if you prefer a code that do not use calc
and use the PGF command \pgfpathquadraticcurveto
you can replace the style definition with :
\makeatletter
\def\pt@get#1{%
\tikz@scan@one@point\pgfutil@firstofone#1\relax%
\pgfpoint{\the\pgf@x}{\the\pgf@y}%
}
\tikzset{
quadratic/.code={
\def\tikz@to@path{}% <- TikZ do nothing
\pgfpathquadraticcurveto{\pt@get{#1}}{\pt@get{(\tikztotarget)}}% <- PGF insert the quadratic curve
}
}
\makeatother