1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17\writestatus{loading}{ConTeXt Color Macros Initialization}
18
19
20
21
22
23
24\installcorenamespace{color}
25\installcorenamespace{colorattribute}
26\installcorenamespace{transparencyattribute}
27\installcorenamespace{colorsetter}
28\installcorenamespace{transparencysetter}
29\installcorenamespace{colorpaletspecification}
30\installcorenamespace{colorpalet}
31\installcorenamespace{colorstack}
32\installcorenamespace{colorconversions}
33\installcorenamespace{colornumber}
34
35\registerctxluafile{coloini}{}
36\registerctxluafile{coloicc}{}
37
38\unprotect
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58\newconditional\c_colo_rgb_supported
59\newconditional\c_colo_cmyk_supported
60\newconditional\c_colo_spot_supported
61\newconditional\c_colo_convert_gray \settrue\c_colo_convert_gray
62\newconditional\c_colo_enabled
63\newconditional\c_colo_expanded
64
65\let\m_colo_weight_gray\v!yes
66
67\let\currentcolormodel \empty
68\let\currentcolorname \empty
69\let\currentcolorpalet \empty
70\let\currentcolorprefix\empty
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\unexpanded\def\definecolor {\dodoubleargument\colo_basics_define}
102\unexpanded\def\defineglobalcolor {\dodoubleargument\colo_basics_define_global}
103\unexpanded\def\defineprocesscolor {\dotripleargument\colo_basics_define_process}
104\unexpanded\def\definenamedcolor {\dodoubleargument\colo_basics_define_named}
105\unexpanded\def\definespotcolor {\dotripleargument\colo_basics_define_spot}
106\unexpanded\def\definemultitonecolor {\doquadrupleempty\colo_basics_define_multitone}
107\unexpanded\def\definetransparency {\dodoubleargument\colo_basics_define_transpancy}
108\unexpanded\def\defineglobaltransparency{\dodoubleargument\colo_basics_define_transpancy_global}
109
110\unexpanded\def\loadfoundcolorsetfile#1#2
111 {\startreadingfile
112 \startcolorset[#1]
113 \input{#2}
114 \stopcolorset
115 \showmessage\m!colors4{#1}
116 \stopreadingfile}
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135\let\g_color\empty
136\let\g_style\empty
137
138\unexpanded\def\switchtocolor[#1]{\begincsname#1\endcsname}
139
140
141
142\unexpanded\def\transparent[#1]
143 {\bgroup
144 \edef\currenttransparencyname{#1}
145
146 \ifx\currenttransparencyname\v!reset
147 \c_attr_transparency\attributeunsetvalue
148 \else
149 \begincsname\??transparencysetter\currenttransparencyname\endcsname\relax
150 \fi
151 \let\nexttoken}
152
153\unexpanded\def\starttransparent[#1]
154 {\begingroup
155 \edef\currenttransparencyname{#1}
156 \ifx\currenttransparencyname\v!reset
157 \c_attr_transparency\attributeunsetvalue
158 \else
159 \begincsname\??transparencysetter\currenttransparencyname\endcsname\relax
160 \fi}
161
162\unexpanded\def\stoptransparent
163 {\endgroup}
164
165
166
167\unexpanded\def\coloronly[#1]
168 {\bgroup
169 \edef\currentcolorname{#1}
170 \ifx\currentcolorprefix\empty
171 \colo_helpers_activate_nop_only
172 \else
173 \colo_helpers_activate_yes_only
174 \fi
175 \let\nexttoken}
176
177\unexpanded\def\startcoloronly[#1]
178 {\begingroup
179 \edef\currentcolorname{#1}
180 \ifx\currentcolorprefix\empty
181 \colo_helpers_activate_nop_only
182 \else
183 \colo_helpers_activate_yes_only
184 \fi}
185
186\unexpanded\def\stopcoloronly
187 {\endgroup}
188
189
190
191\unexpanded\def\color[#1]
192 {\bgroup
193 \edef\currentcolorname{#1}
194 \ifx\currentcolorprefix\empty
195 \colo_helpers_activate_nop
196 \else
197 \colo_helpers_activate_yes
198 \fi
199 \let\nexttoken}
200
201\unexpanded\def\graycolor[#1]
202 {\bgroup
203 \colo_helpers_set_model\s!gray\colo_helpers_activate{#1}
204 \let\nexttoken}
205
206\unexpanded\def\startcolor[#1]
207 {\begingroup
208 \edef\currentcolorname{#1}
209 \ifx\currentcolorprefix\empty
210 \colo_helpers_activate_nop
211 \else
212 \colo_helpers_activate_yes
213 \fi}
214
215\unexpanded\def\stopcolor
216 {\endgroup}
217
218\unexpanded\def\colored[#1]
219 {\bgroup
220 \colo_basics_defined_and_activated{#1}
221 \let\nexttoken}
222
223\unexpanded\def\fastcolored[#1]#2
224 {\begingroup
225 \colo_basics_defined_and_activated{#1}
226 #2
227 \endgroup}
228
229\unexpanded\def\directcolored[#1]
230 {\colo_basics_defined_and_activated{#1}}
231
232\unexpanded\def\fastcolor[#1]#2
233 {\begingroup
234 \edef\currentcolorname{#1}
235 \ifx\currentcolorprefix\empty
236 \colo_helpers_activate_nop
237 \else
238 \colo_helpers_activate_yes
239 \fi
240 #2
241 \endgroup}
242
243\unexpanded\def\directcolor[#1]
244 {\edef\currentcolorname{#1}
245 \ifx\currentcolorprefix\empty
246 \colo_helpers_activate_nop
247 \else
248 \colo_helpers_activate_yes
249 \fi}
250
251
252
253\unexpanded\def\startcolorpage {\startcolor[\ifx\maintextcolor\empty\defaulttextcolor\else\maintextcolor\fi]}
254\unexpanded\def\stopcolorpage {\stopcolor}
255
256\unexpanded\def\getcolorattributevalue#1#2
257 {\begingroup
258 \colo_helpers_activate{#1}
259 \normalexpanded{\endgroup\edef\noexpand#2
260 {\ifnum\c_attr_color=\attributeunsetvalue\else\number\c_attr_color\fi}}}
261
262\let\grey\graycolor
263
264
265
266
267\unexpanded\def\startcurrentcolor{\startcolor[\outercolorname]}
268\unexpanded\def\stopcurrentcolor {\stopcolor}
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\unexpanded\def\startcolorset[#1]{\clf_startcolorset{#1}}
294\unexpanded\def\stopcolorset {\clf_stopcolorset}
295\unexpanded\def\usecolors [#1]{\clf_usecolors{#1}}
296
297\let\setupcolor\usecolors
298
299\installsetuponlycommandhandler \??color {colors}
300
301\let\colo_helpers_show_message\gobblethreearguments
302
303
304
305\let\v_colo_freeze_state\s!false
306
307\setvalue{\??colorconversions\v!yes}
308 {\settrue \c_colo_convert_gray}
309
310\setvalue{\??colorconversions\v!always}
311 {\settrue \c_colo_convert_gray
312 \setfalse\c_colo_rgb_supported
313 \setfalse\c_colo_cmyk_supported}
314
315\appendtoks
316
317 \doifelse{\directcolorsparameter\c!spot }\v!yes \settrue \setfalse\c_colo_spot_supported
318 \doifelse{\directcolorsparameter\c!expansion}\v!yes \settrue \setfalse\c_colo_expanded
319 \doifelse{\directcolorsparameter\c!rgb }\v!yes \settrue \setfalse\c_colo_rgb_supported
320 \doifelse{\directcolorsparameter\c!cmyk }\v!yes \settrue \setfalse\c_colo_cmyk_supported
321 \doifelse{\directcolorsparameter\c!state }\v!start\settrue \setfalse\c_colo_enabled
322
323 \edef\m_colo_weight_gray{\directcolorsparameter\c!factor}
324
325 \ifconditional\c_colo_expanded
326 \let\v_colo_freeze_state\s!true
327 \else
328 \let\v_colo_freeze_state\s!false
329 \fi
330
331 \setfalse\c_colo_convert_gray
332 \begincsname\??colorconversions\directcolorsparameter\c!conversion\endcsname
333
334 \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors{10}\v!rgb \fi
335 \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors{10}\v!cmyk\fi
336 \colo_helpers_set_current_model
337 \ifproductionrun
338 \edef\p_pagecolormodel{\directcolorsparameter\c!pagecolormodel}
339 \clf_setpagecolormodel{\ifx\p_pagecolormodel\v!auto\currentcolormodel\else\p_pagecolormodel\fi}
340 \fi
341\to \everysetupcolors
342
343\appendtoks
344 \setupcolors[\c!state=\v!start]
345 \clf_enablecolor
346 \clf_enabletransparency
347 \let\colo_helpers_show_message\showmessage
348\to \everyjob
349
350
351
352\newcount\c_colo_nesting
353
354\unexpanded\def\pushcolor[#1]
355 {\global\advance\c_colo_nesting\plusone
356 \expandafter\edef\csname\??colorstack\number\c_colo_nesting\endcsname
357 {\c_attr_colormodel \the\c_attr_colormodel
358 \c_attr_color \the\c_attr_color
359 \c_attr_transparency\the\c_attr_transparency
360 \relax}
361 \colo_helpers_activate{#1}}
362
363\unexpanded\def\popcolor
364 {\csname\??colorstack\number\c_colo_nesting\endcsname
365 \global\advance\c_colo_nesting\minusone}
366
367
368
369\newcount\c_colo_saved_attribute_color
370\newcount\c_colo_saved_attribute_transparency
371
372\unexpanded\def\savecolor
373 {\c_colo_saved_attribute_color \c_attr_color
374 \c_colo_saved_attribute_transparency\c_attr_transparency}
375
376\unexpanded\def\restorecolor
377 {\c_attr_color \c_colo_saved_attribute_color
378 \c_attr_transparency\c_colo_saved_attribute_transparency}
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\installcorenamespace{paletlist}
440\installcorenamespace{paletsize}
441
442\let\m_colo_palet\relax
443\let\c_colo_palet\relax
444
445\def\colo_palet_allocate#1
446 {\expandafter\let \csname\??paletlist#1\endcsname\empty
447 \expandafter\newcount\csname\??paletsize#1\endcsname}
448
449\def\colo_palet_prepare#1
450 {\edef\colo_palet_name{#1}
451 \ifcsname\??paletlist\colo_palet_name\endcsname
452 \csname\??paletsize\colo_palet_name\endcsname\zerocount
453 \else
454 \colo_palet_allocate\colo_palet_name
455 \fi
456 \edef\m_colo_palet{\begincsname\??paletlist\colo_palet_name\endcsname}
457 \expandafter\let\expandafter\c_colo_palet\csname\??paletsize\colo_palet_name\endcsname}
458
459\def\colo_palet_extend#1
460 {\addtocommalist{#1}\m_colo_palet
461 \expandafter\let\csname\??paletlist\colo_palet_name\endcsname\m_colo_palet
462 \advance\c_colo_palet\plusone}
463
464\unexpanded\def\doifelsecolorpalet#1
465 {\ifcsname\??paletlist#1\endcsname
466 \expandafter\firstoftwoarguments
467 \else
468 \expandafter\secondoftwoarguments
469 \fi}
470
471\let\paletlist\empty
472\let\paletsize\!!zerocount
473
474\unexpanded\def\getpaletlist[#1]
475 {\edef\paletlist{\begincsname\??paletlist#1\endcsname}}
476
477\unexpanded\def\getpaletsize[#1]
478 {\ifcsname\??paletsize#1\endcsname
479 \edef\paletsize{\the\lastnamedcs}
480 \else
481 \let\paletsize\!!zerocount
482 \fi}
483
484\unexpanded\def\definepalet
485 {\dotripleempty\colo_palets_define}
486
487\def\colo_palets_define
488 {\ifthirdargument
489 \expandafter\colo_palets_define_b
490 \else
491 \expandafter\colo_palets_define_a
492 \fi}
493
494\unexpanded\def\colo_palets_define_a[#1][#2][#3]
495 {\colo_palet_prepare{#1}
496 \ifcondition\validassignment{#2}
497 \setevalue{\??colorpaletspecification#1}{#2}
498 \processcommalist[#2]{\colo_palets_define_one{#1}}
499 \else
500 \ifcsname\??colorpaletspecification#2\endcsname
501 \normalexpanded{\colo_palets_define[#1][\lastnamedcs]}
502 \fi
503 \fi}
504
505\unexpanded\def\colo_palets_define_b[#1][#2][#3]
506 {\colo_palet_prepare{#1}
507 \setevalue{\??colorpaletspecification#1}{#2}
508 \colo_palet_extend{#2}
509 \colo_palets_define_assign{#1}{#2}{#3}}
510
511\def\colo_palets_define_one#1#2
512 {\ifcondition\validassignment{#2}
513 \colo_palets_define_two{#1}[#2]
514 \else
515 \colo_palets_define_three{#1}{#2}
516 \fi}
517
518\def\colo_palets_define_two#1[#2=#3]
519 {\colo_palet_extend{#2}
520 \colo_palets_define_set{#1}{#2}{#3}}
521
522\def\colo_palets_define_three#1#2
523 {\ifcsname\??colorpaletspecification#2\endcsname
524 \processcommacommand[\lastnamedcs]{\colo_palets_define_one{#1}}
525 \fi}
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542\newtoks\everysetuppalet
543
544\unexpanded\def\setuppalet
545 {\dosingleempty\colo_palets_setup}
546
547
548
549\def\colo_palets_setup[#1]
550 {\edef\currentcolorpalet{#1}
551 \ifx\currentcolorpalet\empty
552
553 \let\currentcolorprefix\empty
554
555 \else\ifcsname\??paletlist\currentcolorpalet\endcsname
556 \edef\currentcolorprefix{#1:}
557
558 \else
559 \colo_helpers_show_message\m!colors7\currentcolorpalet
560 \let\currentcolorpalet\empty
561 \let\currentcolorprefix\empty
562
563 \fi\fi
564 \the\everysetuppalet
565 \colo_helpers_initialize_maintextcolor}
566
567
568
569
570
571
572
573
574
575
576
577
578\fetchruntimecommand \showpalet \f!colo_run
579
580
581
582
583
584
585
586
587\fetchruntimecommand \showcolorcomponents \f!colo_run
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610\fetchruntimecommand \comparepalet \f!colo_run
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626\fetchruntimecommand \showcolor \f!colo_run
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\unexpanded\def\negatecolorcomponent#1
652 {\edef#1{\clf_negatedcolorcomponent{#1}}}
653
654\def\negatedcolorcomponent#1
655 {\clf_negatedcolorcomponent{#1}}
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\unexpanded\def\setcolormodel[#1]
691 {\colo_helpers_set_model{#1}}
692
693\def\colo_helpers_set_model#1
694 {\edef\currentcolormodel{#1}
695 \clf_setcolormodel{\currentcolormodel}{\m_colo_weight_gray}}
696
697\colo_helpers_set_model\s!all
698
699\def\colo_helpers_set_current_model
700 {\ifconditional\c_colo_enabled
701 \ifconditional\c_colo_rgb_supported
702 \ifconditional\c_colo_cmyk_supported
703 \colo_helpers_set_model\s!all
704 \else
705 \colo_helpers_set_model\s!rgb
706 \fi
707 \else
708 \ifconditional\c_colo_cmyk_supported
709 \colo_helpers_set_model\s!cmyk
710 \else
711 \ifconditional\c_colo_convert_gray
712 \colo_helpers_set_model\s!gray
713 \else
714 \colo_helpers_set_model\s!none
715 \fi
716 \fi
717 \fi
718 \else
719 \ifconditional\c_colo_convert_gray
720 \colo_helpers_set_model\s!gray
721 \else
722 \colo_helpers_set_model\s!none
723 \fi
724 \fi}
725
726
727
728
729
730
731
732
733
734
735\def\v_colo_dummy_name{color}
736
737\letvalue{\??colorattribute \v_colo_dummy_name}\empty
738\letvalue{\??transparencyattribute\v_colo_dummy_name}\empty
739\letvalue{\??colorsetter \v_colo_dummy_name}\empty
740\letvalue{\??transparencysetter \v_colo_dummy_name}\empty
741
742\letvalue{\??colorsetter }\empty
743\letvalue{\??transparencysetter}\empty
744
745
746
747\def\colo_helpers_fast_activate
748 {\ifx\currentcolorprefix\empty
749 \expandafter\colo_helpers_fast_activate_nop
750 \else
751 \expandafter\colo_helpers_fast_activate_yes
752 \fi}
753
754\def\colo_helpers_fast_activate_yes#1
755 {\ifcsname\??colorsetter\currentcolorprefix#1\endcsname
756 \lastnamedcs
757 \begincsname\??transparencysetter\currentcolorprefix#1\endcsname
758 \else\ifcsname\??colorsetter#1\endcsname
759 \lastnamedcs
760 \begincsname\??transparencysetter#1\endcsname
761 \fi\fi}
762
763\def\colo_helpers_fast_activate_nop#1
764 {\ifcsname\??colorsetter#1\endcsname
765 \lastnamedcs
766 \begincsname\??transparencysetter#1\endcsname
767 \fi}
768
769\def\colo_helpers_activate_dummy
770 {\begincsname\??colorsetter \v_colo_dummy_name\endcsname
771 \begincsname\??transparencysetter\v_colo_dummy_name\endcsname}
772
773\let\dofastcoloractivation\colo_helpers_fast_activate
774
775
776
777\def\colo_helpers_activate#1
778 {\edef\currentcolorname{#1}
779 \ifx\currentcolorprefix\empty
780 \expandafter\colo_helpers_activate_nop
781 \else
782 \expandafter\colo_helpers_activate_yes
783 \fi}
784
785\def\colo_helpers_activate_yes
786 {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
787 \lastnamedcs
788 \begincsname\??transparencysetter\currentcolorprefix\currentcolorname\endcsname
789 \else\ifcsname\??colorsetter\currentcolorname\endcsname
790 \lastnamedcs
791 \begincsname\??transparencysetter\currentcolorname\endcsname
792 \fi\fi}
793
794\def\colo_helpers_activate_nop
795 {\ifcsname\??colorsetter\currentcolorname\endcsname
796 \lastnamedcs
797 \begincsname\??transparencysetter\currentcolorname\endcsname
798 \fi}
799
800\def\colo_helpers_activate_yes_only
801 {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
802 \lastnamedcs
803 \else\ifcsname\??colorsetter\currentcolorname\endcsname
804 \lastnamedcs
805 \fi\fi}
806
807\def\colo_helpers_activate_nop_only
808 {\ifcsname\??colorsetter\currentcolorname\endcsname
809 \lastnamedcs
810 \fi}
811
812\let\dousecolorparameter\colo_helpers_activate
813
814\unexpanded\def\dousecolorhashparameter#1#2
815 {\ifcsname#1#2\endcsname
816 \expandafter\dousecolorparameter\csname#1#2\endcsname
817 \fi}
818
819\unexpanded\def\dousecurrentcolorparameter
820 {\let\currentcolorname\currentcolorparameter
821 \ifcsname\??colorsetter\currentcolorprefix\currentcolorparameter\endcsname
822 \lastnamedcs
823 \begincsname\??transparencysetter\currentcolorprefix\currentcolorparameter\endcsname
824 \else\ifcsname\??colorsetter\currentcolorparameter\endcsname
825 \lastnamedcs
826 \begincsname\??transparencysetter\currentcolorparameter\endcsname
827 \fi\fi}
828
829\let\dosetcolorattribute\dousecolorhashparameter
830
831\unexpanded\def\deactivatecolor
832 {\let\currentcolorname\s!black
833 \c_attr_color \attributeunsetvalue
834 \c_attr_transparency\attributeunsetvalue}
835
836
837
838
839
840
841\def\colo_basics_allocate#1
842 {\expandafter\newcount\csname\??colornumber#1\endcsname
843 \clf_synccolorcount{#1}\c_syst_last_allocated_count}
844
845\def\colo_basics_synchronize#1
846 {\ifcsname\??colornumber#1\endcsname\else
847 \colo_basics_allocate{#1}
848 \fi
849 \clf_synccolor{#1}
850
851 \lastnamedcs\csname\??colorattribute#1\endcsname}
852
853\let\colo_basics_inherit\clf_synccolorclone
854
855\newcount\c_colo_protection
856
857\unexpanded\def\startprotectedcolors
858 {\advance\c_colo_protection\plusone}
859
860\unexpanded\def\stopprotectedcolors
861 {\advance\c_colo_protection\minusone}
862
863\def\colo_basics_define[#1][#2]
864 {\edef\m_colo_old{#1}
865 \edef\m_colo_new{#2}
866 \ifx\m_colo_old\m_colo_new
867
868 \else
869 \clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax
870 \colo_basics_synchronize{#1}
871 \ifcase\c_colo_protection
872 \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}
873 \fi
874 \fi}
875
876\def\colo_basics_define_global[#1][#2]
877 {\edef\m_colo_old{#1}
878 \edef\m_colo_new{#2}
879 \ifx\m_colo_old\m_colo_new
880
881 \else
882 \clf_defineprocesscolorglobal{#1}{#2}\v_colo_freeze_state\relax
883 \colo_basics_synchronize{#1}
884 \ifcase\c_colo_protection
885 \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}
886 \fi
887 \fi}
888
889\let\colo_basics_define_named\colo_basics_define
890
891\def\dodefinefastcolor[#1][#2]
892 {\clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax
893 \colo_basics_synchronize{#1}
894 \ifcase\c_colo_protection
895 \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}
896 \fi}
897
898\def\colo_basics_defined_and_activated#1
899 {\clf_defineprocesscolordummy{#1}
900 \colo_basics_synchronize{\v_colo_dummy_name}
901 \colo_helpers_activate_dummy}
902
903\def\colo_basics_define_process
904 {\ifthirdargument
905 \expandafter\colo_basics_define_process_yes
906 \else
907 \expandafter\colo_basics_define_process_nop
908 \fi}
909
910\def\colo_basics_define_process_yes[#1][#2][#3]
911 {\clf_defineprocesscolorlocal{#1}{\processcolorcomponents{#2},#3}\v_colo_freeze_state\relax
912 \colo_basics_synchronize{#1}
913 \ifcase\c_colo_protection
914 \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}
915 \fi}
916
917\def\colo_basics_define_process_nop[#1][#2][#3]
918 {\clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax
919 \colo_basics_synchronize{#1}
920 \ifcase\c_colo_protection
921 \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}
922 \fi}
923
924
925
926
927
928\def\colo_basics_define_spot[#1][#2][#3]
929 {\clf_definespotcolorglobal{#1}{#2}{#3}
930 \colo_basics_synchronize{#1}
931 \ifcase\c_colo_protection
932 \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}
933 \fi}
934
935\def\colo_basics_define_multitone[#1][#2][#3][#4]
936 {\clf_definemultitonecolorglobal{#1}{#2}{#3}{#4}
937 \colo_basics_synchronize{#1}
938 \ifcase\c_colo_protection
939 \unexpanded\setgvalue{#1}{\colo_helpers_activate{#1}}
940 \fi}
941
942
943
944\def\colo_basics_define_transpancy[#1][#2]
945 {\clf_definetransparency{#1}{#2}}
946
947\def\colo_basics_define_transpancy_global[#1][#2]
948 {\clf_definetransparencyglobal{#1}{#2}}
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\unexpanded\def\defineintermediatecolor
994 {\dotripleempty\colo_basics_define_intermediate}
995
996\def\colo_basics_define_intermediate[#1][#2][#3]
997 {\colo_basics_define_intermediate_indeed[#1][#2][#3]}
998
999\def\colo_basics_define_intermediate_indeed[#1][#2,#3,#4][#5]
1000 {\clf_defineintermediatecolor
1001 {#1}
1002 {#2}
1003 \rawcolorattribute{#3}
1004 \rawcolorattribute{#4}
1005 \rawtransparencyattribute{#3}
1006 \rawtransparencyattribute{#4}
1007 {#5}
1008 \v_colo_freeze_state
1009 \relax
1010 \colo_basics_synchronize{#1}
1011 \unexpanded\setvalue{#1}{\colo_helpers_activate{#1}}}
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049\def\pgf@context@registercolor#1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\zerocount\thecolorattribute{#1}}}
1050\def\pgf@context@registergray #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plustwo \thecolorattribute{#1}}}
1051\def\pgf@context@registerrgb #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusthree\thecolorattribute{#1}}}
1052\def\pgf@context@registercmyk #1{\setevalue{\string\color@#1}{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusfour \thecolorattribute{#1}}}
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066\def\doifelsecolor#1
1067 {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
1068 \expandafter\firstoftwoarguments
1069 \else\ifcsname\??colorattribute#1\endcsname
1070 \doubleexpandafter\firstoftwoarguments
1071 \else
1072 \doubleexpandafter\secondoftwoarguments
1073 \fi\fi}
1074
1075\let\doifcolorelse\doifelsecolor
1076
1077\def\doifcolor#1
1078 {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
1079 \expandafter\firstofoneargument
1080 \else\ifcsname\??colorattribute#1\endcsname
1081 \doubleexpandafter\firstofoneargument
1082 \else
1083 \doubleexpandafter\gobbleoneargument
1084 \fi\fi}
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110\let\maintextcolor \empty
1111\def\defaulttextcolor{black}
1112
1113\unexpanded\def\inheritmaintextcolor
1114 {\ifx\maintextcolor\empty\else\colo_helpers_activate\maintextcolor\fi}
1115
1116\unexpanded\def\onlyinheritmaintextcolor
1117 {\ifx\maintextcolor\empty
1118 \deactivatecolor
1119 \else
1120 \colo_helpers_activate\maintextcolor
1121 \fi}
1122
1123\appendtoks
1124 \deactivatecolor
1125 \inheritmaintextcolor
1126\to \everybeforeoutput
1127
1128\def\colo_helpers_switch_to_maintextcolor#1
1129 {\let\maintextcolor\s!themaintextcolor
1130 \definecolor[\maintextcolor][#1]
1131 \colo_helpers_activate\maintextcolor
1132 \clf_registermaintextcolor\thecolorattribute\maintextcolor\relax}
1133
1134\unexpanded\def\starttextcolor[#1]
1135 {\doifsomething{#1}
1136 {\colo_helpers_switch_to_maintextcolor{#1}}}
1137
1138\let\stoptextcolor\relax
1139
1140\let\p_colo_textcolor\empty
1141
1142\def\colo_helpers_initialize_maintextcolor
1143 {\edef\p_colo_textcolor{\directcolorsparameter\c!textcolor}
1144 \ifx\p_colo_textcolor\empty
1145 \colo_helpers_switch_to_maintextcolor\defaulttextcolor
1146 \else
1147 \colo_helpers_switch_to_maintextcolor\p_colo_textcolor
1148 \fi}
1149
1150\appendtoks \colo_helpers_initialize_maintextcolor \to \everyjob
1151\appendtoks \colo_helpers_initialize_maintextcolor \to \everysetupcolors
1152
1153\letvalue{\??colorsetter }\empty \letvalue{\??colorattribute }\!!zerocount
1154\letvalue{\??transparencysetter}\empty \letvalue{\??transparencyattribute}\!!zerocount
1155
1156\def\colo_helpers_inherited_direct_cs#1{\ifcsname\??colorsetter #1\endcsname\lastnamedcs\fi}
1157\def\colo_helpers_inherited_direct_ca#1{\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi}
1158\def\colo_helpers_inherited_direct_ts#1{\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\fi}
1159\def\colo_helpers_inherited_direct_ta#1{\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi}
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171\let\colo_helpers_set_value\setvalue
1172
1173\appendtoks
1174 \ifconditional\c_colo_expanded
1175 \let\colo_helpers_set_value\setevalue
1176 \else
1177 \let\colo_helpers_set_value\setvalue
1178 \fi
1179\to \everysetupcolors
1180
1181\def\colo_palets_define_set#1#2#3
1182 {\ifcondition\validassignment{#3}
1183 \expandafter\colo_palets_define_assign
1184 \else\ifcsname\??colorsetter#3\endcsname
1185
1186 \doubleexpandafter\colo_palets_define_inherit
1187 \else
1188
1189 \doubleexpandafter\colo_palets_define_undefine
1190 \fi\fi
1191 {#1}{#2}{#3}}
1192
1193\def\colo_palets_define_inherit#1#2#3
1194 {\colo_basics_inherit{#1:#2}{#3}
1195 \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_direct_cs{#3}}
1196 \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_direct_ca{#3}}
1197 \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_direct_ts{#3}}
1198 \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_direct_ta{#3}}}
1199
1200\def\colo_palets_define_undefine#1#2#3
1201 {\localundefine{\??colorsetter #1:#2}
1202 \localundefine{\??colorattribute #1:#2}
1203 \localundefine{\??transparencysetter #1:#2}
1204 \localundefine{\??transparencyattribute#1:#2}}
1205
1206\def\colo_palets_define_assign#1#2#3
1207 {\definecolor[\??colorpalet#1:#2][#3]
1208 \colo_helpers_set_value{\??colorsetter #1:#2}{\colo_helpers_inherited_direct_cs{\??colorpalet#1:#2}}
1209 \colo_helpers_set_value{\??colorattribute #1:#2}{\colo_helpers_inherited_direct_ca{\??colorpalet#1:#2}}
1210 \colo_helpers_set_value{\??transparencysetter #1:#2}{\colo_helpers_inherited_direct_ts{\??colorpalet#1:#2}}
1211 \colo_helpers_set_value{\??transparencyattribute#1:#2}{\colo_helpers_inherited_direct_ta{\??colorpalet#1:#2}}}
1212
1213\setvalue{\??colorattribute currentcolor}{\the\c_attr_color}
1214\setvalue{\??transparencyattribute currentcolor}{\the\c_attr_transparency}
1215
1216
1217
1218
1219
1220
1221\def\colo_helpers_inherited_current_ca#1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi\fi}
1222\def\colo_helpers_inherited_current_cs#1{\ifcsname\??colorsetter \currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??colorsetter #1\endcsname\lastnamedcs\else\fi\fi}
1223\def\colo_helpers_inherited_current_ta#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi\fi}
1224\def\colo_helpers_inherited_current_ts#1{\ifcsname\??transparencysetter \currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\else\fi\fi}
1225
1226
1227
1228\unexpanded\def\colordefalc#1#2{\setevalue{\??colorattribute #1}{#2}\setvalue {\??colorsetter #1}{\c_attr_color #2 }}
1229\unexpanded\def\colordefagc#1#2{\setxvalue{\??colorattribute #1}{#2}\setgvalue{\??colorsetter #1}{\c_attr_color #2 }}
1230\unexpanded\def\colordefalt#1#2{\setevalue{\??transparencyattribute#1}{#2}\setvalue {\??transparencysetter#1}{\c_attr_transparency#2 }}
1231\unexpanded\def\colordefagt#1#2{\setxvalue{\??transparencyattribute#1}{#2}\setgvalue{\??transparencysetter#1}{\c_attr_transparency#2 }}
1232
1233\unexpanded\def\colordefflc#1#2{\setvalue {\??colorattribute #1}{\colo_helpers_inherited_current_ca{#2}}\setvalue {\??colorsetter #1}{\colo_helpers_inherited_current_cs{#2}}}
1234\unexpanded\def\colordeffgc#1#2{\setgvalue{\??colorattribute #1}{\colo_helpers_inherited_current_ca{#2}}\setvalue {\??colorsetter #1}{\colo_helpers_inherited_current_cs{#2}}}
1235\unexpanded\def\colordefflt#1#2{\setvalue {\??transparencyattribute#1}{\colo_helpers_inherited_current_ta{#2}}\setvalue {\??transparencysetter#1}{\colo_helpers_inherited_current_ts{#2}}}
1236\unexpanded\def\colordeffgt#1#2{\setgvalue{\??transparencyattribute#1}{\colo_helpers_inherited_current_ta{#2}}\setgvalue{\??transparencysetter#1}{\colo_helpers_inherited_current_ts{#2}}}
1237
1238\unexpanded\def\colordefrlc #1{\localundefine {\??colorattribute #1}\localundefine {\??colorsetter #1}}
1239\unexpanded\def\colordefrgc #1{\globalundefine{\??colorattribute #1}\globalundefine{\??colorsetter #1}}
1240\unexpanded\def\colordefrlt #1{\localundefine {\??transparencyattribute#1}\localundefine {\??transparencysetter#1}}
1241\unexpanded\def\colordefrgt #1{\globalundefine{\??transparencyattribute#1}\globalundefine{\??transparencysetter#1}}
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262\let\currentcolorname\s!black
1263\let\outercolorname \s!black
1264
1265\let\colorformatseparator\space
1266
1267\def\MPcolor#1
1268 {\clf_mpcolor
1269 \c_attr_colormodel
1270 \colo_helpers_inherited_current_ca{#1}
1271 \colo_helpers_inherited_current_ta{#1} }
1272
1273\def\MPcoloronly#1
1274 {\clf_mpcolor
1275 \c_attr_colormodel
1276 \colo_helpers_inherited_current_ca{#1}
1277 \zerocount}
1278
1279\def\MPtransparency#1
1280 {\clf_mpcolor
1281 \zerocount
1282 \zerocount
1283 \colo_helpers_inherited_current_ta{#1} }
1284
1285\def\MPoptions#1
1286 {\clf_mpoptions
1287 \c_attr_colormodel
1288 \colo_helpers_inherited_current_ca{#1}
1289 \colo_helpers_inherited_current_ta{#1} }
1290
1291\def\thecolormodelattribute {\the\c_attr_colormodel}
1292
1293
1294
1295
1296\def\rawcolorattribute #1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\zerocount\fi\fi}
1297\def\rawtransparencyattribute#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\zerocount\fi\fi}
1298
1299\def\thecolorattribute #1{\number\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\zerocount\fi\fi}
1300\def\thetransparencyattribute#1{\number\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\else\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\zerocount\fi\fi}
1301\def\internalspotcolorname #1{\clf_spotcolorname \thecolorattribute{#1} }
1302\def\internalspotcolorparent #1{\clf_spotcolorparent\thecolorattribute{#1} }
1303\def\internalspotcolorsize #1{\clf_spotcolorvalue \thecolorattribute{#1} }
1304
1305\def\colorcomponents #1{\clf_colorcomponents \thecolorattribute {#1} }
1306\def\transparencycomponents #1{\clf_transparencycomponents\thetransparencyattribute{#1} }
1307\def\processcolorcomponents #1{\clf_processcolorcomponents\thecolorattribute {#1} }
1308
1309\def\colorvalue #1{\clf_formatcolor\thecolorattribute{#1}{\colorformatseparator}}
1310\def\grayvalue #1{\clf_formatgray \thecolorattribute{#1}{\colorformatseparator}}
1311
1312\def\doifelseblack #1{\clf_doifelseblack\thecolorattribute{#1} }
1313\def\doifelsedrawingblack {\clf_doifelsedrawingblack}
1314
1315\let\doifblackelse \doifelseblack
1316\let\doifdrawingblackelse \doifelsedrawingblack
1317
1318\let\doifblackelse \doifelseblack
1319\let\doifdrawingblackelse\doifelsedrawingblack
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345\unexpanded\def\forcecolorhack{\leaders\hrule height\zeropoint depth\zeropoint\hskip\zeropoint\relax}
1346
1347
1348
1349
1350
1351\definecolor[black][s=0]
1352\definecolor[white][s=1]
1353
1354\definetransparency [none] [0]
1355\definetransparency [normal] [1]
1356\definetransparency [multiply] [2]
1357\definetransparency [screen] [3]
1358\definetransparency [overlay] [4]
1359\definetransparency [softlight] [5]
1360\definetransparency [hardlight] [6]
1361\definetransparency [colordodge] [7]
1362\definetransparency [colorburn] [8]
1363\definetransparency [darken] [9]
1364\definetransparency [lighten] [10]
1365\definetransparency [difference] [11]
1366\definetransparency [exclusion] [12]
1367\definetransparency [hue] [13]
1368\definetransparency [saturation] [14]
1369\definetransparency [color] [15]
1370\definetransparency [luminosity] [16]
1371
1372
1373
1374\definecolor[trace:0][s=.4]
1375\definecolor[trace:1][r=.6]
1376\definecolor[trace:2][g=.6]
1377\definecolor[trace:3][b=.6]
1378\definecolor[trace:4][r=.6,g=.6]
1379\definecolor[trace:5][r=.6,b=.6]
1380\definecolor[trace:6][g=.6,b=.6]
1381\definecolor[trace:7][r=.8,g=.4]
1382\definecolor[trace:8][r=.8,b=.4]
1383\definecolor[trace:9][g=.4,b=.8]
1384
1385\definecolor[trace:w][s=1]
1386\definecolor[trace:r][r=.75,t=.5,a=1]
1387\definecolor[trace:g][g=.75,t=.5,a=1]
1388\definecolor[trace:b][b=.75,t=.5,a=1]
1389
1390
1391
1392\definecolor[trace:c][g=.75,b=.75,t=.5,a=1]
1393\definecolor[trace:m][r=.75,b=.75,t=.5,a=1]
1394\definecolor[trace:y][r=.75,g=.75,t=.5,a=1]
1395\definecolor[trace:s][s=.75,t=.5,a=1]
1396\definecolor[trace:d][s=.25,t=.5,a=1]
1397\definecolor[trace:o][r=1,g=.6,b=.1,t=.5,a=1]
1398
1399\definecolor[trace:dw][s=1]
1400\definecolor[trace:dr][r=.75,t=.75,a=1]
1401\definecolor[trace:dg][g=.75,t=.75,a=1]
1402\definecolor[trace:db][b=.75,t=.75,a=1]
1403
1404
1405
1406\definecolor[trace:dc][g=.75,b=.75,t=.75,a=1]
1407\definecolor[trace:dm][r=.75,b=.75,t=.75,a=1]
1408\definecolor[trace:dy][r=.75,g=.75,t=.75,a=1]
1409\definecolor[trace:ds][s=.75,t=.75,a=1]
1410\definecolor[trace:dd][s=.25,t=.75,a=1]
1411\definecolor[trace:do][r=1,g=.6,b=.1,t=.75,a=1]
1412
1413\setupcolors
1414 [\c!state=\v!stop,
1415 \c!conversion=\v!yes,
1416 \c!rgb=\v!yes,
1417 \c!cmyk=\v!yes,
1418 \c!spot=\v!yes,
1419 \c!pagecolormodel=\v!none,
1420 \c!expansion=\v!no,
1421 \c!textcolor=,
1422 \c!factor=\v!yes]
1423
1424\setupcolor
1425 [\v!rgb]
1426
1427\protect \endinput
1428 |