\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{tvary}[2023/07/03 Tvary Class]

\LoadClass{article}

\RequirePackage{tikz}
\RequirePackage{xparse}
\usetikzlibrary{calc} %pro mrizX

\newcommand{\rectangle}[5][]{%
  \begin{tikzpicture}
    \coordinate (A) at (0, 0);
    \coordinate (B) at (#2, 0);
    \coordinate (C) at (#2, #3);
    \coordinate (D) at (0, #3);
    
    \draw (A) -- node[below] {\IfValueT{#4}{#4 = }#2} (B) -- node[right] {\IfValueT{#5}{#5 = }#3} (C) -- (D) -- cycle;
 %  \draw (A) -- node[below] {\IfValueT{#4}{#4 = }\IfValueF{#2}} (B) -- node[right] %%{\IfValueT{#5}{#5 = }\IfValueF{#3}} (C) -- (D) -- cycle;
      
    \node at (A) [circle,fill,inner sep=1.5pt,label=left:A] {};
    \node at (B) [circle,fill,inner sep=1.5pt,label=right:B] {};
    \node at (C) [circle,fill,inner sep=1.5pt,label=right:C] {};
    \node at (D) [circle,fill,inner sep=1.5pt,label=left:D] {};
  \end{tikzpicture}
}


\newcommand{\trojuhelnik}[4][]{%
  \begin{tikzpicture}
    \coordinate (A) at (0, 0);
    \coordinate (B) at (#2, 0);
    \coordinate (C) at (#3, #4);
    
    \draw (A) -- node[below] {$#2$} (B) -- node[right] {$#3$} (C) -- node[left] {$#4$} cycle;
    
    \node at (A) [circle,fill,inner sep=1.5pt,label=below left:A] {};
    \node at (B) [circle,fill,inner sep=1.5pt,label=below right:B] {};
    \node at (C) [circle,fill,inner sep=1.5pt,label=above:C] {};
  \end{tikzpicture}
}


\newcommand{\triangleAngles}[3]{%
  \begin{tikzpicture}
    \coordinate (A) at (0, 0);
    \coordinate (B) at (#1, 0);
    
    % Převod úhlů na radiány
    \pgfmathsetmacro{\angleA}{#2 * pi / 180}
    \pgfmathsetmacro{\angleB}{#3 * pi / 180}
    
    % Výpočet třetího vrcholu (C) na základě úhlů
    \pgfmathsetlengthmacro{\sideC}{#1 * sin(\angleA) / sin(180 - \angleA - \angleB)}
    \coordinate (C) at ({\sideC}, 0);
    
    \draw (A) -- node[below] {$#1$} (B) -- node[right] {$#2$} (C) -- node[left] {$#3$} cycle;
    
    \node at (A) [circle,fill,inner sep=1.5pt,label=below left:A] {};
    \node at (B) [circle,fill,inner sep=1.5pt,label=below right:B] {};
    \node at (C) [circle,fill,inner sep=1.5pt,label=above:C] {};
  \end{tikzpicture}
}

\newcommand{\grid}[3]{
  \begin{tikzpicture}
    \draw[style=help lines,step=#1] (#2) grid (#3);
  \end{tikzpicture}
}

\newcommand{\mriz}[4][]{
  \begin{tikzpicture}
    \draw[style=help lines,step=#2] (#3) grid (#4);
    \ifx#1\empty\relax
    \else
      \draw[->] (#3) -- (#4 |- #3);
      \draw[->] (#3) -- (#3 -| #4);
    \fi
  \end{tikzpicture}
}

\newcommand{\mrizX}[4][]{
  \begin{tikzpicture}
    \draw[style=help lines,step=#2] (#3) grid (#4); %mrizka
    \draw[->] (#3 |- 0, 0) -- (#4 |- 0, 0) node[right] {$x$}; % osa x
    \draw[->] (0,0 |- #3) -- (0,0 |- #4) node[above] {$y$}; % osa y
  
    %\draw[->] (#3) -- (#3 |- #4) node[above] {$y$}; % osa y




    
%    \draw[->] (0, #3) -- (0, #4 |- 0, 0) node[above] {$y$}; % osa y
    
%\draw[->] (#3) -- (#3 |- #4) node[above] {$y$}; % osa y
%\draw[->] (0, #3) -- (0, #4) node[above] {$y$}; % osa y

%\draw[->] (#3) -- (#4 |- #3) node[right] {$x$}; % osa x
%\draw[->] (#3) -- (#3 |- #4) node[above] {$y$}; % osa y

%\draw[->] (0, 0) -- (#3 |- 0, 0) node[right] {$x$}; % osa x %-----------
%\draw[->] (0, 0) -- (0, 0 |- #3) node[above] {$y$}; % osa y %-----------

%\draw[->] (#3 |- 0, 0) -- (0, 0) -- (0, 0 |- #3); % osa x a osa y
%\draw[->] (#3) -- (0, 0) node[above] {$y$}; % prodloužení osy x
%\draw[->] (#4 |- 0, 0) -- (0, 0) node[above] {$x$}; % prodloužení osy y
    
 %   \draw[->] (-1.5,0) -- (1.5,0) node[right] {$x$};
% \draw[->] (0,0)|- #3) -- (0,0 |- #4) node[above] {$y$}; 

 %    \ifx&#1&% pokud je nepovinný parametr prázdný
%    \else% pokud je nepovinný parametr vyplněný
%      \draw[->] ($(#3)-(0.2,0)$) -- ($(#4)+(0.2,0)$);
%      \draw[->] ($(#3)-(0,0.2)$) -- ($(#4)+(0,0.2)$);
%      \node[anchor=north west] at (#4) {#1};
%    \fi
  \end{tikzpicture}
}
