2017-2018/6e/Calcul_Mental/P4/horloge.sty

141 lines
5.1 KiB
Plaintext
Raw Normal View History

2018-04-16 06:38:15 +00:00
\RequirePackage{contour}
\newcommand{\clockAtick}[2]{%
% colors
\colorlet{minutes color}{blue!50!cyan!70!black}
\colorlet{bg hours 0}{yellow}
\colorlet{bg hours 1}{red!50}
\colorlet{hours color}{red!80!black}
% styles
\tikzset{
minutes/.style={circle,inner sep=0,text width=5mm,align=center,font=\bfseries},
minutes 0/.style={fill=minutes color,text=white,minutes},
minutes 1/.style={text=minutes color,fill=white,minutes},
minutes font/.style={font=\normalsize},
hours/.style={font=\fontsize{60}{66}\selectfont\bfseries,text=hours color,align=center},
mini hours font/.style={font=\fontsize{40}{46}\selectfont\bfseries},
}
% radii
\def\bigradius{80mm}
\def\minuteradius{75mm}
\def\hourradius{60mm}
\def\minihourminradius{25mm}
\def\minihourmaxradius{45mm}
\pgfmathsetmacro\minihourradius{(\minihourmaxradius + \minihourminradius)*.5}
\def\hourwidth{2mm}
\def\minutewidth{1mm}
% big circle
\filldraw [fill=white,draw=minutes color] (0,0) circle (\bigradius);
% minutes marks
\foreach \angle[count=\c from 0,evaluate={\c as \hourmark using notequal(int(mod(\c,5)),0)}]
in {0,6,...,354}{ \path (-\angle:\minuteradius) node[minutes \hourmark]{\c}; }
% hours marks
\foreach \angle[count=\c from 1,evaluate={\c as \col using int(mod(\c,2))}] in {30,60,...,360}{
\path (-\angle:\hourradius) node[hours]{\c};
\path[fill=bg hours \col]
(-\angle:\minihourminradius) -- (-\angle:\minihourmaxradius)
arc(-\angle:-\angle-30:\minihourmaxradius) -- (-\angle-30:\minihourminradius)
arc(-\angle-30:-\angle:\minihourminradius) -- cycle;
\path (-\angle-15:\minihourradius pt) node[mini hours font]{\textcolor{white}{\contour{hours color}{\c}}};
}
% hands
\pgfmathsetmacro\hourangle{-#1*30-#2*.5}
\pgfmathsetmacro\minuteangle{-#2*6}
\fill[rotate=\hourangle,fill=hours color] ++(0,\hourwidth) arc(90:270:\hourwidth) -- ++(50mm,0)
-- ++(\hourwidth,\hourwidth) -- ++(-\hourwidth,\hourwidth) -- ++(-50mm,0) -- cycle ;
\fill[rotate=\minuteangle,fill=minutes color] ++(0,\minutewidth) arc(90:270:\minutewidth) -- ++(70mm,0)
-- ++(\minutewidth,\minutewidth) -- ++(-\minutewidth,\minutewidth) -- ++(-70mm,0) -- cycle ;
}
\newcommand{\clockBtick}[2]{%
\draw (0,0) circle (2cm);
\foreach \angle / \label in
{0/3, 30/2, 60/1, 90/12, 120/11, 150/10, 180/9,
210/8, 240/7, 270/6, 300/5, 330/4}
{
\draw (\angle:1.8cm) -- (\angle:2cm);
\draw (\angle:1.4cm) node{\textsf{\label}};
}
\foreach \angle[count=\c from 0] in {0,6,...,354}
{
\draw (\angle:1.9cm) -- (\angle:2cm);
}
\draw[rotate=90] (0,0) -- (-#1*30-#2*30/60:0.7cm); % hours
\draw[rotate=90] (0,0) -- (-#2*6:1.2cm); % minutes
\path [fill=black] (0,0) circle (3pt);
\path [fill=red] (0,0) circle (1.5pt);
}
\newcommand{\clockA}{%
% colors
\colorlet{minutes color}{blue!50!cyan!70!black}
\colorlet{bg hours 0}{yellow}
\colorlet{bg hours 1}{red!50}
\colorlet{hours color}{red!80!black}
% styles
\tikzset{
minutes/.style={circle,inner sep=0,text width=5mm,align=center,font=\bfseries},
minutes 0/.style={fill=minutes color,text=white,minutes},
minutes 1/.style={text=minutes color,fill=white,minutes},
minutes font/.style={font=\normalsize},
hours/.style={font=\fontsize{60}{66}\selectfont\bfseries,text=hours color,align=center},
mini hours font/.style={font=\fontsize{40}{46}\selectfont\bfseries},
}
% radii
\def\bigradius{80mm}
\def\minuteradius{75mm}
\def\hourradius{60mm}
\def\minihourminradius{25mm}
\def\minihourmaxradius{45mm}
\pgfmathsetmacro\minihourradius{(\minihourmaxradius + \minihourminradius)*.5}
\def\hourwidth{2mm}
\def\minutewidth{1mm}
% big circle
\filldraw [fill=white,draw=minutes color] (0,0) circle (\bigradius);
% minutes marks
\foreach \angle[count=\c from 0,evaluate={\c as \hourmark using notequal(int(mod(\c,5)),0)}]
in {0,6,...,354}{ \path (-\angle:\minuteradius) node[minutes \hourmark]{\c}; }
% hours marks
\foreach \angle[count=\c from 1,evaluate={\c as \col using int(mod(\c,2))}] in {30,60,...,360}{
\path (-\angle:\hourradius) node[hours]{\c};
\path[fill=bg hours \col]
(-\angle:\minihourminradius) -- (-\angle:\minihourmaxradius)
arc(-\angle:-\angle-30:\minihourmaxradius) -- (-\angle-30:\minihourminradius)
arc(-\angle-30:-\angle:\minihourminradius) -- cycle;
\path (-\angle-15:\minihourradius pt) node[mini hours font]{\textcolor{white}{\contour{hours color}{\c}}};
}
\path [fill=black] (0,0) circle (3mm);
\path [fill=red] (0,0) circle (1.5mm);
}
\newcommand{\clockB}{%
\draw (0,0) circle (2cm);
\foreach \angle / \label in
{0/3, 30/2, 60/1, 90/12, 120/11, 150/10, 180/9,
210/8, 240/7, 270/6, 300/5, 330/4}
{
\draw (\angle:1.8cm) -- (\angle:2cm);
\draw (\angle:1.4cm) node{\textsf{\label}};
}
\foreach \angle[count=\c from 0] in {0,6,...,354}
{
\draw (\angle:1.9cm) -- (\angle:2cm);
}
\path [fill=black] (0,0) circle (3pt);
\path [fill=red] (0,0) circle (1.5pt);
}