%% Set dvisvgm as option to produce a svg
\documentclass[svgnames,border=1cm]{standalone}
\usepackage{pstricks-add}
\usepackage{pst-caelum}
\usepackage{xint-meeus,wasysym}
\usepackage[export]{animate}
%% To receive a gif uncomment the following line
%% and erase "dvisvgm" option of "standalone
%\usepackage[export]{animate}
\usepackage{readarray}
\input{xint-sun.tex}

%\input{astro-meeus.tex}

\readdef{lune2021.txt}\lignes
\readarray{\lignes}\lune[-,2]
%% ATTENTION: new syntax for \JulianDay (now separated with commas)
\JulianDay(2021,1,1,0,0,0)
%% Counting days easily :-)
\newcommand\calcTfor[1]{\xintdeffloatvar T := (JD+#1-2451545.0)/36525;}

\def\mois#1{\ifcase\numexpr#1\relax
\or janvier\or février\or mars\or avril\or mai\or juin
\or juillet\or août\or septembre\or octobre\or novembre\or décembre\fi}

\begin{document}

\begin{animateinline}[%
    controls,
    loop,
    begin={\begin{pspicture}(-7.5,-7.5)(7.5,7.5)
    %% Setup fixed objects for the animation
    %% NOTE: This is no real background to save Megabytes. EUF !!!
    %% See attempt of Manuel with "timeline" option of "animate"
    %% Maybe this saves some Megabytes for the resulting *.svg
    %% Jean-Michel knows well how to do it though :-)
    %% Jean-François did it for *.gif for animations
    %% see e.g. "anim-Ellipse.tex" in "xint-polexpr" repo for
    %% further explanations. He there presents the command line!!!
    \caelum{Ciel}%
    %% ATTENTION: Now "linewidth" option needs some unit!!!
    %\caelum[linecolor=MidnightBlue!90!cyan,linewidth=0.25pt]{Graticule}%
    %\caelum[linewidth=0.3pt,linecolor=white]{Boundaries}%
    \caelum[linecolor=Yellow]{Ecliptic}%
    %\caelum[linecolor=black]{Graduations}%
    },
    end={\end{pspicture}}
]{7}% 7 frames/s (velocity of the animation)
\multiframe{365}{i=1+1}{%
%% Set SUN
  \calcTfor{\i-1}%
  \CalendarDate{JD+\i-1}%
  \def\RPSun{\FloatToFix{(90-xmDS(T))/20}}%
  \def\APSun{\FloatToFix{-90-xmADS(T)}}%
  \rput(\RPSun;\APSun){\pscircle[fillcolor=Yellow,fillstyle=solid,linecolor=Yellow](0,0){0.15}}%
%% Set MOON
  \def\dec{\lune[\i,2]}%
  \def\asc{\lune[\i,1]}%
  \def\RPMoon{\FloatToFix{(90-\dec)/20}}%
  \def\APMoon{\FloatToFix{-90-\asc}}%
  \rput(\RPMoon;\APMoon){\pscircle[fillstyle=solid,fillcolor=lightgray,linecolor=lightgray](0,0){0.15}}%
  \rput[l](-7,7){Date : \xinteval{day}.\mois{\xinteval{mon}}.\xinteval{yr}}%
}%
\end{animateinline}
\end{document}
