Adds a clock

This commit is contained in:
Jonathan Hodgson 2020-07-12 14:49:25 +01:00
parent d60a66ef70
commit fe7f15a5ef

44
clock.tex Normal file
View file

@ -0,0 +1,44 @@
\documentclass[tikz]{standalone}
\usepackage{datetime}
\begin{document}
\def\hours{\number\currenthour}
\def\minutes{\number\currentminute}
\def\seconds{\number\currentsecond}
\begin{tikzpicture}
%\node {\Huge \number\currenthour};
\draw[line width=0.2cm] (0,0) circle (5.1cm);
% Minutes
\foreach \i in {1,2,...,60}{
\def\angle{\i*6}
\draw[thin] (\angle:5cm) -- (\angle:4.9cm);
}
% 5 minutes
\foreach \i in {1,2,...,12}{
\def\angle{\i*-30+90}
\draw[thin] (\angle:5cm) -- (\angle:4.5cm);
\node at (\angle:4cm) {\Huge\i};
};
% Hour hand
\def\angle{\hours*-30 + \minutes*-0.5 + \seconds*-0.008333 +90}
\draw[line width=0.1cm] (0,0) -- (\angle:2.5cm);
% Minute hand
\def\angle{\minutes*-6 + \seconds*-0.1 +90}
\draw[line width=0.05cm] (0,0) -- (\angle:4cm);
% Second hand
\def\angle{\seconds*-6+90}
\draw[very thick,color=red] (\angle:-1cm) -- (\angle:4.5cm);
\draw[line width=0.1cm,color=red] (\angle:-1cm) -- (\angle:-0.25cm);
% Center dot
\draw[fill=black] (0,0) circle (0.1cm);
\end{tikzpicture}
\end{document}