%! Package = kosmorro
%! Author = Jérôme Deuchnord
%! Date = 2020-04-26

\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{kosmorro}[2020/04/26 Kosmorro Package]

\RequirePackage{xcolor}
\RequirePackage{fp}

\newcommand{\moonphase}[2]{
    \begin{center}
        \begin{minipage}{2cm}
            \includegraphics[width=\linewidth]{#1}
        \end{minipage}
        \hspace{5mm}
        \begin{minipage}{7cm}
            \textbf{\currentmoonphasetitle}\\#2
        \end{minipage}
    \end{center}
}

\newenvironment{ephemerides}{
    \begin{table}[h]
        \centering
        \begin{tabular}{lccc}
            \textbf{\ephemeridesobjecttitle} &
            \textbf{\ephemeridesrisetimetitle} &
            \textbf{\ephemeridesculminationtimetitle} &
            \textbf{\ephemeridessettimetitle}\\
\hline
}{
        \end{tabular}
    \end{table}
}

\newcommand{\object}[4]{
    \hline
    \textbf{#1} & {#2} & {#3} & {#4}\\
}

\newenvironment{graphephemerides}{\setlength{\unitlength}{0.02\linewidth}
\begin{picture}(20,20)
    % Axes
    \put(0,-2){\vector(1,0){50}}
    \multiput(0,-2)(2,0){24}{
        \line(0,-1){0.25}
    }
    \newcounter{hour}
    \multiput(-0.25,-3.5)(4,0){12}{
        \sffamily\footnotesize
        \arabic{hour}\stepcounter{hour}\stepcounter{hour}
    }
    \put(49,-3.5){\sffamily\footnotesize hours}

    % Graduation

    \put(50,-0.5){\sffamily\footnotesize Pluto}
    \put(50,1.5){\sffamily\footnotesize Neptune}
    \put(50,3.5){\sffamily\footnotesize Uranus}
    \put(50,5.5){\sffamily\footnotesize Saturn}
    \put(50,7.5){\sffamily\footnotesize Jupiter}
    \put(50,9.5){\sffamily\footnotesize Mars}
    \put(50,11.5){\sffamily\footnotesize Venus}
    \put(50,13.5){\sffamily\footnotesize Mercury}
    \put(50,15.5){\sffamily\footnotesize Moon}
    \put(50,17.5){\sffamily\footnotesize Sun}

    \multiput(0,0)(0,2){10}{
        \color{gray}\line(1,0){48}
    }

    \linethickness{1.5mm}
}{
\end{picture}
\vspace{1cm}
}

\newcommand{\graphobject}[8]{%
    % #1: Y coordinate component
    % #2: Color
    % #3: Hour rise time
    % #4: Minute rise time
    % #5: Hour set time
    % #6: Minute set time
    % #7: Human-readable rise time
    % #8: Human-readable set time

    \FPeval{\start}{#3*2+(#4/60)*2}%
    \FPeval{\length}{#5*2+(#6/60)*2 - \start}%
    \FPeval{\starttext}{\start+0.7}%
    \FPeval{\endtext}{\start+\length-3.25}%

    {\color{#2}%
    \put(\start,#1){%
        \line(1, 0){\length}%
    }}%

    \put(\starttext,#1.5){\sffamily\footnotesize #7}%
    \put(\endtext,#1.5){\sffamily\footnotesize #8}%
}

\newcommand{\event}[2]{
    \textbf{#1} & {#2}\\
}

\newenvironment{events}{
    \begin{table}[h]
        \begin{tabular}{ll}
}{
        \end{tabular}
    \end{table}
}

\endinput
