summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/profcollege/PfCCible.tex
blob: 91e8f28e0423358c6ca00b586281b7228a8788f8 (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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
%%%
% Cibles
%%%
\def\filedateCible{2024/08/04}%
\def\fileversionCible{0.1}%
\message{-- \filedateCible\space v\fileversionCible}%
%
\newtoks\toklisteciblea%

\def\UpdatetoksCibleA#1\nil{\addtotok\toklisteciblea{"#1",}}%

\setKVdefault[Cible]{RayonBase=5mm,Ecart=5mm,Flechettes=false,RayonF=2.5cm,Impression=false}%

\NewDocumentCommand\Cible{om}{%
  \useKVdefault[Cible]%
  \setKV[Cible]{#1}%
  \toklisteciblea{}%
  \xdef\PfCNombreZone{0}%
  \ifboolKV[Cible]{Flechettes}{}{%
    \setsepchar{,}%
    \readlist*\PfCListeCible{#2}%
    \foreachitem\compteur\in\PfCListeCible{\expandafter\UpdatetoksCibleA\compteur\nil}%
    \xdef\PfCNombreZone{\PfCListeCiblelen}%
  }%
  \BuildCible{\the\toklisteciblea}%
}%

\NewDocumentCommand\BuildCible{m}{%
  \ifluatex%
    \mplibforcehmode%
    \begin{mplibcode}
      Rayon=\useKV[Cible]{RayonBase};
      Ecart=\useKV[Cible]{Ecart};
      boolean Flechettes,Impression;
      Flechettes=\useKV[Cible]{Flechettes};
      Impression=\useKV[Cible]{Impression};
      NombreCercles=\PfCNombreZone;
      
      vardef affichage(text t)=
      pair O;
      O=u*(5,5);
      for k=NombreCercles downto 1:
      if (k mod 2)=0:
      fill cercles(O,Rayon+(k-1)*Ecart) withcolor 0.7white;
      else:
      fill cercles(O,Rayon+(k-1)*Ecart) withcolor white;
      fi;
      endfor;
      for k=1 upto NombreCercles:
      trace cercles(O,Rayon+(k-1)*Ecart);
      endfor;
      n:=0;
      for p_=t:
      n:=n+1;
      if n=NombreCercles:
      label(TEX(p_),O);
      else:
      label(TEX(p_),O+(NombreCercles+0.5-n)*(0,Ecart));
      label(TEX(p_),O-(NombreCercles+0.5-n)*(0,Ecart));
      fi;
      endfor;
      enddef;

      vardef affichageflechettes=
      pair O;
      O=u*(5,5);
      RayonBase=\useKV[Cible]{RayonF};
      RayonA=(170/(0.5*451))*RayonBase;
      RayonI=0.5*(RayonBase+RayonA);
      RayonAa=(162/(0.5*451))*RayonBase;
      RayonB=(107/(0.5*451))*RayonBase;
      RayonBb=(99/(0.5*451))*RayonBase;
      RayonC=(32/(0.5*451))*RayonBase;
      RayonD=(12.7/(0.5*451))*RayonBase;
      path cbase,ca,caa,cb,cbb,cc,cd;
      cbase=cercles(O,RayonBase);
      ca=cercles(O,RayonA);
      caa=cercles(O,RayonAa);
      cb=cercles(O,RayonB);
      cbb=cercles(O,RayonBb);
      cc=cercles(O,RayonC);
      cd=cercles(O,RayonD);
      fill cbase;
      pair A[],Aa[],B[],Bb[],C[],D[],E[];
      for k=1 upto 21:
      A[k]=pointarc(ca,9+(k-1)*18);
      Aa[k]=pointarc(caa,9+(k-1)*18);
      B[k]=pointarc(cb,9+(k-1)*18);
      Bb[k]=pointarc(cbb,9+(k-1)*18);
      C[k]=pointarc(cc,9+(k-1)*18);
      D[k]=pointarc(cd,9+(k-1)*18);
      E[k]=pointarc(cercles(O,RayonI),(k-1)*18);
      endfor;
      for k=2 step 2 until 20:
      fill O--A[k]--arccercle(A[k],A[k+1],O)--cycle withcolor white;
      endfor;
      for k=1 upto 20:
      if (k mod 2)=1:
      fill Aa[k]--A[k]--arccercle(A[k],A[k+1],O)--reverse(arccercle(Aa[k],Aa[k+1],O))--cycle withcolor if Impression:0.4white else: Crimson fi;
      fill Bb[k]--B[k]--arccercle(B[k],B[k+1],O)--reverse(arccercle(Bb[k],Bb[k+1],O))--cycle withcolor if Impression:0.4white else: Crimson fi;
      else:
      fill Aa[k]--A[k]--arccercle(A[k],A[k+1],O)--reverse(arccercle(Aa[k],Aa[k+1],O))--cycle withcolor if Impression:0.8white else: LightGreen fi;
      fill Bb[k]--B[k]--arccercle(B[k],B[k+1],O)--reverse(arccercle(Bb[k],Bb[k+1],O))--cycle withcolor if Impression:0.8white else: LightGreen fi;
      fi;
      endfor;
      fill cc withcolor if Impression:0.8white else: LightGreen fi;
      fill cd withcolor if Impression:0.4white else: Crimson fi;
      trace ca withcolor white;
      trace caa withcolor white;
      trace cb withcolor white;
      trace cbb withcolor white;
      trace cc withcolor white;
      trace cd withcolor white;
      enddef;

      vardef affichagetexteflechettes(text t)=
      drawoptions(withcolor white);
      n:=0;
      for p_=t:
      n:=n+1;
      label(TEX("\bfseries "&p_),E[n]);
      endfor;
      enddef;
      
      if Flechettes:
      affichageflechettes;
      affichagetexteflechettes("6","13","4","18","1","20","5","12","9","14","11","8","16","7","19","3","17","2","15","10");
      else:
      affichage(#1);
      fi;
    \end{mplibcode}
  \else
    \begin{mpost}[mpsettings={Rayon=\useKV[Cible]{RayonBase};Ecart=\useKV[Cible]{Ecart};boolean Flechettes,Impression;Flechettes=\useKV[Cible]{Flechettes};Impression=\useKV[Cible]{Impression};NombreCercles=\PfCNombreZone;}]
      vardef affichage(text t)=
      pair O;
      O=u*(5,5);
      for k=NombreCercles downto 1:
      if (k mod 2)=0:
      fill cercles(O,Rayon+(k-1)*Ecart) withcolor 0.7white;
      else:
      fill cercles(O,Rayon+(k-1)*Ecart) withcolor white;
      fi;
      endfor;
      for k=1 upto NombreCercles:
      trace cercles(O,Rayon+(k-1)*Ecart);
      endfor;
      n:=0;
      for p_=t:
      n:=n+1;
      if n=NombreCercles:
      label(LATEX(p_),O);
      else:
      label(LATEX(p_),O+(NombreCercles+0.5-n)*(0,Ecart));
      label(LATEX(p_),O-(NombreCercles+0.5-n)*(0,Ecart));
      fi;
      endfor;
      enddef;

      vardef affichageflechettes=
      pair O;
      O=u*(5,5);
      RayonBase=\useKV[Cible]{RayonF};
      RayonA=(170/(0.5*451))*RayonBase;
      RayonI=0.5*(RayonBase+RayonA);
      RayonAa=(162/(0.5*451))*RayonBase;
      RayonB=(107/(0.5*451))*RayonBase;
      RayonBb=(99/(0.5*451))*RayonBase;
      RayonC=(32/(0.5*451))*RayonBase;
      RayonD=(12.7/(0.5*451))*RayonBase;
      path cbase,ca,caa,cb,cbb,cc,cd;
      cbase=cercles(O,RayonBase);
      ca=cercles(O,RayonA);
      caa=cercles(O,RayonAa);
      cb=cercles(O,RayonB);
      cbb=cercles(O,RayonBb);
      cc=cercles(O,RayonC);
      cd=cercles(O,RayonD);
      fill cbase;
      pair A[],Aa[],B[],Bb[],C[],D[],E[];
      for k=1 upto 21:
      A[k]=pointarc(ca,9+(k-1)*18);
      Aa[k]=pointarc(caa,9+(k-1)*18);
      B[k]=pointarc(cb,9+(k-1)*18);
      Bb[k]=pointarc(cbb,9+(k-1)*18);
      C[k]=pointarc(cc,9+(k-1)*18);
      D[k]=pointarc(cd,9+(k-1)*18);
      E[k]=pointarc(cercles(O,RayonI),(k-1)*18);
      endfor;
      for k=2 step 2 until 20:
      fill O--A[k]--arccercle(A[k],A[k+1],O)--cycle withcolor white;
      endfor;
      for k=1 upto 20:
      if (k mod 2)=1:
      fill Aa[k]--A[k]--arccercle(A[k],A[k+1],O)--reverse(arccercle(Aa[k],Aa[k+1],O))--cycle withcolor if Impression:0.4white else: Crimson fi;
      fill Bb[k]--B[k]--arccercle(B[k],B[k+1],O)--reverse(arccercle(Bb[k],Bb[k+1],O))--cycle withcolor if Impression:0.4white else: Crimson fi;
      else:
      fill Aa[k]--A[k]--arccercle(A[k],A[k+1],O)--reverse(arccercle(Aa[k],Aa[k+1],O))--cycle withcolor if Impression:0.8white else: LightGreen fi;
      fill Bb[k]--B[k]--arccercle(B[k],B[k+1],O)--reverse(arccercle(Bb[k],Bb[k+1],O))--cycle withcolor if Impression:0.8white else: LightGreen fi;
      fi;
      endfor;
      fill cc withcolor if Impression:0.8white else: LightGreen fi;
      fill cd withcolor if Impression:0.4white else: Crimson fi;
      trace ca withcolor white;
      trace caa withcolor white;
      trace cb withcolor white;
      trace cbb withcolor white;
      trace cc withcolor white;
      trace cd withcolor white;
      enddef;

      vardef affichagetexteflechettes(text t)=
      drawoptions(withcolor white);
      n:=0;
      for p_=t:
      n:=n+1;
      % label(LATEX("\noexpand\bfseries "&p_),E[n]);
      label(LATEX(p_),E[n]);
      endfor;
      enddef;
      
      if Flechettes:
      affichageflechettes;
      affichagetexteflechettes("6","13","4","18","1","20","5","12","9","14","11","8","16","7","19","3","17","2","15","10");
      else:
      affichage(#1);
      fi;
    \end{mpost}
  \fi
}%