% --------------------------------------------------------------------------
% the tikz-cookingsymbols package
% 
%   draw cooking symbols (like top/bottom-heat) with tikz
%
% --------------------------------------------------------------------------
% Fabian Matischok
% E-Mail: f_matischok@t-online.de
% --------------------------------------------------------------------------
% Copyright 2025 Fabian Matischok
% 
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tikz-cookingsymbols}[2025/03/15 2.0 Draw cookingsymbols with tikz]
%		required packages
\RequirePackage{tikz}
\usetikzlibrary{calc,topaths,bending}
\RequirePackage{calc}


% catch font size
\AtBeginDocument{
  \begingroup
  \normalsize
  \pgfmathparse{\f@size / 1pt} % Conversion to numerical value (ex: 10)
  \xdef\tikzCS@basefontsize{\pgfmathresult}
  \endgroup
}


\pgfqkeys{/tikzCScmd}{% Create directory for keys
  scale/.store in = \tikzCS@cmd@scale,
  scale = 1,             % default value
  color/.store in = \tikzCS@cmd@color,
  color = black,         % default value
}


%		private box
\newsavebox{\tikzCS@Box}

%		defining used lengths and commands
\newlength{\tikzCS@AFHeight}
\settoheight{\tikzCS@AFHeight}{abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ}
\addtolength{\tikzCS@AFHeight}{-0.4pt} % 0.4pt is the line width used for drawn the default symbol
\setlength{\tikzCS@AFHeight}{15\tikzCS@AFHeight}% to avoid issues with missing space at crossing knot for \AirFryer, we working with icons scaled up 15 times
\newlength{\tikzCS@AFDepth}
\settodepth{\tikzCS@AFDepth}{abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ}
\setlength{\tikzCS@AFDepth}{15\tikzCS@AFDepth}% to avoid issues with missing space at crossing knot for \AirFryer, we working with icons scaled up 15 times
\newlength{\tikzCS@AFHeightStar}
\setlength{\tikzCS@AFHeightStar}{\tikzCS@AFHeight}% in starred version of commmands, ...
\addtolength{\tikzCS@AFHeightStar}{\tikzCS@AFDepth}% ... depth is added to height
\newlength{\tikzCS@BLDepth}% Baseline Depth
\setlength{\tikzCS@BLDepth}{\tikzCS@AFDepth}
\addtolength{\tikzCS@BLDepth}{-3pt}% 0.5*0.4*15, half of standard line width (0.4pt) scaled up by 15
\ProvideExpandableDocumentCommand{\tikzCS@AFSize}{}{\fpeval{\tikzCS@AFHeight}}
\ProvideExpandableDocumentCommand{\tikzCS@AFRadius}{m}{(15/\tikzCS@AFSize)*#1}%  #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
\ProvideExpandableDocumentCommand{\tikzCS@GrillDistance}{}{((\tikzCS@AFSize-30)/\tikzCS@AFSize)}
\ProvideExpandableDocumentCommand{\tikzCS@GrillLength}{}{0.125*\tikzCS@GrillDistance}
\ProvideExpandableDocumentCommand{\tikzCS@BL}{}{(1/10)*\tikzCS@GrillDistance}
\ProvideExpandableDocumentCommand{\tikzCS@MWLength}{}{\tikzCS@AFSize/5}

%		border of symbols
\ProvideDocumentCommand{\tikzCS@Border}{m}{%
\draw (${15/\tikzCS@AFSize}*(#1,0pt)$)to (${(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(#1,0pt)$) arc[radius=\tikzCS@AFRadius{#1},start angle=270,end angle=360]%
to($(#1,0pt)+{(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(0pt,#1)$) arc[radius=\tikzCS@AFRadius{#1},start angle=0,end angle=90]%
to(${15/\tikzCS@AFSize}*(#1,0pt)+(0pt,#1)$) arc[radius=\tikzCS@AFRadius{#1},start angle=90,end angle=180]%
to(${15/\tikzCS@AFSize}*(0pt,#1)$) arc[radius=\tikzCS@AFRadius{#1},start angle=180,end angle=270];%
}


%		fan for circulating air
\ProvideDocumentCommand{\tikzCS@Fan}{m}{% #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
\filldraw[line join=bevel] (${0.5}*(#1,#1)$) to[in=0,out=75] (${0.5}*(#1,#1)+{(0.5*\tikzCS@AFSize-15)/\tikzCS@AFSize}*(90:#1)$) to[out=180,in=105]cycle;%
\filldraw[line join=bevel] (${0.5}*(#1,#1)$) to[in=120,out=195] (${0.5}*(#1,#1)+{(0.5*\tikzCS@AFSize-15)/\tikzCS@AFSize}*(210:#1)$) to[out=300,in=225]cycle;%
\filldraw[line join=bevel] (${0.5}*(#1,#1)$) to[in=240,out=315] (${0.5}*(#1,#1)+{(0.5*\tikzCS@AFSize-15)/\tikzCS@AFSize}*(330:#1)$) to[out=420,in=345]cycle;%
}



% code for drawn the specified (starred or not) symbol in right color, size 
\newcommand{\tikzCS@cmd}[3]{% #1: starred or not, #2: option scale and color, #3: command name to draw the symbol
	\begingroup             % Isolation of key modifications
	\pgfqkeys{/tikzCScmd}{#2}% Apply user keys
	\IfBooleanTF{#1}{%	True
		\savebox{\tikzCS@Box}{\tikz[baseline={(0pt,\tikzCS@BLDepth)},\tikzCS@cmd@color,line width=6pt]{#3{\tikzCS@AFHeightStar}}% the default line width (0.4pt) is scaled up 15 times (= 6pt)
		}% 
	}{%	False
		\savebox{\tikzCS@Box}{\tikz[\tikzCS@cmd@color,line width=6pt]{#3{\tikzCS@AFHeight}}% % the default line width (0.4pt) is scaled up 15 times (= 6pt)
		}%
	}%
	\pgfmathparse{\tikzCS@cmd@scale*\f@size / \tikzCS@basefontsize/15}\edef\tikzCS@scaleFactor{\pgfmathresult}\scalebox{\tikzCS@scaleFactor}{\usebox{\tikzCS@Box}}% downscaled by 15 (see the begin code)
	\endgroup
}



%	Top/BottomHeat
\newcommand{\tikzCS@drawTopBottomHeat}[1]{\tikzCS@Border{#1}% #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
		\draw (${15/\tikzCS@AFSize}*(#1,0pt)+{15/\tikzCS@AFSize}*(0pt,#1)$)to(${(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(#1,0pt)+{15/\tikzCS@AFSize}*(0pt,#1)$);%
		\draw (${15/\tikzCS@AFSize}*(#1,0pt)+{(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(0pt,#1)$)to(${(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(#1,0pt)+{(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(0pt,#1)$);%
		}

\ProvideDocumentCommand{\TopBottomHeat}{s O{}}{% lang: EN
	\tikzCS@cmd{#1}{#2}{\tikzCS@drawTopBottomHeat}
}


\let\OberUnterHitze\TopBottomHeat % lang: DE


% Top Heat
\newcommand{\tikzCS@drawTopHeat}[1]{\tikzCS@Border{#1}% #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
		\draw (${15/\tikzCS@AFSize}*(#1,0pt)+{(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(0pt,#1)$)to(${(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(#1,0pt)+{(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(0pt,#1)$);%
		}

\ProvideDocumentCommand{\TopHeat}{s O{}}{% lang: EN
	\tikzCS@cmd{#1}{#2}{\tikzCS@drawTopHeat}
}


\let\OberHitze\TopHeat % lang: DE


% Bottom Heat
\newcommand{\tikzCS@drawBottomHeat}[1]{\tikzCS@Border{#1}% #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
		\draw (${15/\tikzCS@AFSize}*(#1,0pt)+{15/\tikzCS@AFSize}*(0pt,#1)$)to(${(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(#1,0pt)+{15/\tikzCS@AFSize}*(0pt,#1)$);%
		}

\ProvideDocumentCommand{\BottomHeat}{s O{}}{% lang: EN
	\tikzCS@cmd{#1}{#2}{\tikzCS@drawBottomHeat}
}


\let\UnterHitze\BottomHeat % lang: DE


% Convection Oven
\newcommand{\tikzCS@drawConvectionOven}[1]{\tikzCS@Border{#1}%#1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
		\tikzCS@Fan{#1}%
		\draw (${0.5}*(#1,#1)$) circle[radius={((\tikzCS@AFSize-15)/\tikzCS@AFSize)*0.5*#1}];%
		}

\ProvideDocumentCommand{\ConvectionOven}{s O{}}{% lang: EN
	\tikzCS@cmd{#1}{#2}{\tikzCS@drawConvectionOven}
}


\let\Umluft\ConvectionOven % lang: DE


% Convection Oven alternative
\newcommand{\tikzCS@drawConvectionOvenAlt}[1]{\tikzCS@Border{#1}% #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
		\begin{scope}[shift={(${15*0.5/\tikzCS@AFSize}*(0pt,-#1)$)}]%
		\tikzCS@Fan{#1}%
		\end{scope}%
		}

\ProvideDocumentCommand{\ConvectionOvenAlt}{s O{}}{% lang: EN
	\tikzCS@cmd{#1}{#2}{\tikzCS@drawConvectionOvenAlt}
}


\let\UmluftAlt\ConvectionOvenAlt % lang: DE


% ConvectionOvenGrill
\newcommand{\tikzCS@drawConvectionOvenGrill}[1]{\tikzCS@Border{#1}% #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
		\draw (${15/\tikzCS@AFSize}*(#1,0pt)+{(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(0pt,#1)$)-- ++($\tikzCS@GrillLength*(#1,-#1)$)-- ++($\tikzCS@GrillLength*(#1,#1)$)%
			-- ++($\tikzCS@GrillLength*(#1,-#1)$)-- ++($\tikzCS@GrillLength*(#1,#1)$)%
			-- ++($\tikzCS@GrillLength*(#1,-#1)$)-- ++($\tikzCS@GrillLength*(#1,#1)$)%
			-- ++($\tikzCS@GrillLength*(#1,-#1)$)-- ++($\tikzCS@GrillLength*(#1,#1)$);%
		\begin{scope}[shift={(${15/\tikzCS@AFSize}*(0pt,-#1)+{0.5*15/\tikzCS@AFSize}*(#1,0pt)$)},scale={(\tikzCS@AFSize-15)/\tikzCS@AFSize}]%
		\tikzCS@Fan{#1}%
		\end{scope}%
		}

\ProvideDocumentCommand{\ConvectionOvenGrill}{s O{}}{% lang: EN
	\tikzCS@cmd{#1}{#2}{\tikzCS@drawConvectionOvenGrill}
}


\let\UmluftGrill\ConvectionOvenGrill % lang: DE


% Grill
\newcommand{\tikzCS@drawGrill}[1]{\tikzCS@Border{#1}% #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
		\draw (${15/\tikzCS@AFSize}*(#1,0pt)+{(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(0pt,#1)$)-- ++($\tikzCS@GrillLength*(#1,-#1)$)-- ++($\tikzCS@GrillLength*(#1,#1)$)%
			-- ++($\tikzCS@GrillLength*(#1,-#1)$)-- ++($\tikzCS@GrillLength*(#1,#1)$)%
			-- ++($\tikzCS@GrillLength*(#1,-#1)$)-- ++($\tikzCS@GrillLength*(#1,#1)$)%
			-- ++($\tikzCS@GrillLength*(#1,-#1)$)-- ++($\tikzCS@GrillLength*(#1,#1)$);%
		}

\ProvideDocumentCommand{\Grill}{s O{}}{% lang: EN+DE
	\tikzCS@cmd{#1}{#2}{\tikzCS@drawGrill}
}

%	Microwave
\newcommand{\tikzCS@drawMicrowave}[1]{\tikzCS@Border{#1}% #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
		\foreach \t in{0,1,2,3}\draw[shift={(${\t*(1/5)}*(0pt,#1)$)}] (${15/\tikzCS@AFSize}*(#1,0pt)+{1/5}*(0pt,#1)$)to[in=180,out=337.5]
					++($\tikzCS@GrillLength*(2*#1,-0.5*#1)$)to[out=0,in=202.5]
					++($\tikzCS@GrillLength*(2*#1,0.5*#1)$)to[out=22.5,in=180]
					++($\tikzCS@GrillLength*(2*#1,0.5*#1)$)to[out=0,in=157.5]
					++($\tikzCS@GrillLength*(2*#1,-0.5*#1)$);
		}

\ProvideDocumentCommand{\Microwave}{s O{}}{% lang: EN
	\tikzCS@cmd{#1}{#2}{\tikzCS@drawMicrowave}
}


\let\Microwelle\Microwave % lang: DE


% AirFryer
\newcommand{\tikzCS@drawAirFryer}[1]{\tikzCS@Border{#1}% #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
		\coordinate (tikzCS@coordC)at(${(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(#1,0pt)+{(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(0pt,#1)+{2*\tikzCS@BL}*(-#1,0)+{1*\tikzCS@BL}*(0,-#1)$);%
		\coordinate (tikzCS@coordD)at(${(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(#1,0pt)+{(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(0pt,#1)+{1*\tikzCS@BL}*(0,-#1)$);%
		\coordinate (tikzCS@coordP1) at (${15/\tikzCS@AFSize}*(#1,0pt)+{(\tikzCS@AFSize-15)/\tikzCS@AFSize}*(0pt,#1)$);
		\coordinate (tikzCS@coordH) at (${3*\tikzCS@BL}*(#1,0pt)$);% horizontal shift
		\coordinate (tikzCS@coordQ1) at ($(tikzCS@coordP1)+{2*\tikzCS@BL}*(0,-#1)$);
		\coordinate (tikzCS@coordQ2) at ($(tikzCS@coordP1)+{1.5*\tikzCS@BL}*(#1,0pt)+{\tikzCS@BL}*(0pt,-#1)$);
		\coordinate (tikzCS@coordP3) at ($(tikzCS@coordQ1)+(tikzCS@coordH)$);
		\coordinate (tikzCS@coordQ3) at ($(tikzCS@coordP1)+(tikzCS@coordH)$);
		\coordinate (tikzCS@coordP4) at ($(tikzCS@coordQ2)+(tikzCS@coordH)$);
		\coordinate (tikzCS@coordP5) at ($(tikzCS@coordQ3)+(tikzCS@coordH)$);
		\coordinate (tikzCS@coordQ5) at ($(tikzCS@coordP3)+(tikzCS@coordH)$);
		\draw[-_, shorten >=4.5pt] (tikzCS@coordP1) to[out=0,in=180] (tikzCS@coordP3) to[out=0, in=225] (tikzCS@coordP4);
		\draw[-_, shorten >=4.5pt] (tikzCS@coordC) to[out=135, in=0] (tikzCS@coordP5) to[out=180, in=45] (tikzCS@coordP4);
		\draw[-_, shorten >=4.5pt] (tikzCS@coordQ1) to[out=0, in=225] (tikzCS@coordQ2);
		\draw[-_, shorten >=4.5pt] (tikzCS@coordC) to[out=225, in=0] (tikzCS@coordQ5) to[out=180, in=0] (tikzCS@coordQ3) to[out=180,in=45] (tikzCS@coordQ2);
		\draw(tikzCS@coordC)--(tikzCS@coordD);
		\draw ($(tikzCS@coordD)+{1.15*\tikzCS@BL}*(-#1,#1)$)--(tikzCS@coordD)--++(${1.15\tikzCS@BL}*(-#1,-#1)$);
	\begin{scope}[shift={(${15/\tikzCS@AFSize}*(0pt,-#1)+{15*0.5/\tikzCS@AFSize}*(#1,0pt)$)},scale={(\tikzCS@AFSize-15)/\tikzCS@AFSize}]%
		\tikzCS@Fan{#1}%
		\end{scope}%	
		}

\ProvideDocumentCommand{\AirFryer}{s O{} }{% lang: EN+DE
	\tikzCS@cmd{#1}{#2}{\tikzCS@drawAirFryer}
}


%	Pizza
\newcommand{\tikzCS@drawPizza}[1]{\tikzCS@Border{#1}% #1 is \tikzCS@AFHeight or \tikzCS@AFHeightStar
		\coordinate (tikzCS@coordA)at(${15/\tikzCS@AFSize}*(#1,#1)$);%
		\coordinate (tikzCS@coordC)at($(tikzCS@coordA)+{(\tikzCS@AFSize-30)/\tikzCS@AFSize}*(20:#1)$);%
		\coordinate (tikzCS@coordB)at($(tikzCS@coordA)!0.91!(tikzCS@coordC)$);%
		\draw[clip](tikzCS@coordA)to(tikzCS@coordC) arc[radius={((\tikzCS@AFSize-15)/\tikzCS@AFSize)*#1},start angle=20,delta angle=45]to cycle
		(tikzCS@coordB)arc[radius={((\tikzCS@AFSize-15)/\tikzCS@AFSize)*0.9*#1},start angle=20,delta angle=45];%
		\draw ($(tikzCS@coordA)+{0.54}*(50:#1)$) circle[radius={(15/\tikzCS@AFSize)*0.7*#1}];
		\draw ($(tikzCS@coordA)+{0.3}*(65:#1)$) circle[radius={(15/\tikzCS@AFSize)*0.7*#1}];
		\draw ($(tikzCS@coordA)+{0.44}*(20:#1)$) circle[radius={(15/\tikzCS@AFSize)*0.7*#1}];
		}

\ProvideDocumentCommand{\Pizza}{s O{} }{% lang: EN+DE
	\tikzCS@cmd{#1}{#2}{\tikzCS@drawPizza}
}


\endinput