summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/analogclock/analogclock.sty
blob: 93d9426515820201e5052e3b87cfae2b3ed020a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
\ProvidesPackage{analogclock} [2007/10/30 v1.0 analog clock accessory]

%
%  Luis Randez  randez@unizar.es
%  Juan I. Montijano  monti@unizar.es
%
% This program can be redistributed and/or modified under the terms
% of the GNU Public License, version 2.


\RequirePackage{hyperref}
\RequirePackage{xcolor}[2004/05/09]
\RequirePackage{xkeyval}
\RequirePackage{tikz}

\ifdefined\clock@interval\else\def\clock@interval{15}\fi
\DeclareOptionX{timeinterval}{\renewcommand{\clock@interval}{#1}}
\ProcessOptionsX

\newdimen\clock@fontsize
\def\clock@setfontcolor{\clock@temp{.}\let\clock@fontcolor=\clock@tempa}
%\def\clock@setbgcolor{\clock@temp{.}\let\clock@fontcolor=\clock@tempa}


\def\clock@temp#1{\def\clock@tempa##1,##2,##3\@nil{##1 ##2 ##3}%
\extractcolorspec{#1}\clock@tempb
   \expandafter\convertcolorspec\clock@tempb{rgb}\clock@tempb
   \edef\clock@tempa{\expandafter\clock@tempa\clock@tempb\@nil}}

%\clock@temp{black!10}\let\clock@bgcolor=\clock@tempa
\def\clock@bgcolor{black!30}


\def\kk{\mbox{\TextField[name=rolex0, width=2\clock@fontsize, height=2\clock@fontsize, align = 1, charsize =1.1\clock@fontsize, color =\clock@bgcolor, readonly=true, value={}]{}}}

%
\def\initclock{
\vbox to 0pt{
\begin{Form}
$$
\TextField[format=\startclock,name=resultado2, width=0truecm, height=0truecm, bordercolor= 1 1 1, backgroundcolor= 1 1 1,value={}]{}
$$
\end{Form}%
\TextField[name=rolex0, hidden=true, width=0pt, height=0pt,charsize=0pt]{}%
\TextField[name=rolex1, hidden=true, width=0pt, height=0pt,charsize=0pt]{}%
\TextField[name=rolex2, hidden=true, width=0pt, height=0pt,charsize=0pt]{}%
\TextField[name=rolex3, hidden=true, width=0pt, height=0pt,charsize=0pt]{}%
\TextField[name=rolex4, hidden=true, width=0pt, height=0pt,charsize=0pt]{}%
\TextField[name=rolex5, hidden=true, width=0pt, height=0pt,charsize=0pt]{}%
}\vskip -\baselineskip%
}
%
\newbox\sizebox
\newdimen\uu
%
\def\analogclock{\clock@setfontcolor\clock@setfontsize\clock@setfontnumber%
\uu=\f@size pt\raisebox{0.41\clock@fontsize}{\raisebox{-0.41\uu}{\mbox{%
\vrule width 0pt height 2pt%
\kern0.31\clock@fontsize\kern-0.31\uu%
\begin{tikzpicture}[scale=\clock@fontnumber]%
\useasboundingbox (-0.57 pt,-0.72 pt) rectangle (0.89 pt,1.05 pt);
%\clockskin
\faceframe%
\facebg%
\face%
\node at (0 pt,-0.0013 pt) {\colocafield{rolex1}};
\node at (0 pt,-0.0013 pt) {\colocafield{rolex2}};
\end{tikzpicture}%
\vrule width 0pt height 2pt%
}}}%
}%

\newcount\@face
\def\faceclock#1#2{%
\@face=#1\def\@col{#2}%
\ifx\@col\@empty\def\facebg{}\else\fi%
\ifnum\@face<0\def\faceframe{}\else\fi%
\ifnum\@face=4\def\face{}\else\fi%           Esfera sin simbolos
\ifnum\@face=-4\def\face{}\else\fi%           Esfera sin simbolos
\ifnum\@face=2\def\face@type{rolex3}\fi%  Esfera  con muchos simbolos
\ifnum\@face=-1\def\face@type{rolex3}\fi%  Esfera  con muchos simbolos
\ifnum\@face=2\def\face@type{rolex4}\fi%  Esfera  con puntos
\ifnum\@face=-2\def\face@type{rolex4}\fi%  Esfera  con puntos
\ifnum\@face=3\def\face@type{rolex5}\fi%  Esfera  con cuatro rayas
\ifnum\@face=-3\def\face@type{rolex5}\fi%  Esfera  con cuatro rayas
\def\clock@bgcolor{#2}%
}
%

\def\colocafield#1{%
\setbox\sizebox=\hbox{\mbox{\unskip\TextField[name=#1, width=2\clock@fontsize, height=2\clock@fontsize, align = 1, charsize =\clock@fontsize, color =\clock@fontcolor, readonly=true, value={}]{}}}%
\kern-\wd\sizebox\kern 2\clock@fontsize%
\box\sizebox%
}
%
\def\clock@setfontsize{\clock@fontsize=\f@size pt\clock@fontsize=\fac@font\clock@fontsize}
\def\fac@font{1.0}
\def\clocksizefactor#1{\def\fac@font{#1}}


\def\facebg{\fill[fill=\clock@bgcolor] (0,0) circle (0.75 pt);}
\def\faceframe{\draw[color=., thick] (0.00,0.00) circle (0.77 pt);}
\def\face{\node at (0 pt,-0.0013 pt) {\colocafield{\face@type}};\font\peque=cmr5 at 0.12\clock@fontsize \draw (0pt,-0.34 pt)  node {\peque M\&R};}
\def\face@type{rolex3}
\def\clockskin{%
\filldraw[rotate=22, fill=black!10!white] (0.2 pt,0.83 pt) arc (0:180:0.2 pt) -- cycle;
\filldraw[rotate=-22, fill=black!10!white] (0.2 pt,0.83 pt) arc (0:180:0.2 pt) -- cycle;
\draw[very thick] (0 pt, 0.75 pt) -- (0pt,0.92pt)  circle (0.05pt);
\draw[very thick] (-65:0.75 pt) -- (-65:0.90 pt);
\draw[very thick] (-115:0.75 pt) -- (-115:0.90 pt);
}
%\def\clockskin{}

\def\@p{p}
\def\extract@number#1{\edef\clock@tempb{#1 pp}\def\clock@tempa##1##2\@nil{\if##1\@p\else ##1\clock@tempa##2\@nil\fi}
\edef\clock@fontnumber{\expandafter\clock@tempa\clock@tempb\@nil}}
\def\clock@setfontnumber{\extract@number{\the\clock@fontsize}}



%
\def\startclock{%
%
fecha1 = reloj();
run = app.setInterval("reloj();",\clock@interval000);
%
%
function reloj()
{
%
var fObj     = new Date();
var horas    = fObj.getHours();
var minutos  = fObj.getMinutes(); minutos1 = minutos+0.0;
%
horaa=horas+0.0;
if (horaa >= 12) {horaa=horaa-12.0; };
%
%
%this.getField("rolex0").textColor=color.red;
this.getField("rolex0").strokeColor=color.transparent;
this.getField("rolex0").fillColor=color.transparent;
%this.getField("rolex1").textColor=color.red;
this.getField("rolex1").strokeColor=color.transparent;
this.getField("rolex1").fillColor=color.transparent;
%this.getField("rolex2").textColor=color.red;
this.getField("rolex2").strokeColor=color.transparent;
this.getField("rolex2").fillColor=color.transparent;
this.getField("rolex3").strokeColor=color.transparent;
this.getField("rolex3").fillColor=color.transparent;
this.getField("rolex4").strokeColor=color.transparent;
this.getField("rolex4").fillColor=color.transparent;
this.getField("rolex5").strokeColor=color.transparent;
this.getField("rolex5").fillColor=color.transparent;
this.getField("rolex0").textFont="clock";
this.getField("rolex1").textFont="clock";
this.getField("rolex2").textFont="clock";
this.getField("rolex3").textFont="clock";
this.getField("rolex4").textFont="clock";
this.getField("rolex5").textFont="clock";
var str = new String();
numero=Math.floor(192.0 + horaa*5.0 + minutos1/12.0);
str =  String.fromCharCode(48);
this.getField("rolex0").value=str;
str =  String.fromCharCode(numero);
this.getField("rolex1").value=str;
str =  String.fromCharCode(64+minutos1);
this.getField("rolex2").value=str;
str =  String.fromCharCode(49);
this.getField("rolex3").value=str;
str =  String.fromCharCode(50);
this.getField("rolex4").value=str;
str =  String.fromCharCode(51);
this.getField("rolex5").value=str;
}
%
}
%