%\newcommand{\highlight}[1]{\colorbox{yellow}{$\displaystyle #1$}}
\newcommand\Fontvi{\fontsize{9.5}{1}\selectfont}
%%%%%%%
\newcommand{\msout}[1]{\text{\sout{\ensuremath{#1}}}}
\pgfplotsset{compat=1.8}

\newcommand\myheading[1]{%
\par\bigskip
{\Large\bfseries#1}\par\smallskip}

\makeatletter


\usetikzlibrary{svg.path}
\usetikzlibrary{decorations.pathreplacing,decorations.markings}
\newcounter{pos}
\tikzset{
  initcounter/.code={\setcounter{pos}{0}},
  style between/.style n args={3}{
    postaction={
      initcounter,
      decorate,
      decoration={
        show path construction,
        curveto code={
          \addtocounter{pos}{1}
          \pgfmathtruncatemacro{\min}{#1 - 1}
          \ifthenelse{\thepos < #2 \AND \thepos > \min}{
            \draw[#3]
            (\tikzinputsegmentfirst)
            ..
            controls (\tikzinputsegmentsupporta) and (\tikzinputsegmentsupportb)
            ..
            (\tikzinputsegmentlast);
          }{}
        }
      }
    },
  },
}



\newcommand{\handmadecube}[5]{
	
	\pgfmathsetmacro{\width}{#1}
	\pgfmathsetmacro{\height}{#2}
	\pgfmathsetmacro{\ti}{#3}
	\pgfmathsetmacro{\x}{#4}
	\pgfmathsetmacro{\y}{#5}
	
	
	\pgfmathsetmacro{\yfactor}{0.9}
	\pgfmathsetmacro{\xfactor}{0.6}
	
	
	% % square
	\draw [-,draw=\borderColor] (\x-\width,\y) -- (\x,\y); % % x cahnge ->
	\draw [-,draw=\borderColor] (\x,\y) -- (\x,\y-\height); % % y change   |
	\draw [-,draw=\borderColor] (\x,\y-\height) -- (\x-\width,\y-\height); % % x change <-
	\draw [-,draw=\borderColor] (\x-\width,\y-\height) -- (\x-\width,\y); % % y change  |
	
	\draw  [draw=\borderColor,fill=\forefillColor] (\x-\width,\y)--(\x,\y) -- (\x,\y-\height) -- (\x-\width,\y-\height) --cycle ;
	
	\draw  [draw=\borderColor,fill=\toprsidefillcolor] (\x,\y) -- (\x+\xfactor*\ti,\y+\yfactor*\ti) -- (\x+\xfactor*\ti,\y+\yfactor*\ti-\height) -- (\x,\y-\height) --cycle ;
	
	\draw  [draw=\borderColor,fill=\toprsidefillcolor] (\x-\width,\y)--(\x,\y) -- (\x+\xfactor*\ti,\y+\yfactor*\ti) -- (\x+\xfactor*\ti-\width,\y+\yfactor*\ti) --cycle ;
	
	\draw [-,draw=\borderColor]   (\x,\y) -- (\x+\xfactor*\ti,\y+\yfactor*\ti);
	
	\draw [-,draw=\borderColor] (\x-\width,\y) -- (\x-\width+\xfactor*\ti,\y+\yfactor*\ti);
	
	\draw [-,draw=\borderColor] (\x-\width+\xfactor*\ti,\y+\yfactor*\ti) -- (\x+\xfactor*\ti,\y+\yfactor*\ti);
	
	\draw [-,draw=\borderColor] (\x+\xfactor*\ti,\y+\yfactor*\ti) -- (\x+\xfactor*\ti,\y+\yfactor*\ti-\height);
	
	\draw [-,draw=\borderColor] (\x,\y-\height) -- (\x+\xfactor*\ti,\y+\yfactor*\ti-\height);
	
}

\def\cuboid#1#2#3#4#5{
	\begin{scope}
		\edef\mycolor{#2}
		\edef\depth{#3}
		\edef\height{#4}
		\edef\width{#5}
		\draw[black,fill=\mycolor] #1 -- ++(-\depth,0,0) -- ++(0,-\height,0) -- ++(\depth,0,0) -- cycle #1 -- ++(0,0,-\width) -- ++(0,-\height,0) -- ++(0,0,\width) -- cycle  #1 -- ++(-\depth,0,0) -- ++(0,0,-\width) -- ++(\depth,0,0) -- cycle;
	\end{scope}
}


\def\cuboidlabelmine#1#2#3#4#5#6#7#8{
	\begin{scope}
		\edef\mycolor{#2}
		\edef\depth{#3}
		\edef\height{#4}
		\edef\width{#5}
		\edef\depthlabel{#6}
		\edef\heightlabel{#7}
		\edef\widthlabel{#8}
		\draw[black,fill=\mycolor] #1 -- ++(-\depth,0,0) -- ++(0,-\height,0) -- ++(\depth,0,0) node[pos=0.5,below] {\tiny \depthlabel} -- cycle #1 -- ++(0,0,-\width) -- ++(0,-\height,0) node[pos=0.5,right,outer sep=-3pt] {\tiny \heightlabel} -- ++(0,0,\width)  node[pos=0.5,below] {\tiny \widthlabel} -- cycle  #1 -- ++(-\depth,0,0) -- ++(0,0,-\width) -- ++(\depth,0,0) -- cycle;
	\end{scope}
}



\def\lenetparamnew#1#2#3#4#5#6#7#8{
	\begin{scope}
		\edef\mycolor{#2}
		\edef\depth{#3}
		\edef\height{#4}
		\edef\width{#5}
		\edef\depthlabel{#8}
		\edef\heightlabel{#7}
		\edef\sep{#6}
		\draw[black,fill=\mycolor] #1 -- ++(-\depth,0,0) -- ++(0,-\height,0) -- ++(\depth,0,0) -- cycle #1 -- ++(0,0,-\width) -- ++(0,-\height,0) node[pos=0.9,above,outer sep=-13 pt] {\tiny \heightlabel} node[pos=0.9,above,outer sep=-20 pt] {\tiny \depthlabel} -- ++(0,0,\width)  -- cycle  #1 -- ++(-\depth,0,0) -- ++(0,0,-\width) -- ++(\depth,0,0) -- cycle;
	\end{scope}
}



\def\lenetparam#1#2#3#4#5#6#7#8{
	\begin{scope}
		\edef\mycolor{#2}
		\edef\depth{#3}
		\edef\height{#4}
		\edef\width{#5}
		\edef\depthlabel{#6}
		\edef\heightlabel{#7}
		\edef\widthlabel{#8}
		\draw[black] #1 -- ++(-\depth,0,0) -- ++(0,-\height,0) -- ++(\depth,0,0) node[pos=0.5,above,outer sep=-28pt] {\tiny \depthlabel} node[pos=0.6,above,outer sep=-35pt] {\tiny \heightlabel} node[pos=0.5,above,outer sep=-42] {\tiny \widthlabel}  -- cycle #1 -- ++(0,0,-\width) -- ++(0,-\height,0)  -- ++(0,0,\width) -- cycle  #1 -- ++(-\depth,0,0) -- ++(0,0,-\width) -- ++(\depth,0,0) -- cycle;
	\end{scope}
}



\def\kernel#1#2#3#4#5#6{
	\begin{scope}
		\edef\mycolor{#2}
		\edef\depth{#3}
		\edef\height{#4}
		\edef\width{#5}
		\draw[black,fill=\mycolor] #1 -- ++(-\depth,0,0) -- ++(0,-\height,0) -- ++(\depth,0,0) -- cycle #1 -- ++(0,0,-\width) -- ++(0,-\height,0) -- ++(0,0,\width) -- cycle  #1 -- ++(-\depth,0,0) -- ++(0,0,-\width) -- ++(\depth,0,0) -- cycle;
		\draw[dashed] #1 -- #6 #1++(0,0,-\width) -- #6 #1++(0,-\height,0) -- #6 #1++(0,-\height,-\width) -- #6;
	\end{scope}
}


\def\kernellabel#1#2#3#4#5#6#7#8#9{
	%#6 is target pixel
	\begin{scope}
		\edef\mycolor{#2}
		\edef\depth{#3}
		\edef\height{#4}
		\edef\width{#5}
		\edef\depthlabel{#7}
		\edef\heightlabel{#8}
		\edef\widthlabel{#9}
		\draw[black,fill=\mycolor] #1 -- ++(-\depth,0,0) -- ++(0,-\height,0) -- ++(\depth,0,0) node[pos=0.5,below] {\tiny \depthlabel} -- cycle #1 -- ++(0,0,-\width) -- ++(0,-\height,0) node[pos=0.5,right] {\tiny \heightlabel} -- ++(0,0,\width)  node[pos=0.5,below] {\tiny \widthlabel} -- cycle  #1 -- ++(-\depth,0,0) -- ++(0,0,-\width) -- ++(\depth,0,0) -- cycle;
		\draw[dashed] #1 -- #6 #1++(0,0,-\width) -- #6 #1++(0,-\height,0) -- #6 #1++(0,-\height,-\width) -- #6;
	\end{scope}
}



\newcommand{\tikzmark}[1]{\tikz[baseline,remember picture] \coordinate (#1) {};}


%\def\alpha{3} 

\newcommand\derivative[5]{%
    \tkzDefPointByFct[draw](#1) \tkzGetPoint{start}
  \tkzDefPointByFct[draw](#2) \tkzGetPoint{end}
  \draw[thin,|-|,yshift=-3pt] (start) -- node[black,fill=white,#5] {#3}(start-|end);  
  \draw[thin,|-|,xshift=3pt] (start-|end) -- node[black,fill=white,right] {#4}(end); 
  %\draw[thin] (start) --(end); 
}
