-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbidipresentation.cls
3450 lines (3237 loc) · 156 KB
/
bidipresentation.cls
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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
%%
%% This is file `bidipresentation.cls',
%%
%% __________________________________________________
%% Copyright © 2009–2014 Vafa Khalighi <[email protected]>
%%
%% A great portion of the code is brorrowd from texpower bundle:
%%
%% -------------------------------------------------------------------------------------
%% TeXPower bundle - dynamic online presentations with LaTeX
%% Copyright (C) 1999-2004 Stephan Lehmke
%% Copyright (C) 2003-2005 Hans Fredrik Nordhaug
%% -------------------------------------------------------------------------------------
%%
%% with modifications to get things working properly in both right to
%% left and left to right modes.
%%
%% It may be distributed and/or modified under the LaTeX Project Public License,
%% version 1.3c or higher (your choice). The latest version of
%% this license is at: http://www.latex-project.org/lppl.txt
%%
%% This work is “author-maintained” (as per LPPL maintenance status)
%% by Vafa Khalighi.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{bidipresentation}[2014/09/26 v0.3 Experimental bidi presentation]
\RequirePackage{scrlfile}
\RequirePackage{fancyhdr}
\RequirePackage{ifthen}
\RequirePackage{calc}
\RequirePackage{keyval}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\newboolean{verbose@bidipres}
\DeclareOption{verbose}{\setboolean{verbose@bidipres}{true}}
\provideboolean{display}
\DeclareOption{display}{\setboolean{display}{true}}
\DeclareOption{printout}{\setboolean{display}{false}}
\newboolean{fixcolorstack@bidipres}
\DeclareOption{fixcolorstack}{\setboolean{fixcolorstack@bidipres}{true}}
\newboolean{strongfiltering@bidipres}
\DeclareOption{strongfiltering}{\setboolean{strongfiltering@bidipres}{true}}
\newcommand{\strongfilteringon}{\setboolean{strongfiltering@bidipres}{true}}
\newcommand{\strongfilteringoff}{\setboolean{strongfiltering@bidipres}{false}}
\newboolean{nineminutes@bidipres}
\DeclareOption{nineminutes}{\setboolean{nineminutes@bidipres}{true}}
\newboolean{bidiprescolor}
\newboolean{coloremph@bidipres}
\DeclareOption{coloremph}
{\setboolean{bidiprescolor}{true}\setboolean{coloremph@bidipres}{true}}
\newboolean{colormath@bidipres}
\DeclareOption{colormath}
{\setboolean{bidiprescolor}{true}\setboolean{colormath@bidipres}{true}}
\newboolean{colorhighlight@bidipres}
\DeclareOption{colorhighlight}
{\setboolean{bidiprescolor}{true}\setboolean{colorhighlight@bidipres}{true}}
\newboolean{whitebackground@bidipres}
\setboolean{whitebackground@bidipres}{true}% This is the default.
\DeclareOption{whitebackground}
{\setboolean{bidiprescolor}{true}\setboolean{whitebackground@bidipres}{true}}
\newboolean{lightbackground@bidipres}
\DeclareOption{lightbackground}
{\setboolean{bidiprescolor}{true}\setboolean{lightbackground@bidipres}{true}}
\newboolean{blackbackground@bidipres}
\DeclareOption{blackbackground}
{\setboolean{bidiprescolor}{true}\setboolean{blackbackground@bidipres}{true}}
\newboolean{darkbackground@bidipres}
\DeclareOption{darkbackground}
{\setboolean{bidiprescolor}{true}\setboolean{darkbackground@bidipres}{true}}
\ExecuteOptions{display}
\ProcessOptions\relax
\LoadClass{article}
\RequirePackage[foot=10.2pt,head=0pt,paperwidth=128mm,paperheight=96mm,left=5mm,top=5mm,right=7mm,bottom=8mm]{geometry}
\renewcommand{\headrulewidth}{0mm}
\renewcommand{\maketitle}%
{\ClassError{bidipresentation}{Caution: ``maketitle'' command not supported}%
{Please use ``titlepage'' environment instead}%
}
\RequirePackage{hyperref}
\fancypagestyle{pres}{%
\lhead{}%
\chead{}%
\rhead{}%
\ifthenelse{\boolean{bidiprescolor}}{%
\lfoot{\xecolor{textcolor}\footnotesize \thepage}}{%
\lfoot{\footnotesize \thepage}}
\cfoot{}%
\rfoot{}%
}
\pagestyle{pres}
\newcommand{\distance}[1]{\vspace*{\stretch{#1}}}
\newcommand{\abstand}[1]{\vspace*{\stretch{#1}}}
\setlength{\parskip}{0.6ex}
\setlength{\parindent}{0mm}
\newenvironment{plainslide}[1][]%
{{\raggedleft \large\bfseries #1\par}\par\vspace*{\stretch{1}}}%
{\par\vspace*{\stretch{1}}\newpage}
\newenvironment{rawslide}{}{\newpage}%
\def\itemize{%
\ifnum \@itemdepth >\thr@@\@toodeep\else
\advance\@itemdepth\@ne
\edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
\expandafter
\list
\csname\@itemitem\endcsname
{\def\makelabel##1{\hss\llap{##1}}}%
\fi
\setlength{\itemsep}{0ex}%
\setlength{\parskip}{0.1ex}%
\setlength{\parsep}{0ex}%
}%
\let\enditemize =\endlist
\def\enumerate{%
\ifnum \@enumdepth >\thr@@\@toodeep\else
\advance\@enumdepth\@ne
\edef\@enumctr{enum\romannumeral\the\@enumdepth}%
\expandafter
\list
\csname label\@enumctr\endcsname
{\usecounter\@enumctr\def\makelabel##1{\hss\llap{##1}}}%
\fi
\setlength{\itemsep}{0ex}%
\setlength{\parskip}{0.1ex}%
\setlength{\parsep}{0ex}%
}%
\let\endenumerate =\endlist
\renewenvironment{description}
{\list{}{\labelwidth\z@ \itemindent-\leftmargin
\let\makelabel\descriptionlabel}
\setlength{\itemsep}{0ex}%
\setlength{\parskip}{0.1ex}%
\setlength{\parsep}{0ex}}
{\endlist}
\ifthenelse{\boolean{display}}
{\ClassInfo{bidipresentation}{Producing display version. Dynamic features activated.}}
{\ClassInfo{bidipresentation}{Producing printout version. Dynamic features inactive.}}
\ifthenelse{\boolean{verbose@bidipres}}{\setcounter{errorcontextlines}{10000}}{}
\newcounter{tmpcnta@bidipres}
\newcounter{tmpcntb@bidipres}
\newlength{\tempdima@bidipres}
\newlength{\tempdimb@bidipres}
\newbox\tempbox@bidipres
\newboolean{carryon@bidipres}
\newcommand{\bidiprespagewidth}{\strip@pt\paperwidth truept}
\newcommand{\bidiprespageheight}{\strip@pt\paperheight truept}
\newcommand{\mkfactor}[2]%
{\setlength{\tempdima@bidipres}{1pt*#2}\edef#1{\strip@pt\tempdima@bidipres}}
\newcommand{\mklength@bidipres}[2]
{\setlength{\tempdima@bidipres}{#2}\edef#1{\the\tempdima@bidipres}}
\newcommand{\mklength}{}
\let\mklength\mklength@bidipres
\ifthenelse{\boolean{bidiprescolor}}{%
\RequirePackage{color}%
\RequirePackage{xecolor}%
}{}%
\ifthenelse{\boolean{bidiprescolor}}{% Yes.
\let\setcolor@bidipres=\color%
\let\o@definecolor@bidipres=\definecolor%
\def\definecolor#1#2#3%
{%
\o@definecolor@bidipres{#1}{#2}{#3}%
\expandafter\edef\csname colordef@bidipres@#1\endcsname%
{\csname processcolor@bidipres@#2\endcsname{#3}}%
}%
\@ifundefined{c@lor@namefile}{}{\input{\c@lor@namefile}}
\ifx\color@gray\@undefined
\ifx\color@rgb\@undefined
\else
\definecolor{black}{rgb}{0,0,0}
\definecolor{white}{rgb}{1,1,1}
\fi
\else
\definecolor{black}{gray}{0}
\definecolor{white}{gray}{1}
\fi
\ifx\color@rgb\@undefined\else
\definecolor{red}{rgb}{1,0,0}
\definecolor{green}{rgb}{0,1,0}
\definecolor{blue}{rgb}{0,0,1}
\fi
\ifx\color@cmyk\@undefined\else
\definecolor{cyan}{cmyk}{1,0,0,0}
\definecolor{magenta}{cmyk}{0,1,0,0}
\definecolor{yellow}{cmyk}{0,0,1,0}
\fi
\newcommand{\interpolate@bidipres}[3]%
{%
\setlength{\tempdima@bidipres}{1pt-#1pt}% Calculate the second factor for the weighted average.
\edef\secondfactor@bidipres{\strip@pt\tempdima@bidipres}%
\setlength{\tempdima@bidipres}{#2pt*\real{#1}+#3pt*\real{\secondfactor@bidipres}}% Calculate the weighted average.
\ifthenelse{\lengthtest{\tempdima@bidipres<0pt}}% Bound the result to the interval [0,1] (just in case the first
{\setlength{\tempdima@bidipres}{0pt}}% factor was not from [0,1]).
{\ifthenelse{\lengthtest{\tempdima@bidipres>1pt}}{\setlength{\tempdima@bidipres}{1pt}}{}}%
\edef\result@bidipres{\strip@pt\tempdima@bidipres}%
}
\def\interpolate@three@bidipres#1,#2,#3;#4,#5,#6;#7%
{%
\interpolate@bidipres{#7}{#1}{#4}% First intermediary value.
\edef\newcolordef@bidipres{\result@bidipres,}% Store first value.
\interpolate@bidipres{#7}{#2}{#5}% Second intermediary value.
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres,}% Store second value.
\interpolate@bidipres{#7}{#3}{#6}% Third intermediary value.
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres}% Store third value.
}
\def\interpolate@four@bidipres#1,#2,#3,#4;#5,#6,#7,#8;#9%
{%
\interpolate@bidipres{#9}{#1}{#5}% First intermediary value.
\edef\newcolordef@bidipres{\result@bidipres,}% Store first value.
\interpolate@bidipres{#9}{#2}{#6}% Second intermediary value.
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres,}% Store second value.
\interpolate@bidipres{#9}{#3}{#7}% Third intermediary value.
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres,}% Store third value.
\interpolate@bidipres{#9}{#4}{#8}% Fourth intermediary value.
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres}% Store fourth value.
}
\def\convert@cmykvalue@rgbvalue@bidipres#1#2%
{%
\setlength{\tempdima@bidipres}{1pt-#1pt-#2pt}%
\ifthenelse{\lengthtest{\tempdima@bidipres<0pt}}{\setlength{\tempdima@bidipres}{0pt}}{}%
\edef\result@bidipres{\strip@pt\tempdima@bidipres}%
}%
\def\convert@cmyk@rgb@bidipres#1,#2,#3,#4;%
{%
\convert@cmykvalue@rgbvalue@bidipres{#1}{#4}%
\edef\newcolordef@bidipres{\result@bidipres,}% Store first value.
\convert@cmykvalue@rgbvalue@bidipres{#2}{#4}%
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres,}% Store second value.
\convert@cmykvalue@rgbvalue@bidipres{#3}{#4}%
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres}% Store third value.
}
\def\convert@RGBvalue@rgbvalue@bidipres#1%
{%
\setlength{\tempdima@bidipres}{#1pt/255}%
\edef\result@bidipres{\strip@pt\tempdima@bidipres}%
}%
\def\convert@RGB@rgb@bidipres#1,#2,#3;%
{%
\convert@RGBvalue@rgbvalue@bidipres{#1}%
\edef\newcolordef@bidipres{\result@bidipres,}% Store first value.
\convert@RGBvalue@rgbvalue@bidipres{#2}%
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres,}% Store second value.
\convert@RGBvalue@rgbvalue@bidipres{#3}%
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres}% Store third value.
}
\newcommand{\colorbetween}[4][.5]%
{%
\begingroup% Make the definition of \processcolor... local.
\newcommand{\processcolor@bidipres@rgb}[3]% What if the first color is an rgb color?
{%
\ifx##2\processcolor@bidipres@rgb% Are both colors rgb colors?
\interpolate@three@bidipres##1;##3;{#1}% Calculate interpolated values.
\else
\ifx##2\processcolor@bidipres@gray% Is the second color from the gray model?
\interpolate@three@bidipres##1;##3,##3,##3;{#1}% Calculate interpolated values.
\else
\ifx##2\processcolor@bidipres@cmyk% Is the second color from the cmyk model?
\convert@cmyk@rgb@bidipres##3;% Convert to rgb.
\edef\newcolordef@bidipres{\noexpand\interpolate@three@bidipres##1;\newcolordef@bidipres;{#1}}%
\newcolordef@bidipres
\else
\ifx##2\processcolor@bidipres@RGB% Is the second color from the RGB model?
\convert@RGB@rgb@bidipres##3;% Convert to rgb.
\edef\newcolordef@bidipres{\noexpand\interpolate@three@bidipres##1;\newcolordef@bidipres;{#1}}%
\newcolordef@bidipres
\else
\ifx##2\processcolor@bidipres@hsb% Is the second color from the hsb model?
\ClassError{bidipresentation}{Don't know how to convert an hsb color!}
\fi
\fi
\fi
\fi
\fi
\edef\newcolordef@bidipres{{rgb}{\newcolordef@bidipres}}% Store the result
}%
\newcommand{\processcolor@bidipres@gray}[3]% What if the first color is a gray color?
{%
\ifx##2\processcolor@bidipres@gray% Are both colors gray colors?
\interpolate@bidipres{#1}{##1}{##3}% Calculate interpolated value.
\edef\newcolordef@bidipres{{gray}{\result@bidipres}}% Store the result
\else
\processcolor@bidipres@rgb{##1,##1,##1}{##2}{##3}% Otherwise, convert first color to rgb and continue.
\fi
}%
\newcommand{\processcolor@bidipres@cmyk}[3]% What if the first color is a cmyk color?
{%
\ifx##2\processcolor@bidipres@cmyk% Are both colors cmyk colors?
\interpolate@four@bidipres##1;##3;{#1}% Calculate interpolated values.
\edef\newcolordef@bidipres{{cmyk}{\newcolordef@bidipres}}% Store the result
\else
\convert@cmyk@rgb@bidipres##1;% Otherwise, convert first color to rgb ...
\expandafter\processcolor@bidipres@rgb\expandafter{\newcolordef@bidipres}{##2}{##3}% ... and continue.
\fi
}%
\newcommand{\processcolor@bidipres@RGB}[3]% What if the first color is an RGB color?
{%
\convert@RGB@rgb@bidipres##1;% Convert to rgb ...
\expandafter\processcolor@bidipres@rgb\expandafter{\newcolordef@bidipres}{##2}{##3}% ... and continue.
}%
\newcommand{\processcolor@bidipres@hsb}[3]% What if the first color is an hsb color?
{%
\ifx##2\processcolor@bidipres@hsb% Are both colors hsb colors?
\interpolate@three@bidipres##1;##3;{#1}% Calculate interpolated values.
\edef\newcolordef@bidipres{{hsb}{\newcolordef@bidipres}}% Store the result
\else
\ClassError{bidipresentation}{Don't know how to convert an hsb color!}
\fi
}%
\expandafter\let\expandafter
\firstcol@bidipres\csname colordef@bidipres@#3\endcsname % Retrieve definition of color <source1>...
\expandafter\expandafter\expandafter\firstcol@bidipres% and apply (remember \processcolor... is part of the definition)
\csname colordef@bidipres@#4\endcsname% to definition of color <source2>.
\edef\end@bidipres% Define color <target> (outside the enclosing group).
{\endgroup\noexpand\definecolor{#2}\newcolordef@bidipres}%
\end@bidipres
}% matches \newcommand{\colorbetween}
\newcommand{\complement@bidipres}[1]%
{%
\setlength{\tempdima@bidipres}{1pt-#1pt}%
\edef\result@bidipres{\strip@pt\tempdima@bidipres}%
}
\def\complement@three@bidipres#1,#2,#3;%
{%
\complement@bidipres{#1}%
\edef\newcolordef@bidipres{\result@bidipres,}% Store first value.
\complement@bidipres{#2}%
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres,}% Store second value.
\complement@bidipres{#3}%
\edef\newcolordef@bidipres{\newcolordef@bidipres\result@bidipres}% Store third value.
}
\def\grabfourth@bidipres#1,#2,#3,#4;%
{%
\def\mem@bidipres{#4}% Store fourth element.
\def\result@bidipres{#1,#2,#3;}% Store first three elements.
}
\newcommand{\complementcolor}[2]%
{%
\begingroup% Make the definition of \processcolor... local.
\newcommand{\processcolor@bidipres@rgb}[1]% What if the color is an rgb color?
{%
\complement@three@bidipres##1;% Calculate complemented values.
\edef\newcolordef@bidipres{{rgb}{\newcolordef@bidipres}}% Store the result
}%
\newcommand{\processcolor@bidipres@gray}[1]% What if the color is a gray color?
{%
\complement@bidipres{##1}% Calculate complemented value.
\edef\newcolordef@bidipres{{gray}{\result@bidipres}}% Store the result
}%
\newcommand{\processcolor@bidipres@cmyk}[1]% What if the color is a cmyk color?
{%
\grabfourth@bidipres##1;% Remember fourth element.
\expandafter\complement@three@bidipres\result@bidipres% Calculate complemented values of first three elements.
\edef\newcolordef@bidipres{{cmyk}{\newcolordef@bidipres,\mem@bidipres}}% Store the result, putting back the fourth element.
}%
\newcommand{\processcolor@bidipres@RGB}[1]% What if the color is an RGB color?
{%
\convert@RGB@rgb@bidipres##1;% Convert to rgb ...
\expandafter\processcolor@bidipres@rgb\expandafter{\newcolordef@bidipres}% ... and continue.
}%
\newcommand{\processcolor@bidipres@hsb}[1]% What if the color is an hsb color?
{%
\complement@three@bidipres##1;% Calculate complemented values.
\edef\newcolordef@bidipres{{hsb}{\newcolordef@bidipres}}% Store the result
}%
\csname colordef@bidipres@#2\endcsname% Execute definition of color <source> (which contains \processcolor...)
\edef\end@bidipres% Define color <target> (outside the enclosing group).
{\endgroup\noexpand\definecolor{#1}\newcolordef@bidipres}%
\end@bidipres
}% matches \newcommand{\complementcolor}
}% matches \ifthenelse{\boolean{bidiprescolor}}{% Yes.
{% No. Do nothing.
}
\newcommand{\replacecolor}
{%
\let\replacecolor@hook@bidipres=\@gobble% This hook can be used for variant checking (see below).
\replacecolor@bidipres% Pick up arguments.
}
\newcommand{\replacecolor@bidipres}[2][]% Pick up the first two arguments of \replacecolor.
{%
\ifthenelse{\equal{#1}{}}{\edef\tcolname@bidipres{#2}}{\edef\tcolname@bidipres{#2@#1}}% Construct `real' target color name.
\@replacecolor@bidipres% Read second argument.
}%
\ifthenelse{\boolean{bidiprescolor}}% Only if bidipresentation's color management is active.
{% Yes.
\newcommand{\undefinecolor@bidipres}[1]% Make a color undefined.
{\expandafter\let\csname\string\color @#1\endcsname=\@undefined}%
\newcommand{\ifcolorexists@bidipres}[3]% Conditional for testing whether a color is defined.
{\@ifundefined{\string\color @#1}{#3}{#2}}% Test whether a given color is defined.
\newcommand{\@replacecolor@bidipres}[2][]% Second part of \replacecolor.
{%
\ifthenelse{\equal{#1}{}}{\edef\scolname@bidipres{#2}}{\edef\scolname@bidipres{#2@#1}}% Construct `real' source color name.
\ifcolorexists@bidipres{\scolname@bidipres}% Does the source color exist at all?
{% Yes.
\replacecolor@hook@bidipres{\tcolname@bidipres}% Execute hook.
\expandafter\let\csname\string\color @\tcolname@bidipres\expandafter\endcsname% Make value of target color
\csname\string\color @\scolname@bidipres\endcsname% identical with source color.
\expandafter\let\csname colordef@bidipres@\tcolname@bidipres\expandafter\endcsname% Make definition of target color
\csname colordef@bidipres@\scolname@bidipres\endcsname% identical with source color.
}%
{% No. Do nothing.
}%
}%
\newcommand{\colors@bidipres}{}
\newcommand{\removecolor@bidipres}[1]%
{%
\def\processme@bidipres##1% This macro does the real work.
{%
\ifthenelse{\equal{#1}{##1}}% Is this the color to be removed?
{% Yes. Do nothing, so it vanishes.
}
{% No. Re-insert.
\expandafter\def\expandafter\colors@bidipres\expandafter{\colors@bidipres\processme@bidipres{##1}}%
}%
}%
\expandafter\let\expandafter\colors@bidipres\expandafter\empty% Initialize \colors@bidipres.
\colors@bidipres% Execute \processme@bidipres for every color on the list.
}
\newcommand{\addbidiprescolor}[1]%
{%
\removecolor@bidipres{#1}% Remove this color from the list (to avoid duplicates).
\expandafter\def\expandafter\colors@bidipres\expandafter{\colors@bidipres\processme@bidipres{#1}}% ... and insert.
\register@normalvariant@bidipres{#1}% Register the normal variant for this color.
}
\newcommand{\definebidiprescolor}[4][]
{%
\addbidiprescolor{#2}% Add color to the list.
\ifthenelse{\equal{#1}{}}% Color from the current color set?
{\definecolor{#2}{#3}{#4}}% Yep. Just define the color.
{\definecolor{#2@#1}{#3}{#4}}% No. Add color set identifyer.
}
\newcommand{\replacecolors@bidipres}%
{%
\@ifstar% The starred version will put the color set into normal variant.
{\let\replacecolor@hook@bidipres=\register@normalvariant@bidipres\@replacecolors@bidipres}
{\let\replacecolor@hook@bidipres=\@gobble\@replacecolors@bidipres}%
}
\newcommand{\@replacecolors@bidipres}[4]% This part does the real work.
{%
\def\processme@bidipres##1{\replacecolor@bidipres[#1]{#2##1}[#3]{#4##1}}%
\colors@bidipres
}
\newcommand{\usecolorset}[1]%
{%
\replacecolors@bidipres*{}{}{#1}{}% Replace normal variant (registering variants).
\replacecolors@bidipres{}{d}{#1}{d}% Replace dimmed variant.
\replacecolors@bidipres{}{e}{#1}{e}% Replace enhanced variant.
\xecolor{textcolor}% Activate textcolor.
\pagecolor{pagecolor}% Activate pagecolor.
}%
\newcommand{\dumpcolorset}[1]%
{%
\nonnormalwarnings@bidipres{Dumping color set #1}% Output a warning for every color not in the normal variant.
\replacecolors@bidipres{#1}{}{}{}% Dump normal variant (hopefully).
\replacecolors@bidipres{#1}{d}{}{d}% Dump dimmed variant.
\replacecolors@bidipres{#1}{e}{}{e}% Dump enhanced variant.
}%
\newcommand{\registervariant@bidipres}[2]% Remember which variant a color is currently in.
{\expandafter\def\csname cvar@#1@bidipres\endcsname{#2}}
\newcommand{\register@normalvariant@bidipres}[1]% Register that a color is now in the normal variant.
{\registervariant@bidipres{#1}{}}
\newcommand{\currentvariant@bidipres}[1]% Return the current variant of a color.
{\csname cvar@#1@bidipres\endcsname}
\newcommand{\ifnormalvariant@bidipres}[3]% Conditional for checking whether a color is in the normal variant.
{\ifthenelse{\equal{\currentvariant@bidipres{#1}}{}}{#2}{#3}}
\newcommand{\nonnormalwarnings@bidipres}[1]% Checks the current variant for every standard color and gives a warning
{% if it's not the normal one.
\def\processme@bidipres##1%
{%
\ifnormalvariant@bidipres{##1}{}
{%
\ClassWarning{bidipresentation}
{#1\MessageBreak when color ##1 is in \currentvariant@bidipres{##1} variant}%
}%
}%
\colors@bidipres
}
\newcommand{\dimlevel}{.7}
\newcommand{\dimcolor}[2][\dimlevel]
{%
\ifnormalvariant@bidipres{#2}% Color in the normal variant?
{% Yes.
\registervariant@bidipres{#2}{d}% Register dimmed variant.
\ifcolorexists@bidipres{d#2}% Dedicated dimmed color found?
{\replacecolor{#2}{d#2}}% Yes. use that one.
{\colorbetween[#1]{#2}{pagecolor}{#2}}% No. Dim numerically using \colorbetween.
}%
{}% No. Do nothing.
}
\newcommand{\dimcolors}[1][\dimlevel]
{%
\def\processme@bidipres##1{\dimcolor[#1]{##1}}%
\colors@bidipres
}%
\newcommand{\enhancelevel}{.5}
\newcommand{\enhancecolor}[2][\enhancelevel]
{%
\ifnormalvariant@bidipres{#2}% Color in the normal variant?
{%
\registervariant@bidipres{#2}{e}% Register enhanced variant.
\ifcolorexists@bidipres{e#2}% Dedicated enhanced color found?
{\replacecolor{#2}{e#2}}% Yes. use that one.
{\colorbetween[-#1]{#2}{pagecolor}{#2}}% No. Enhance numerically using \colorbetween.
}%
{}%
}%
\newcommand{\enhancecolors}[1][\enhancelevel]
{%
\def\processme@bidipres##1{\enhancecolor[#1]{##1}}%
\colors@bidipres
}%
\newcommand{\replacecolorsbyone@bidipres}[2]%
{%
\def\processme@bidipres##1{\replacecolor{#1##1}{#2}}%
\colors@bidipres
}
\newcommand{\vanishcolor}{pagecolor}
\newcommand{\vanishcolors}[1][\vanishcolor]{\replacecolorsbyone@bidipres{}{#1}}
\input{bidiprescolors.cfg}
\newcommand{\whitebackground}%
{%
\usecolorset{whitebg}%
}
\ifthenelse{\boolean{whitebackground@bidipres}}
{\AtEndOfClass{\whitebackground}}
{}
\newcommand{\lightbackground}%
{%
\usecolorset{lightbg}%
}
\ifthenelse{\boolean{lightbackground@bidipres}}{\AtEndOfClass{\lightbackground}}{}
\newcommand{\darkbackground}%
{%
\usecolorset{darkbg}%
}
\ifthenelse{\boolean{darkbackground@bidipres}}{\AtEndOfClass{\darkbackground}}{}
\newcommand{\blackbackground}%
{%
\usecolorset{blackbg}%
}
\ifthenelse{\boolean{blackbackground@bidipres}}{\AtEndOfClass{\blackbackground}}{}
\ifthenelse{\boolean{bidiprescolor}}
{%
\renewcommand{\normalcolor}{\xecolor{textcolor}}% \normalcolor should produce textcolor.
\let\o@textnormal@bidipres=\textnormal% \textnormal should also set text color.
\def\textnormal#1{\o@textnormal@bidipres{\normalcolor#1}}
\AtEndOfClass{\xecolor{textcolor}\let\default@color\current@color}
\AtBeginDocument%
{%
\pagecolor{pagecolor}\xecolor{textcolor}%
}%
}
{}
\ifthenelse{\boolean{bidiprescolor}}{\AtBeginDocument{\pagecolor{pagecolor}\xecolor{textcolor}}}{}
}% matches \ifthenelse{\boolean{bidiprescolor}}{% Yes.
{% No; provide dummies.
\let\setcolor@bidipres=\@gobble%
\newcommand{\@replacecolor@bidipres}[2][]{}%
\let\addbidiprescolor=\@gobble
\newcommand{\definebidiprescolor}[4][]{}%
\let\usecolorset=\@gobble
\let\dumpcolorset=\@gobble
\newcommand{\dimcolor}[2][]{}
\newcommand{\dimcolors}[1][]{}
\newcommand{\enhancecolor}[2][]{}
\newcommand{\enhancecolors}[1][]{}
\newcommand{\vanishcolors}[1][]{}
}
\ifthenelse{\boolean{coloremph@bidipres}}% Should \emph use color?
{% Yes;
\DeclareRobustCommand{\em}% Redefine \em.
{%
\@nomath\em \xecolor{emcolor}% Change color.
\replacecolor{tmp@bidipres}{emcolor}% Exchange emcolor and altemcolor.
\replacecolor{emcolor}{altemcolor}%
\replacecolor{altemcolor}{tmp@bidipres}%
}%
}%
{}% No; keep original definition.
\ifthenelse{\boolean{colorhighlight@bidipres}}% Color highlighting enabled?
{% Yes; code is displayed typewriter-style, bold and in a special color.
\DeclareRobustCommand{\code}[1]{\textxecolor{codecolor}{\textbf{\texttt{#1}}}}%
\DeclareRobustCommand{\codeswitch}{\xecolor{codecolor}\bfseries\ttfamily}%
}
{% No; code is displayed just in typewriter-style and bold.
\DeclareRobustCommand{\code}[1]{\textbf{\texttt{#1}}}%
\DeclareRobustCommand{\codeswitch}{\bfseries\ttfamily}%
}
\newcommand{\macroname}[1]{\code{\textbackslash#1}}
\newcommand{\commandapp}[3][]{\code{\macroname{#2}\ifthenelse{\equal{#1}{}}{}{[#1]}\{#3\}}}
\newcommand{\carg}[1]{\code{\origmath{\left<\code{#1}\right>}}}
\ifthenelse{\boolean{colorhighlight@bidipres}}% Color highlighting enabled?
{% Yes;
\DeclareRobustCommand{\underl}{\textxecolor{underlcolor}}% Use color to highlight.
}
{% No;
\DeclareRobustCommand{\underl}{\textbf}% Use bold face.
}
\ifthenelse{\boolean{colorhighlight@bidipres}}% Color highlighting enabled?
{% Yes;
\DeclareRobustCommand{\concept}{\textxecolor{conceptcolor}}% Use color to highlight.
}
{% No;
\DeclareRobustCommand{\concept}{\textbf}% Use bold face.
}
\ifthenelse{\boolean{colorhighlight@bidipres}}% Color highlighting enabled?
{% Yes;
\DeclareRobustCommand{\inactive}{\textxecolor{inactivecolor}}% Use color to highlight.
}
{% No;
\DeclareRobustCommand{\inactive}{\monochromeinactive}% Use monochrome default.
}
\providecommand{\monochromeinactive}{}% What should \inactive do if colors can't be used? We provide a hook for
% user definitions.
\ifthenelse{\boolean{colorhighlight@bidipres}}% Color highlighting enabled?
{% Yes; use a colored box.
\newcommand{\present}[2][]{\leavevmode\llap{\textbf{\footnotesize#1}\,}\fcolorbox{textcolor}{presentcolor}{#2}}%
\newcommand{\mkpbox@bidipres}[1]{\fcolorbox{presentcolor}{presentcolor}{#1}}% Internal macro for use by \presentbox.
}
{% No; use an \fbox.
\newcommand{\present}[2][]{\leavevmode\llap{\textbf{\footnotesize#1}\,}\fbox{#2}}%
\newcommand{\mkpbox@bidipres}[1]{\fbox{#1}}%
}
\newsavebox{\pbox@bidipres}% Container for the minipage to be boxed.
\newenvironment{presentbox}%
{%
\par\smallskip% First a small space to separate the area from preceding text.
\begin{lrbox}{\pbox@bidipres}% Save the contents in a minipage inside \pbox@bidipres.
\noindent
\begin{minipage}{\linewidth-2\fboxsep-2\fboxrule}% Reduce the width of the minipage to leave space for the frame.
\replacecolor{presentcolor}{pagecolor}% If \present is used inside the colored area...
}%
{%
\end{minipage}
\end{lrbox}%
\noindent\mkpbox@bidipres{\usebox{\pbox@bidipres}}% This typesets the saved minipage inside the coloured area.
\smallskip% A small space to separate the area from succeding text.
\par
}
\newcommand{\rulestripes}{10}
\newcommand{\stripeoverlap}{.15pt}
\newcommand{\rulefirstgradprogression}{1}
\newcommand{\rulesecondgradprogression}{1}
\newcommand{\rulegradmidpoint}{.5}
\newcounter{stripe@bidipres}
\newcounter{stripes@bidipres}
\newcommand{\firstgradprogression@bidipres}{1}
\newcommand{\secondgradprogression@bidipres}{1}
\newcounter{gradprogression@bidipres}
\newcommand{\gradmidpoint@bidipres}{.5}
\newcommand{\mkgradfirstfactor@bidipres}{\mkgradfactor@bidipres\firstgradprogression@bidipres}
\newcommand{\mkgradsecondfactor@bidipres}{\mkgradfactor@bidipres\secondgradprogression@bidipres}
\newcommand{\mkgradfactor@bidipres}[3]% Calculate a factor modified by a `progression' parameter.
{%
\mkfactor{#2}{#3}% Calculate the unmodified factor.
\setcounter{gradprogression@bidipres}{#1}% Factor definition may contain a calc-expression.
\ifthenelse{\value{gradprogression@bidipres}=1}{}% Progression value 1 is neutral.
{%
\ifthenelse{\value{gradprogression@bidipres}<0}% `Negative' progression?
{% Yes.
\@tempcnta-\value{gradprogression@bidipres}\relax% Complement progression wrt 0.
\mkfactor{#2}{1-1pt*\real{#2}}% Complement factor definition wrt 1pt.
}
{\@tempcnta\value{gradprogression@bidipres}\relax}% No; Use progression as given.
\whiledo{\the\@tempcnta>1}% Calculate (factor definition)^(progression).
{\advance\@tempcnta by -1\relax\mkfactor{#2}{\real{#2}*\real{#2}}}%
\ifthenelse{\value{gradprogression@bidipres}<0}% `Negative' progression?
{% Yes.
\mkfactor{#2}{1-1pt*\real{#2}}% Complement result wrt 1pt.
}
{}%
}%
}
\newcommand{\vgradrule}[1][]% Pick up first optional argument: [<stripes>]
{%
\let\firstgradprogression@bidipres=\rulefirstgradprogression% Use progression parameter for rules.
\ifthenelse{\equal{#1}{}}% First optional argument given?
{\setcounter{stripes@bidipres}{\rulestripes}}% No; use default value.
{\setcounter{stripes@bidipres}{#1}}% Yes.
\vgradrule@bidipres% Pick up [<startmodel>]{<startcolor>}.
}
\newcommand{\vgradrule@bidipres}[2][]% Pick up next pair of arguments: [<startmodel>]{<startcolor>}.
{%
\ifthenelse{\equal{#1}{}}% <startmodel> given?
{\replacecolor{startcolor@bidipres}{#2}}% No; <startcolor> is a color name.
{\definecolor{startcolor@bidipres}{#1}{#2}}% Yes; {<startmodel>}{<startcolor>} is a color definition.
\@vgradrule@bidipres% Pick up [<endmodel>]{<endcolor>}.
}
\newcommand{\@vgradrule@bidipres}[2][]% Pick up next pair of arguments: [<endmodel>]{<endcolor>}.
{%
\ifthenelse{\equal{#1}{}}
{\replacecolor{endcolor@bidipres}{#2}}
{\definecolor{endcolor@bidipres}{#1}{#2}}%
\@@vgradrule@bidipres% Pick up rule arguments and proceed.
}
\newcommand{\hstripe@bidipres}[4]%
{\hbox{{\setcolor@bidipres{stripecolor@bidipres}\rule{#2}{#3}}}#4}
\newcommand{\@@vgradrule@bidipres}[3][0pt]%
{%
\ifthenelse{\value{stripes@bidipres}<2}% A `pathological case' which can happen in animations: If 0 or 1 stripes are
% requested, a division by zero error would be produced by the gradient code.
{\mbox{{\setcolor@bidipres{startcolor@bidipres}\rule[#1]{#2}{#3}}}}% In this case, just produce a colored rule.
{%
\raisebox{#1}% Evaluate the <raise> argument of the rule.
{%
\vbox% A vbox with \offinterlineskip allows to align the stripes vertically.
{%
\offinterlineskip
\setcounter{stripe@bidipres}{0}% Initialize the number of the current stripe.
\whiledo{\value{stripe@bidipres}<\value{stripes@bidipres}}
{%
\mkgradfirstfactor@bidipres{\tmp@bidipres}% Make the weight for \colorbetween, based on the number of the current stripe
{\value{stripe@bidipres}/(\value{stripes@bidipres}-1)}% and the first gradient progression.
\colorbetween[\tmp@bidipres]{stripecolor@bidipres}{endcolor@bidipres}{startcolor@bidipres}% Calculate stripe color.
\stepcounter{stripe@bidipres}%
\ifthenelse{\value{stripe@bidipres}=\value{stripes@bidipres}}% Last stripe?
{\hstripe@bidipres{\tmp@bidipres}{#2}{(#3)/\value{stripes@bidipres}}{}}% Yes; make stripe w/o overlap.
{% No; add a kern to make stripes overlap.
\hstripe@bidipres{\tmp@bidipres}{#2}{(#3)/\value{stripes@bidipres}+\stripeoverlap}{\kern-\stripeoverlap}%
}%
}% matches \whiledo{\value{stripe@bidipres}<\value{stripes@bidipres}}{%
}% matches \vbox{%
}% matches \raisebox{#1}{%
}% matches second argument of \ifthenelse{\value{stripes@bidipres}<2}
}% matches \newcommand{\@@vgradrule@bidipres}[3][0pt]{%
\newcommand{\dblvgradrule}[1][]% Pick up first optional argument: [<midpoint>]
{%
\let\firstgradprogression@bidipres=\rulefirstgradprogression% Use progression parameters for rules.
\let\secondgradprogression@bidipres=\rulesecondgradprogression
\ifthenelse{\equal{#1}{}}% First optional argument given?
{\let\gradmidpoint@bidipres=\rulegradmidpoint}% No; use default value.
{\def\gradmidpoint@bidipres{#1}}% Yes.
\dblvgradrule@bidipres% Pick up second optional argument.
}
\newcommand{\dblvgradrule@bidipres}[1][]% Pick up second optional argument: [<stripes>]
{%
\ifthenelse{\equal{#1}{}}
{\setcounter{stripes@bidipres}{\rulestripes}}
{\setcounter{stripes@bidipres}{#1}}%
\@dblvgradrule@bidipres
}
\newcommand{\@dblvgradrule@bidipres}[2][]% Pick up next pair of arguments: [<startmodel>]{<startcolor>}.
{%
\ifthenelse{\equal{#1}{}}
{\replacecolor{startcolor@bidipres}{#2}}
{\definecolor{startcolor@bidipres}{#1}{#2}}%
\@@dblvgradrule@bidipres
}
\newcommand{\@@dblvgradrule@bidipres}[2][]% Pick up next pair of arguments: [<midmodel>]{<midcolor>}.
{%
\ifthenelse{\equal{#1}{}}
{\replacecolor{midcolor@bidipres}{#2}}
{\definecolor{midcolor@bidipres}{#1}{#2}}%
\@@@dblvgradrule@bidipres
}
\newcommand{\@@@dblvgradrule@bidipres}[2][]% Pick up next pair of arguments: [<endmodel>]{<endcolor>}.
{%
\ifthenelse{\equal{#1}{}}
{\replacecolor{endcolor@bidipres}{#2}}
{\definecolor{endcolor@bidipres}{#1}{#2}}%
\@@@@dblvgradrule@bidipres% Pick up rule arguments and proceed.
}
\newcommand{\@@@@dblvgradrule@bidipres}[3][0pt]% Main part of \dblvgradrule.
{%
\ifthenelse{\value{stripes@bidipres}<2}% The gradient code is not equipped for making less than 2 stripes.
{\mbox{{\setcolor@bidipres{midcolor@bidipres}\rule[#1]{#2}{#3}}}}% In this case, just produce a rule colored with the middle color.
{%
\raisebox{#1}% Evaluate the <raise> argument of the rule.
{%
\vbox% A vbox with \offinterlineskip allows to align the stripes
{% vertically.
\offinterlineskip
\setcounter{stripe@bidipres}{0}% Initialize the number of the current stripe.
\setcounter{tmpcnta@bidipres}% Number of the `middle' stripe.
{\value{stripes@bidipres}*\real{\gradmidpoint@bidipres}}%
\whiledo{\value{stripe@bidipres}<\value{tmpcnta@bidipres}}% Produce the upper part of the gradient.
{%
\mkgradfirstfactor@bidipres{\tmp@bidipres}% Make the weight for \colorbetween, based on the number of the
{\value{stripe@bidipres}/\value{tmpcnta@bidipres}}% current stripe and the first gradient progression.
\colorbetween[\tmp@bidipres]{stripecolor@bidipres}{midcolor@bidipres}{startcolor@bidipres}% Calculate stripe color.
\hstripe@bidipres{\tmp@bidipres}% Make stripe with overlap.
{#2}{(#3)/\value{stripes@bidipres}+\stripeoverlap}{\kern-\stripeoverlap}% This is the upper part, remember?
\stepcounter{stripe@bidipres}%
}%
\stepcounter{tmpcnta@bidipres}%
\ifthenelse{\value{stripes@bidipres}=\value{tmpcnta@bidipres}}% Only one stripe left to produce?
{\hstripe@bidipres{1}{#2}{(#3)/\value{stripes@bidipres}}{}}% Just produce one stripe colored with the end color.
{%
\whiledo{\value{stripe@bidipres}<\value{stripes@bidipres}}% Produce the lower part of the gradient.
{%
\mkgradsecondfactor@bidipres{\tmp@bidipres}% Make the weight for \colorbetween.
{(\value{stripe@bidipres}-\value{tmpcnta@bidipres}+1)/(\value{stripes@bidipres}-\value{tmpcnta@bidipres})}%
\colorbetween[\tmp@bidipres]{stripecolor@bidipres}{endcolor@bidipres}{midcolor@bidipres}% Calculate stripe color.
\stepcounter{stripe@bidipres}%
\ifthenelse{\value{stripe@bidipres}=\value{stripes@bidipres}}% Last stripe?
{\hstripe@bidipres{\tmp@bidipres}{#2}{(#3)/\value{stripes@bidipres}}{}}% Yes; make stripe w/o overlap.
{% No; add kern to make stripes overlap.
\hstripe@bidipres{\tmp@bidipres}{#2}{(#3)/\value{stripes@bidipres}+\stripeoverlap}{\kern-\stripeoverlap}%
}%
}% matches \whiledo{\value{stripe@bidipres}<\value{stripes@bidipres}}%
}% matches second argument of \ifthenelse{\value{stripes@bidipres}=\value{tmpcnta@bidipres}}%
}% matches \vbox{%
}% matches \raisebox{#1}{%
}% matches second argument of \ifthenelse{\value{stripes@bidipres}<2}%
}% matches \newcommand{\@@@@dblvgradrule@bidipres}[3][0pt]%
\newcommand{\hgradrule}[1][]% Pick up first optional argument: [<stripes>].
{%
\let\firstgradprogression@bidipres=\rulefirstgradprogression% Use progression parameter for rules.
\ifthenelse{\equal{#1}{}}% First optional argument given?
{\setcounter{stripes@bidipres}{\rulestripes}}% No; use default value.
{\setcounter{stripes@bidipres}{#1}}% Yes.
\hgradrule@bidipres% Pick up [<startmodel>]{<startcolor>}.
}
\newcommand{\hgradrule@bidipres}[2][]% Pick up next pair of arguments: [<startmodel>]{<startcolor>}.
{%
\ifthenelse{\equal{#1}{}}
{\replacecolor{startcolor@bidipres}{#2}}
{\definecolor{startcolor@bidipres}{#1}{#2}}%
\@hgradrule@bidipres
}
\newcommand{\@hgradrule@bidipres}[2][]
{%
\ifthenelse{\equal{#1}{}}
{\replacecolor{endcolor@bidipres}{#2}}
{\definecolor{endcolor@bidipres}{#1}{#2}}%
\@@hgradrule@bidipres% Pick up rule arguments and proceed.
}
\newcommand{\vstripe@bidipres}[4]% Helper command for making _one_ stripe. Can be overladed for making historams.
{{\setcolor@bidipres{stripecolor@bidipres}\rule{#2}{#3}#4}}
\newcommand{\@@hgradrule@bidipres}[3][0pt]% Main part of \hgradrule.
{%
\ifthenelse{\value{stripes@bidipres}<2}% A `pathological case' which can happen in animations: If 0 or 1 stripes are
% requested, a division by zero error would be produced by the gradient code.
{\mbox{{\setcolor@bidipres{startcolor@bidipres}\rule[#1]{#2}{#3}}}}% In this case, just produce a colored rule.
{%
\raisebox{#1}% Evaluate the <raise> argument of the rule.
{%
\setcounter{stripe@bidipres}{0}% Initialize the number of the current stripe.
\whiledo{\value{stripe@bidipres}<\value{stripes@bidipres}}
{%
\mkgradfirstfactor@bidipres{\tmp@bidipres}% Make the weight for \colorbetween, based on the number of the current stripe
{\value{stripe@bidipres}/(\value{stripes@bidipres}-1)}% and the first gradient progression.
\colorbetween[\tmp@bidipres]{stripecolor@bidipres}{endcolor@bidipres}{startcolor@bidipres}% Calculate stripe color.
\stepcounter{stripe@bidipres}%
\ifthenelse{\value{stripe@bidipres}=\value{stripes@bidipres}}% Last stripe?
{\vstripe@bidipres{\tmp@bidipres}{(#2)/\value{stripes@bidipres}}{#3}{}}% Yes; make stripe w/o overlap.
{% No; add a kern to make stripes overlap.
\vstripe@bidipres{\tmp@bidipres}{(#2)/\value{stripes@bidipres}+\stripeoverlap}{#3}{\kern-\stripeoverlap}%
}%
}% matches \whiledo{\value{stripe@bidipres}<\value{stripes@bidipres}}{%
}% matches \raisebox{#1}{%
}% matches second argument of \ifthenelse{\value{stripes@bidipres}<2}%
}% matches \newcommand{\@@hgradrule@bidipres}[3][0pt]{%
\newcommand{\dblhgradrule}[1][]% Pick up first optional argument: [<midpoint>].
{%
\let\firstgradprogression@bidipres=\rulefirstgradprogression% Use progression parameters for rules.
\let\secondgradprogression@bidipres=\rulesecondgradprogression
\ifthenelse{\equal{#1}{}}{\let\gradmidpoint@bidipres=\rulegradmidpoint}{\def\gradmidpoint@bidipres{#1}}%
\dblhgradrule@bidipres
}
\newcommand{\dblhgradrule@bidipres}[1][]% Pick up second optional argument: [<stripes>].
{%
\ifthenelse{\equal{#1}{}}{\setcounter{stripes@bidipres}{\rulestripes}}{\setcounter{stripes@bidipres}{#1}}%
\@dblhgradrule@bidipres
}
\newcommand{\@dblhgradrule@bidipres}[2][]% Pick up next pair of arguments: [<startmodel>]{<startcolor>}.
{%
\ifthenelse{\equal{#1}{}}{\replacecolor{startcolor@bidipres}{#2}}{\definecolor{startcolor@bidipres}{#1}{#2}}%
\@@dblhgradrule@bidipres
}
\newcommand{\@@dblhgradrule@bidipres}[2][]
{%
\ifthenelse{\equal{#1}{}}{\replacecolor{midcolor@bidipres}{#2}}{\definecolor{midcolor@bidipres}{#1}{#2}}%
\@@@dblhgradrule@bidipres
}
\newcommand{\@@@dblhgradrule@bidipres}[2][]
{%
\ifthenelse{\equal{#1}{}}
{\replacecolor{endcolor@bidipres}{#2}}
{\definecolor{endcolor@bidipres}{#1}{#2}}%
\@@@@dblhgradrule@bidipres% Pick up rule arguments and proceed.
}
\newcommand{\@@@@dblhgradrule@bidipres}[3][0pt]% Main part of \dblhgradrule.
{%
\ifthenelse{\value{stripes@bidipres}<2}% The gradient code is not equipped for making less than 2 stripes.
{\mbox{{\setcolor@bidipres{midcolor@bidipres}\rule[#1]{#2}{#3}}}}% In this case, just produce a rule colored with the middle color.
{%
\raisebox{#1}% Evaluate the <raise> argument of the rule.
{%
\setcounter{stripe@bidipres}{0}% Initialize the number of the current stripe.
\setcounter{tmpcnta@bidipres}% Number of the `middle' stripe.
{\value{stripes@bidipres}*\real{\gradmidpoint@bidipres}}%
\whiledo{\value{stripe@bidipres}<\value{tmpcnta@bidipres}}% Produce the left part of the gradient.
{%
\mkgradfirstfactor@bidipres{\tmp@bidipres}% Make the weight for \colorbetween, based on the number of the
{\value{stripe@bidipres}/\value{tmpcnta@bidipres}}% current stripe and the first gradient progression.
\colorbetween[\tmp@bidipres]{stripecolor@bidipres}{midcolor@bidipres}{startcolor@bidipres}% Calculate stripe color.
\vstripe@bidipres{\tmp@bidipres}% Make stripe with overlap.
{(#2)/\value{stripes@bidipres}+\stripeoverlap}{#3}{\kern-\stripeoverlap}% This is the left part, remember?
\stepcounter{stripe@bidipres}%
}%
\stepcounter{tmpcnta@bidipres}%
\ifthenelse{\value{stripes@bidipres}=\value{tmpcnta@bidipres}}% Only one stripe left to produce?
{\vstripe@bidipres{1}{(#2)/\value{stripes@bidipres}}{#3}{}}% Just produce one stripe colored with the end color.
{%
\whiledo{\value{stripe@bidipres}<\value{stripes@bidipres}}% Produce the right part of the gradient.
{%
\mkgradsecondfactor@bidipres{\tmp@bidipres}% Make the weight for \colorbetween.
{(\value{stripe@bidipres}-\value{tmpcnta@bidipres})/(\value{stripes@bidipres}-\value{tmpcnta@bidipres}-1)}%
\colorbetween[\tmp@bidipres]{stripecolor@bidipres}{endcolor@bidipres}{midcolor@bidipres}% Calculate stripe color.
\stepcounter{stripe@bidipres}%
\ifthenelse{\value{stripe@bidipres}=\value{stripes@bidipres}}% Last stripe?
{\vstripe@bidipres{\tmp@bidipres}{(#2)/\value{stripes@bidipres}}{#3}{}}% Yes; make stripe w/o overlap.
{% Add kern to make stripes overlap.
\vstripe@bidipres{\tmp@bidipres}{(#2)/\value{stripes@bidipres}+\stripeoverlap}{#3}{\kern-\stripeoverlap}%
}%
}% matches \whiledo{\value{stripe@bidipres}<\value{stripes@bidipres}}{%
}% matches second argument of \ifthenelse{\value{stripes@bidipres}=\value{tmpcnta@bidipres}}%
}% matches \raisebox{#1}{%
}% matches second argument of \ifthenelse{\value{stripes@bidipres}<2}%
}% matches \newcommand{\@@@@dblhgradrule@bidipres}[3][0pt]{%
\providecommand{\clipbox}[2][\z@]{\leavevmode\hbox{#2}}
\newcommand{\dgradslope}{1,1}
\newcounter{dgradhslope@bidipres}
\newcounter{dgradvslope@bidipres}
\def\setdgradslope(#1,#2){\setcounter{dgradhslope@bidipres}{#1}\setcounter{dgradvslope@bidipres}{#2}}
\newcommand{\dgradrule}[1][]
{%
\ifthenelse{\equal{#1}{}}{\expandafter\setdgradslope\expandafter(\dgradslope)}{\setdgradslope(#1)}%
\dgradrule@bidipres
}
\newcommand{\dgradrule@bidipres}[2][]
{%
\ifthenelse{\equal{#1}{}}{\replacecolor{startcolor@bidipres}{#2}}{\definecolor{startcolor@bidipres}{#1}{#2}}%
\@dgradrule@bidipres
}