# Bounding box is larger than expected when drawing a curved path

I have been working on logo for my department and I have the following code. The problem is that whenever I compile the diagram seems to be larger than the actual logo. I do not know what is the problem. I know the numbers I have selected are not the best but any insights into the matter will be highly appreciated.

 \documentclass[letterpaper]{article}
\usepackage[top=2cm,bottom=2cm,left=2cm,right=2cm]{geometry}
%\usepackage{amsmath,amssymb,units}
%\usepackage{enumitem,multicol}
\usepackage{tikz}
%\usetikzlibrary{arrows}
\usepackage{lipsum}

\begin{document}

\lipsum[1-2]
\begin{tikzpicture}[y=0.80pt, x=0.8pt,yscale=-1]
\path[draw=black,fill=white]
(258.9527,290.5199) .. controls (173.9885,538.4766) and (568.5860,261.2969) ..
(306.5098,257.1141) .. controls (44.4337,252.9312) and (429.9845,542.5624) ..
(352.9767,292.0206) .. controls (275.9689,41.4788) and (119.6549,497.6604) ..
(334.1376,346.9999) .. controls (548.6203,196.3394) and (66.4622,188.6439) ..
(276.0276,346.0724) .. controls (485.5930,503.5010) and (343.9169,42.5633) ..
(258.9527,290.5199) -- cycle;
\end{tikzpicture}
\lipsum[1-2]
\end{document}


See image below:

• Do you mean that the bounding box of the diagram is much larger than the diagram itself? – krlmlr Feb 6 '12 at 20:24
• Yes, my word choice was not the most appropriate but yes that is what I am asking – azetina Feb 6 '12 at 20:29
• I took the liberty to edit the title and to add a tag. – krlmlr Feb 6 '12 at 20:39
• @user946850 Thanks for the edit. That seems like a better title for the question. – azetina Feb 6 '12 at 20:43
• @azetina: Cool logo - How did you draw it? – hpekristiansen Feb 6 '12 at 23:06

Update : before to use a grid it's possible to use pdfcrop to get the dimensions of the "real" picture. You need to use \thispagestyle{empty} and you need to compile only the picture. You get a pdf file then with pdfcrop you get a new pdf file. Inside this pdf, you can read /BBox [0 0 146.908 142.991] (be careful with the units). We don't have the origin but we get the dimensions. pdfcrop can also give a pdf file that you can include with a correct bounding box.

Manually : With a grid

\documentclass[letterpaper]{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[y=0.80pt, x=0.8pt,yscale=-1]
\draw[help lines,step=8pt] (208,208) grid (400, 400);
\clip (208,208) rectangle (400, 400);
\path[draw=black]
(258.9527,290.5199) .. controls (173.9885,538.4766) and (568.5860,261.2969) ..
(306.5098,257.1141) .. controls (44.4337,252.9312) and (429.9845,542.5624) ..
(352.9767,292.0206) .. controls (275.9689,41.4788) and (119.6549,497.6604) ..
(334.1376,346.9999) .. controls (548.6203,196.3394) and (66.4622,188.6439) ..
(276.0276,346.0724) .. controls (485.5930,503.5010) and (343.9169,42.5633) ..
(258.9527,290.5199) -- cycle;
\end{tikzpicture}
\begin{tikzpicture}[y=0.80pt, x=0.8pt,yscale=-1]
\path[draw=black] (213,215) rectangle (398, 395);
\clip (213,215) rectangle (398, 395);
\path[draw=black]
(258.9527,290.5199) .. controls (173.9885,538.4766) and (568.5860,261.2969) ..
(306.5098,257.1141) .. controls (44.4337,252.9312)  and (429.9845,542.5624) ..
(352.9767,292.0206) .. controls (275.9689,41.4788)  and (119.6549,497.6604) ..
(334.1376,346.9999) .. controls (548.6203,196.3394) and (66.4622,188.6439) ..
(276.0276,346.0724) .. controls (485.5930,503.5010) and (343.9169,42.5633) ..
(258.9527,290.5199) -- cycle;
\end{tikzpicture}
\end{document}


• Nice use of a grid to work out what the size should be. Definitely the most practical solution. – Loop Space Feb 7 '12 at 9:46
• I like the pdfcrop idea, I actually do that quite a lot. And +1 for the grid supports as well! – yo' Feb 7 '12 at 10:31
• @altermundus Thanks for providing a substantial solution. – azetina Feb 7 '12 at 15:30

As seen in the answer by Peter Grill, the size of the bounding box is determined not only by the path points, but also by the control points. In order to reduce the size of the bounding box, we have to specify it explicitly.

The manual states:

PGF is reasonably good at keeping track of the size of your picture and reserving just the right amount of space for it in the main document. However, in some cases you may want to say things like “do not count this for the picture size” or “the picture is actually a little large.” For this you can use the option use as bounding box or the command \useasboundingbox, which is just a shorthand for \path[use as bounding box].

And especially with respect to curved lines:

... Controls points of a curve often lie far “outside” the curve and make the bounding box too large. In this case, you should use the [use as bounding box] option.

As a quick fix, you could add something like the following into your tikzpicture environment before drawing:

 \path[use as bounding box] (220, 200) rectangle (400, 400);


For more precise calculation, find points that will define the convex hull of your logo with sufficient precision and use a polygon as bounding box -- this works equally well.

Here is the result of the quick fix:

• The bounding box is good but is it possible to edit the logo to get the same effect? Just wondering. – azetina Feb 6 '12 at 20:50
• If you used only the path points for computing the bounding box, the result would be equally wrong. (This is what I tried first.) TikZ would have to do rather difficult computations in order to get it right. – krlmlr Feb 6 '12 at 21:01

This is not an answer, but thought it might be useful to see why this is happening as @user946850 points out. I added the following to the code to see where the control points are:

\foreach \x in {{(173.9885,538.4766)}, {(568.5860,261.2969)}, {(44.4337,252.9312)},
{(429.9845,542.5624)}, {(275.9689,41.4788)}, {(119.6549,497.6604)}, {(548.6203,196.3394)}, {(66.4622,188.6439)}, {(485.5930,503.5010)}, {(343.9169,42.5633)}} {
\node [fill=red,shape=circle] at \x {};
};


Another way to see the bounding box is to apply the following at the end of the picture:

\draw [blue] (current bounding box.south west) rectangle (current bounding box.north east);


• I suppose that is what is causing the bounding box to be so large. Is this customizable other than adding the bounding box as user946850 suggests. – azetina Feb 6 '12 at 20:44
• Thanks for the effort. I was just too lazy to figure out how to iterate over coordinates :-) – krlmlr Feb 6 '12 at 20:47
• Is there a simple general way to exclude control points from a bounding box before a picture is drawn? – orome May 27 '12 at 12:57

I added an experimental library bbox which computes the bounding box for curves. I tested it and it seems to work unless the curve has very steep angles, in which case there might be dimension too large errors. However, in this example and all reasonable'' cases it seems to work.

\documentclass[letterpaper]{article}
\usepackage[top=2cm,bottom=2cm,left=2cm,right=2cm]{geometry}
\usepackage{tikz}
\usetikzlibrary{bbox}

\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[y=0.80pt, x=0.8pt,yscale=-1]
\path[draw=black,fill=white]
(258.9527,290.5199) .. controls (173.9885,538.4766) and (568.5860,261.2969) ..
(306.5098,257.1141) .. controls (44.4337,252.9312) and (429.9845,542.5624) ..
(352.9767,292.0206) .. controls (275.9689,41.4788) and (119.6549,497.6604) ..
(334.1376,346.9999) .. controls (548.6203,196.3394) and (66.4622,188.6439) ..
(276.0276,346.0724) .. controls (485.5930,503.5010) and (343.9169,42.5633) ..
(258.9527,290.5199) -- cycle;
\draw (current bounding box.south west) rectangle  (current bounding box.north
east);
\end{tikzpicture}
\caption{Default.}
\end{figure}
\begin{figure}
\centering
\begin{tikzpicture}[y=0.80pt, x=0.8pt,yscale=-1,bezier bounding box]
\path[draw=black,fill=white]
(258.9527,290.5199) .. controls (173.9885,538.4766) and (568.5860,261.2969) ..
(306.5098,257.1141) .. controls (44.4337,252.9312) and (429.9845,542.5624) ..
(352.9767,292.0206) .. controls (275.9689,41.4788) and (119.6549,497.6604) ..
(334.1376,346.9999) .. controls (548.6203,196.3394) and (66.4622,188.6439) ..
(276.0276,346.0724) .. controls (485.5930,503.5010) and (343.9169,42.5633) ..
(258.9527,290.5199) -- cycle;
\draw (current bounding box.south west) rectangle  (current bounding box.north
east);
\end{tikzpicture}
\caption{With \texttt{bezier bounding box} from the \texttt{bbox} library
switched on.}
\end{figure}
\end{document}


The theory behind this is very simple. The TeX code for the following can be found under this link.

For those who do not want to follow external links: this is the code of the library:

\tikzset{%
bezier bounding box/.is choice,%
bezier bounding box/.default=true,%
bezier bounding box/true/.code=\tikzset{switch on bezier bounding box},%
bezier bounding box/false/.code=\tikzset{switch off bezier bounding box}}%
\tikzset{switch off bezier bounding box/.code={%
\def\pgf@lt@curveto##1##2##3##4##5##6{%
\pgf@protocolsizes{##1}{##2}%
\pgf@protocolsizes{##3}{##4}%
\pgf@protocolsizes{##5}{##6}%
\pgfsyssoftpath@curveto{\the##1}{\the##2}{\the##3}{\the##4}{\the##5}{\the##6}%
}%
\let\pgf@nlt@curveto\pgf@lt@curveto}}
%
% it might just be me but according to what I believe to find
% \pgfmathsetlengthmacro appears to generate spaces
%
\tikzset{switch on bezier bounding box/.code={%
\def\pgf@lt@curveto##1##2##3##4##5##6{%
% extrema in x
\pgfmathsetmacro{\pgf@temp@b}{abs(\pgf@path@lastx-##5-3*##1+3*##3)}%
% ^^^ this is used for the denominator below, cannot become too small
\pgfmathsetmacro{\pgf@temp@c}{max(1+\pgf@path@lastx,max(##1,max(##3,##5)))}%
% ^^^ in order to avoid dimension too large errors from squaring lengths in pt
\pgfmathparse{((##1/\pgf@temp@c)*(##1/\pgf@temp@c)-1*((##1/\pgf@temp@c)*(##3/\pgf@temp@c))+(##3/\pgf@temp@c)*(##3/\pgf@temp@c)-1*((##1/\pgf@temp@c)*(##5/\pgf@temp@c))+(-(##3/\pgf@temp@c)+(##5/\pgf@temp@c))*(\pgf@path@lastx/\pgf@temp@c))}%
\pgfutil@tempdima=\pgfmathresult pt\relax%
% ^^^ discriminant
\ifdim\pgf@temp@b pt<0.01pt\relax%
% approximately linear
\pgfmathparse{abs(2*(##1)-2*(##3)+(##5))}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\ifdim\pgfutil@tempdimb<0.1pt\relax%
% if the denominator is very small, it is *likely* large but could be 0/0
\else
\pgfmathsetmacro{\pgf@temp@a}{(2*(##1)-3*(##3)+(##5))/(2*(##1)-2*(##3)+(##5))}%
\pgfmathparse{\pgf@path@lastx*pow(1-\pgf@temp@a,3)+3*##1*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##3*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##5*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{\pgfutil@tempdimb}{##6}%
\fi%
\else
\ifdim\pgfutil@tempdima<0pt\relax% negative discriminant -> no turning point
\else
\pgfmathsetmacro{\pgf@temp@a}{min(1,max(0,(\pgf@path@lastx-2*##1+##3-\pgf@temp@c*sqrt(\pgfutil@tempdima))/(\pgf@path@lastx-##5-3*##1+3*##3)))}%
\pgfmathparse{\pgf@path@lastx*pow(1-\pgf@temp@a,3)+3*##1*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##3*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##5*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{\pgfutil@tempdimb}{##6}%
\pgfmathsetmacro{\pgf@temp@a}{min(1,max(0,(\pgf@path@lastx-2*##1+##3+\pgf@temp@c*sqrt(\pgfutil@tempdima))/(\pgf@path@lastx-##5-3*##1+3*##3)))}%
\pgfmathparse{\pgf@path@lastx*pow(1-\pgf@temp@a,3)+3*##1*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##3*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##5*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{\pgfutil@tempdimb}{##6}%
\fi%
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% extrema in y (completely analogous to the above)
\pgfmathsetmacro{\pgf@temp@b}{abs(\pgf@path@lasty-##6-3*##2+3*##4)}%
\pgfmathsetmacro{\pgf@temp@c}{max(1+\pgf@path@lasty,max(##2,max(##4,##6)))}%
\pgfmathparse{((##2/\pgf@temp@c)*(##2/\pgf@temp@c)-1*((##2/\pgf@temp@c)*(##4/\pgf@temp@c))+(##4/\pgf@temp@c)*(##4/\pgf@temp@c)-1*((##2/\pgf@temp@c)*(##6/\pgf@temp@c))+(-(##4/\pgf@temp@c)+(##6/\pgf@temp@c))*(\pgf@path@lasty/\pgf@temp@c))}%
\pgfutil@tempdima=\pgfmathresult pt\relax%
% ^^^ discriminant
\ifdim\pgf@temp@b pt<0.01pt\relax%
% approximately linear
\pgfmathparse{abs(2*(##2)-2*(##4)+(##6))}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\ifdim\pgfutil@tempdimb<0.1pt\relax%
% if the denominator is very small, it is *likely* large but could be 0/0
\else
\pgfmathsetmacro{\pgf@temp@a}{(2*(##2)-3*(##4)+(##6))/(2*(##2)-2*(##4)+(##6))}%
\pgfmathparse{\pgf@path@lasty*pow(1-\pgf@temp@a,3)+3*##2*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##4*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##6*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{##5}{\pgfutil@tempdimb}%
\fi%
\else
\ifdim\pgfutil@tempdima<0pt\relax% negative discriminant -> no turning point
\else
\pgfmathsetmacro{\pgf@temp@a}{min(1,max(0,(\pgf@path@lasty-2*##2+##4-\pgf@temp@c*sqrt(\pgfutil@tempdima))/(\pgf@path@lasty-##6-3*##2+3*##4)))}%
\pgfmathparse{\pgf@path@lasty*pow(1-\pgf@temp@a,3)+3*##2*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##4*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##6*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{##5}{\pgfutil@tempdimb}%
\pgfmathsetmacro{\pgf@temp@a}{min(1,max(0,(\pgf@path@lasty-2*##2+##4+\pgf@temp@c*sqrt(\pgfutil@tempdima))/(\pgf@path@lasty-##6-3*##2+3*##4)))}%
\pgfmathparse{\pgf@path@lasty*pow(1-\pgf@temp@a,3)+3*##2*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##4*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##6*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{##5}{\pgfutil@tempdimb}%
\fi%
\fi
\pgf@protocolsizes{\pgf@path@lastx}{\pgf@path@lasty}%
\pgf@protocolsizes{##5}{##6}%
\pgfsyssoftpath@curveto{\the##1}{\the##2}{\the##3}{\the##4}{\the##5}{\the##6}%
}
\let\pgf@nlt@curveto\pgf@lt@curveto}}% fix me: 0/0 cases and occasional
% dimension too large errors (what's the cause?)


If you do not want do load the library, you may just copy the code and sandwich it between \makeatletter and \makeatother.

If you encounter dimension too large errors, you may want to use

\usetikzlibrary{fpu}
\newcommand{\pgfmathsetmacroFPU}[2]{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathsetmacro{#1}{#2}%
\pgfmathsmuggle#1\endgroup}
\newcommand{\pgfmathparseFPU}[1]{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathparse{#1}%
\pgfmathsmuggle\pgfmathresult\endgroup}
\tikzset{%
bezier bounding box/.is choice,%
bezier bounding box/.default=true,%
bezier bounding box/true/.code=\tikzset{switch on bezier bounding box},%
bezier bounding box/false/.code=\tikzset{switch off bezier bounding box}}%
\tikzset{switch off bezier bounding box/.code={%
\def\pgf@lt@curveto##1##2##3##4##5##6{%
\pgf@protocolsizes{##1}{##2}%
\pgf@protocolsizes{##3}{##4}%
\pgf@protocolsizes{##5}{##6}%
\pgfsyssoftpath@curveto{\the##1}{\the##2}{\the##3}{\the##4}{\the##5}{\the##6}%
}%
\let\pgf@nlt@curveto\pgf@lt@curveto}}
%
% it might just be me but according to what I believe to find
% \pgfmathsetlengthmacro appears to generate spaces
%
\tikzset{switch on bezier bounding box/.code={%
\def\pgf@lt@curveto##1##2##3##4##5##6{%
% extrema in x
\pgfmathsetmacroFPU{\pgf@temp@b}{abs(\pgf@path@lastx-##5-3*##1+3*##3)}%
% ^^^ this is used for the denominator below, cannot become too small
\pgfmathsetmacroFPU{\pgf@temp@c}{max(1+\pgf@path@lastx,max(##1,max(##3,##5)))}%
% ^^^ in order to avoid dimension too large errors from squaring lengths in pt
\pgfmathparseFPU{((##1/\pgf@temp@c)*(##1/\pgf@temp@c)-1*((##1/\pgf@temp@c)*(##3/\pgf@temp@c))+(##3/\pgf@temp@c)*(##3/\pgf@temp@c)-1*((##1/\pgf@temp@c)*(##5/\pgf@temp@c))+(-(##3/\pgf@temp@c)+(##5/\pgf@temp@c))*(\pgf@path@lastx/\pgf@temp@c))}%
\pgfutil@tempdima=\pgfmathresult pt\relax%
% ^^^ discriminant
\ifdim\pgf@temp@b pt<0.01pt\relax%
% approximately linear
\pgfmathparseFPU{abs(2*(##1)-2*(##3)+(##5))}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\ifdim\pgfutil@tempdimb<0.1pt\relax%
% if the denominator is very small, t is *likely* large but could be 0/0
\else
\pgfmathsetmacroFPU{\pgf@temp@a}{(2*(##1)-3*(##3)+(##5))/(2*(##1)-2*(##3)+(##5))}%
\pgfmathparseFPU{\pgf@path@lastx*pow(1-\pgf@temp@a,3)+3*##1*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##3*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##5*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{\pgfutil@tempdimb}{##6}%
\fi%
\else
\ifdim\pgfutil@tempdima<0pt\relax% negative discriminant -> no turning point
\else
\pgfmathsetmacroFPU{\pgf@temp@a}{min(1,max(0,(\pgf@path@lastx-2*##1+##3-\pgf@temp@c*sqrt(\pgfutil@tempdima))/(\pgf@path@lastx-##5-3*##1+3*##3)))}%
\pgfmathparseFPU{\pgf@path@lastx*pow(1-\pgf@temp@a,3)+3*##1*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##3*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##5*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{\pgfutil@tempdimb}{##6}%
\pgfmathsetmacroFPU{\pgf@temp@a}{min(1,max(0,(\pgf@path@lastx-2*##1+##3+\pgf@temp@c*sqrt(\pgfutil@tempdima))/(\pgf@path@lastx-##5-3*##1+3*##3)))}%
\pgfmathparseFPU{\pgf@path@lastx*pow(1-\pgf@temp@a,3)+3*##1*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##3*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##5*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{\pgfutil@tempdimb}{##6}%
\fi%
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% extrema in y (completely analogous to the above)
\pgfmathsetmacroFPU{\pgf@temp@b}{abs(\pgf@path@lasty-##6-3*##2+3*##4)}%
\pgfmathsetmacroFPU{\pgf@temp@c}{max(1+\pgf@path@lasty,max(##2,max(##4,##6)))}%
\pgfmathparseFPU{((##2/\pgf@temp@c)*(##2/\pgf@temp@c)-1*((##2/\pgf@temp@c)*(##4/\pgf@temp@c))+(##4/\pgf@temp@c)*(##4/\pgf@temp@c)-1*((##2/\pgf@temp@c)*(##6/\pgf@temp@c))+(-(##4/\pgf@temp@c)+(##6/\pgf@temp@c))*(\pgf@path@lasty/\pgf@temp@c))}%
\pgfutil@tempdima=\pgfmathresult pt\relax%
% ^^^ discriminant
\ifdim\pgf@temp@b pt<0.01pt\relax%
% approximately linear
\pgfmathparseFPU{abs(2*(##2)-2*(##4)+(##6))}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\ifdim\pgfutil@tempdimb<0.1pt\relax%
% if the denominator is very small, t is *likely* large but could be 0/0
\else
\pgfmathsetmacroFPU{\pgf@temp@a}{(2*(##2)-3*(##4)+(##6))/(2*(##2)-2*(##4)+(##6))}%
\pgfmathparseFPU{\pgf@path@lasty*pow(1-\pgf@temp@a,3)+3*##2*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##4*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##6*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{##5}{\pgfutil@tempdimb}%
\fi%
\else
\ifdim\pgfutil@tempdima<0pt\relax% negative discriminant -> no turning point
\else
\pgfmathsetmacroFPU{\pgf@temp@a}{min(1,max(0,(\pgf@path@lasty-2*##2+##4-\pgf@temp@c*sqrt(\pgfutil@tempdima))/(\pgf@path@lasty-##6-3*##2+3*##4)))}%
\pgfmathparseFPU{\pgf@path@lasty*pow(1-\pgf@temp@a,3)+3*##2*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##4*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##6*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{##5}{\pgfutil@tempdimb}%
\pgfmathsetmacroFPU{\pgf@temp@a}{min(1,max(0,(\pgf@path@lasty-2*##2+##4+\pgf@temp@c*sqrt(\pgfutil@tempdima))/(\pgf@path@lasty-##6-3*##2+3*##4)))}%
\pgfmathparseFPU{\pgf@path@lasty*pow(1-\pgf@temp@a,3)+3*##2*pow(1-\pgf@temp@a,2)*\pgf@temp@a+3*##4*(1-\pgf@temp@a)*\pgf@temp@a*\pgf@temp@a+##6*pow(\pgf@temp@a,3)}%
\pgfutil@tempdimb=\pgfmathresult pt\relax%
\pgf@protocolsizes{##5}{\pgfutil@tempdimb}%
\fi%
\fi
\pgf@protocolsizes{\pgf@path@lastx}{\pgf@path@lasty}%
\pgf@protocolsizes{##5}{##6}%
\pgfsyssoftpath@curveto{\the##1}{\the##2}{\the##3}{\the##4}{\the##5}{\the##6}%
}
\let\pgf@nlt@curveto\pgf@lt@curveto}}
\endinput


instead. This is even slower than the above but has less problems with the dimension too large errors.

• Wow! Good job! Nice piece work. – azetina Jul 24 at 15:53

clip the figure before drawing

\documentclass[letterpaper]{article}
\usepackage[top=2cm,bottom=2cm,left=2cm,right=2cm]{geometry}
%\usepackage{amsmath,amssymb,units}
%\usepackage{enumitem,multicol}
\usepackage{tikz}
%\usetikzlibrary{arrows}
\usepackage{lipsum}

\begin{document}

\lipsum[1-2]
\begin{tikzpicture}[y=0.80pt, x=0.8pt,yscale=-1]
\clip[draw](305,305) circle (100);
\path[draw=red,fill=white]
(258.9527,290.5199) .. controls (173.9885,538.4766) and (568.5860,261.2969) ..
(306.5098,257.1141) .. controls (44.4337,252.9312) and (429.9845,542.5624) ..
(352.9767,292.0206) .. controls (275.9689,41.4788) and (119.6549,497.6604) ..
(334.1376,346.9999) .. controls (548.6203,196.3394) and (66.4622,188.6439) ..
(276.0276,346.0724) .. controls (485.5930,503.5010) and (343.9169,42.5633) ..
(258.9527,290.5199) -- cycle;
\end{tikzpicture}
\lipsum[1-2]
\end{document}