1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Color Macros Initialization}
15
16
17
18
19
20
21\installcorenamespace{color}
22\installcorenamespace{colorattribute}
23\installcorenamespace{transparencyattribute}
24\installcorenamespace{colorsetter}
25\installcorenamespace{transparencysetter}
26\installcorenamespace{colorpaletspecification}
27\installcorenamespace{colorpalet}
28\installcorenamespace{colorstack}
29\installcorenamespace{colorconversions}
30\installcorenamespace{colornumber}
31
32\registerctxluafile{coloini}{}
33\registerctxluafile{coloicc}{autosuffix}
34
35\unprotect
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55\newconditional\c_colo_rgb_supported
56\newconditional\c_colo_cmyk_supported
57\newconditional\c_colo_spot_supported
58\newconditional\c_colo_convert_gray \c_colo_convert_gray\conditionaltrue
59\newconditional\c_colo_enabled
60\newconditional\c_colo_expanded
61
62\let\m_colo_weight_gray\v!yes
63
64\mutable\lettonothing\currentcolormodel
65\mutable\lettonothing\currentcolorname
66\mutable\lettonothing\currentcolorpalet
67\mutable\lettonothing\currentcolorprefix
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\permanent\protected\def\loadfoundcolorsetfile#1#2
99 {\startreadingfile
100 \startcolorset[#1]
101 \input{#2}
102 \stopcolorset
103 \showmessage\m!colors4{#1}
104 \stopreadingfile}
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123\permanent\protected\def\switchtocolor[#1]{\begincsname#1\endcsname}
124
125
126
127\permanent\protected\def\transparent[#1]
128 {\beginsimplegroup
129 \cdef\scratchstringone{#1}
130
131 \ifx\scratchstringone\v!reset
132 \c_attr_transparency\attributeunsetvalue
133 \else
134 \begincsname\??transparencysetter\scratchstringone\endcsname\relax
135 \fi
136 \let\nexttoken}
137
138\permanent\protected\def\starttransparent[#1]
139 {\begingroup
140 \cdef\scratchstringone{#1}
141 \ifx\scratchstringone\v!reset
142 \c_attr_transparency\attributeunsetvalue
143 \else
144 \begincsname\??transparencysetter\scratchstringone\endcsname\relax
145 \fi}
146
147\permanent\protected\def\stoptransparent
148 {\endgroup}
149
150
151
152\permanent\protected\def\coloronly[#1]
153 {\beginsimplegroup
154 \cdef\currentcolorname{#1}
155 \ifempty\currentcolorprefix
156 \colo_helpers_activate_nop_only
157 \else
158 \colo_helpers_activate_yes_only
159 \fi
160 \let\nexttoken}
161
162\permanent\protected\def\startcoloronly[#1]
163 {\begingroup
164 \cdef\currentcolorname{#1}
165 \ifempty\currentcolorprefix
166 \colo_helpers_activate_nop_only
167 \else
168 \colo_helpers_activate_yes_only
169 \fi}
170
171\permanent\protected\def\stopcoloronly
172 {\endgroup}
173
174
175
176\permanent\protected\def\color[#1]
177 {\beginsimplegroup
178 \cdef\currentcolorname{#1}
179 \ifempty\currentcolorprefix
180 \colo_helpers_activate_nop
181 \else
182 \colo_helpers_activate_yes
183 \fi
184 \let\nexttoken}
185
186\permanent\protected\def\graycolor[#1]
187 {\beginsimplegroup
188 \colo_helpers_set_model\s!gray\colo_helpers_activate{#1}
189 \let\nexttoken}
190
191\permanent\protected\def\startcolor[#1]
192 {\begingroup
193 \cdef\currentcolorname{#1}
194 \ifempty\currentcolorprefix
195 \colo_helpers_activate_nop
196 \else
197 \colo_helpers_activate_yes
198 \fi}
199
200\permanent\protected\def\stopcolor
201 {\endgroup}
202
203\permanent\protected\def\colored[#1]
204 {\beginsimplegroup
205 \colo_basics_defined_and_activated{#1}
206 \let\nexttoken}
207
208\permanent\protected\def\fastcolored[#1]#2
209 {\begingroup
210 \colo_basics_defined_and_activated{#1}
211 #2
212 \endgroup}
213
214\permanent\protected\def\directcolored[#1]
215 {\colo_basics_defined_and_activated{#1}}
216
217\permanent\protected\def\fastcolor[#1]#2
218 {\begingroup
219 \cdef\currentcolorname{#1}
220 \ifempty\currentcolorprefix
221 \colo_helpers_activate_nop
222 \else
223 \colo_helpers_activate_yes
224 \fi
225 #2
226 \endgroup}
227
228\permanent\protected\def\directcolor[#1]
229 {\cdef\currentcolorname{#1}
230 \ifempty\currentcolorprefix
231 \colo_helpers_activate_nop
232 \else
233 \colo_helpers_activate_yes
234 \fi}
235
236
237
238\permanent\protected\def\startcolorpage{\startcolor[\ifempty\maintextcolor\defaulttextcolor\else\maintextcolor\fi]}
239\permanent\protected\def\stopcolorpage {\stopcolor}
240
241\permanent\protected\def\getcolorattributevalue#1#2
242 {\begingroup
243 \colo_helpers_activate{#1}
244 \normalexpanded{\endgroup\edef\noexpand#2{\ifnum\c_attr_color=\attributeunsetvalue\else\the\c_attr_color\fi}}}
245
246
247
248
249
250
251\permanent\protected\def\startcurrentcolor{\startcolor[\outercolorname]}
252\permanent\protected\def\stopcurrentcolor {\stopcolor}
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\permanent\protected\def\startcolorset[#1]{\clf_startcolorset{#1}}
278\permanent\protected\def\stopcolorset {\clf_stopcolorset}
279\permanent\protected\def\usecolors [#1]{\clf_usecolors{#1}}
280
281\aliased\let\setupcolor\usecolors
282
283\installsetuponlycommandhandler \??color {colors}
284
285\let\colo_helpers_show_message\gobblethreearguments
286
287
288
289\let\v_colo_freeze_state\s!false
290
291\defcsname\??colorconversions\v!yes\endcsname
292 {\c_colo_convert_gray\conditionaltrue}
293
294\defcsname\??colorconversions\v!always\endcsname
295 {\c_colo_convert_gray\conditionaltrue
296 \c_colo_rgb_supported\conditionalfalse
297 \c_colo_cmyk_supported\conditionalfalse}
298
299\appendtoks
300
301 \ifcstok{\directcolorsparameter\c!spot }\v!yes \c_colo_spot_supported\conditionaltrue\else\c_colo_spot_supported\conditionalfalse\fi
302 \ifcstok{\directcolorsparameter\c!expansion}\v!yes \c_colo_expanded\conditionaltrue \else\c_colo_expanded\conditionalfalse \fi
303 \ifcstok{\directcolorsparameter\c!rgb }\v!yes \c_colo_rgb_supported\conditionaltrue \else\c_colo_rgb_supported\conditionalfalse \fi
304 \ifcstok{\directcolorsparameter\c!cmyk }\v!yes \c_colo_cmyk_supported\conditionaltrue\else\c_colo_cmyk_supported\conditionalfalse\fi
305 \ifcstok{\directcolorsparameter\c!state }\v!start\c_colo_enabled\conditionaltrue \else\c_colo_enabled\conditionalfalse \fi
306
307 \edef\m_colo_weight_gray{\directcolorsparameter\c!factor}
308
309 \ifconditional\c_colo_expanded
310 \let\v_colo_freeze_state\s!true
311 \else
312 \let\v_colo_freeze_state\s!false
313 \fi
314
315 \c_colo_convert_gray\conditionalfalse
316 \begincsname\??colorconversions\directcolorsparameter\c!conversion\endcsname
317
318 \ifconditional\c_colo_rgb_supported \colo_helpers_show_message\m!colors{10}\v!rgb \fi
319 \ifconditional\c_colo_cmyk_supported\colo_helpers_show_message\m!colors{10}\v!cmyk\fi
320 \colo_helpers_set_current_model
321 \ifproductionrun
322 \edef\p_pagecolormodel{\directcolorsparameter\c!pagecolormodel}
323 \clf_setpagecolormodel{\ifx\p_pagecolormodel\v!auto\currentcolormodel\else\p_pagecolormodel\fi}
324 \fi
325\to \everysetupcolors
326
327\appendtoks
328 \setupcolors[\c!state=\v!start]
329 \clf_enablecolor
330 \clf_enabletransparency
331 \let\colo_helpers_show_message\showmessage
332\to \everyjob
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\installmacrostack\m_color_state
363
364\permanent\protected\def\pushcolor[#1]
365 {\edef\m_color_state
366 {\c_attr_colormodel \the\c_attr_colormodel
367 \c_attr_color \the\c_attr_color
368 \c_attr_transparency\the\c_attr_transparency}
369 \push_macro_m_color_state
370 \colo_helpers_activate{#1}}
371
372\permanent\protected\def\popcolor
373 {\pop_macro_m_color_state
374 \m_color_state\relax}
375
376
377
378\newinteger\c_colo_saved_attribute_color
379\newinteger\c_colo_saved_attribute_transparency
380
381\permanent\protected\def\savecolor
382 {\c_colo_saved_attribute_color \c_attr_color
383 \c_colo_saved_attribute_transparency\c_attr_transparency}
384
385\permanent\protected\def\restorecolor
386 {\c_attr_color \c_colo_saved_attribute_color
387 \c_attr_transparency\c_colo_saved_attribute_transparency}
388
389
390
391
392
393
394
395
396
397
398
399\permanent\def\usedcolorparameterattributes#1
400 {\beginlocalcontrol\begingroup
401 \dousecolorparameter{#1}
402 \normalexpanded{\endgroup\noexpand\endlocalcontrol
403
404 \noexpand\s!attr \colorattribute \the\c_attr_color
405
406 \noexpand\s!attr \colormodelattribute \the\c_attr_colormodel
407
408 \noexpand\s!attr \transparencyattribute \ifnum\c_attr_transparency=\attributeunsetvalue\attributeunsetvalue\else\the\c_attr_transparency\fi}}
409
410\permanent\def\usedsymbolcolorparameterattributes#1
411 {\beginlocalcontrol\begingroup
412
413
414
415 \dousecolorparameter{#1}
416
417 \normalexpanded{\endgroup\noexpand\endlocalcontrol
418
419 \noexpand\s!symbolattr \colorattribute \the\c_attr_color
420
421 \noexpand\s!symbolattr \colormodelattribute \the\c_attr_colormodel
422
423 \noexpand\s!symbolattr \transparencyattribute \ifnum\c_attr_transparency=\attributeunsetvalue\attributeunsetvalue\else\the\c_attr_transparency\fi}}
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\installcorenamespace{paletlist}
485\installcorenamespace{paletsize}
486
487\let\m_colo_palet\relax
488\let\c_colo_palet\relax
489
490\def\colo_palet_allocate#1
491 {\letcsname\??paletlist#1\endcsname\empty
492 \ifcsname\??paletsize#1\endcsname\else
493 \expandafter\newinteger\csname\??paletsize#1\endcsname
494 \fi}
495
496\def\colo_palet_prepare#1
497 {\edef\colo_palet_name{#1}
498 \ifcsname\??paletlist\colo_palet_name\endcsname
499 \csname\??paletsize\colo_palet_name\endcsname\zerocount
500 \else
501 \colo_palet_allocate\colo_palet_name
502 \fi
503
504 \edef\c_colo_palet{\csname\??paletsize\colo_palet_name\endcsname}
505 \edef\m_colo_palet{\begincsname\??paletlist\colo_palet_name\endcsname}}
506
507\def\colo_palet_extend#1
508 {\addtocommalist{#1}\m_colo_palet
509 \letcsname\??paletlist\colo_palet_name\endcsname\m_colo_palet
510
511 \advanceby\c_colo_palet\plusone}
512
513\permanent\protected\def\doifelsecolorpalet#1
514 {\ifcsname\??paletlist#1\endcsname
515 \expandafter\firstoftwoarguments
516 \else
517 \expandafter\secondoftwoarguments
518 \fi}
519
520\mutable\lettonothing\paletlist
521\mutable\let \paletsize\!!zerocount
522
523\permanent\protected\def\getpaletlist[#1]
524 {\edef\paletlist{\begincsname\??paletlist#1\endcsname}}
525
526\permanent\protected\def\getpaletsize[#1]
527 {\ifcsname\??paletsize#1\endcsname
528 \edef\paletsize{\the\lastnamedcs}
529 \else
530 \let\paletsize\!!zerocount
531 \fi}
532
533\permanent\tolerant\protected\def\definepalet[#1]#*[#2]#*[#3]
534 {\ifarguments
535 \expandafter\gobblethreearguments
536 \or
537 \expandafter\gobblethreearguments
538 \or
539 \expandafter\colo_palets_define_a
540 \or
541 \expandafter\colo_palets_define_b
542 \fi{#1}{#2}{#3}}
543
544\protected\def\colo_palets_define_a#1#2#3
545 {\colo_palet_prepare{#1}
546 \ifhastok={#2}
547 \edefcsname\??colorpaletspecification#1\endcsname{#2}
548 \processcommalist[#2]{\colo_palets_define_one{#1}}
549 \orelse\ifcsname\??colorpaletspecification#2\endcsname
550 \normalexpanded{\colo_palets_define_b{#1}{\lastnamedcs}\empty}
551 \fi}
552
553\protected\def\colo_palets_define_b#1#2#3
554 {\colo_palet_prepare{#1}
555 \edefcsname\??colorpaletspecification#1\endcsname{#2}
556 \colo_palet_extend{#2}
557 \colo_palets_define_assign{#1}{#2}{#3}}
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579\def\colo_palets_define_one#1#2
580 {\ifhastok={#2}
581 \colo_palets_define_two{#1}[#2]
582 \else
583 \colo_palets_define_three{#1}{#2}
584 \fi}
585
586\def\colo_palets_define_two#1[#2=#3]
587 {\colo_palet_extend{#2}
588 \colo_palets_define_set{#1}{#2}{#3}}
589
590\def\colo_palets_define_three#1#2
591 {\ifcsname\??colorpaletspecification#2\endcsname
592 \processcommacommand[\lastnamedcs]{\colo_palets_define_one{#1}}
593 \fi}
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610\newtoks\everysetuppalet
611
612
613
614\permanent\tolerant\protected\def\setuppalet[#1]
615 {\cdef\currentcolorpalet{#1}
616 \ifempty\currentcolorpalet
617
618 \lettonothing\currentcolorprefix
619
620 \orelse\ifcsname\??paletlist\currentcolorpalet\endcsname
621 \cdef\currentcolorprefix{#1:}
622
623 \else
624 \colo_helpers_show_message\m!colors7\currentcolorpalet
625 \lettonothing\currentcolorpalet
626 \lettonothing\currentcolorprefix
627
628 \fi
629 \expand\everysetuppalet
630 \colo_helpers_initialize_maintextcolor}
631
632
633
634
635
636
637
638
639
640
641
642
643\fetchmodulecommand \showpalet \f!colo_run
644
645
646
647
648
649
650
651
652\fetchmodulecommand \showcolorcomponents \f!colo_run
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675\fetchmodulecommand \comparepalet \f!colo_run
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691\fetchmodulecommand \showcolor \f!colo_run
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\fetchmodulecommand \compareluminance \f!colo_run
717
718
719
720
721
722
723
724
725
726\permanent\protected\def\negatecolorcomponent #1{\edef#1{\clf_negatedcolorcomponent{#1}}}
727\permanent \def\negatedcolorcomponent#1{\clf_negatedcolorcomponent{#1}}
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\permanent\protected\def\setcolormodel[#1]
763 {\colo_helpers_set_model{#1}}
764
765\def\colo_helpers_set_model#1
766 {\cdef\currentcolormodel{#1}
767 \clf_setcolormodel{\currentcolormodel}{\m_colo_weight_gray}}
768
769\colo_helpers_set_model\s!all
770
771\def\colo_helpers_set_current_model
772 {\ifconditional\c_colo_enabled
773 \ifconditional\c_colo_rgb_supported
774 \ifconditional\c_colo_cmyk_supported
775 \colo_helpers_set_model\s!all
776 \else
777 \colo_helpers_set_model\s!rgb
778 \fi
779 \orelse\ifconditional\c_colo_cmyk_supported
780 \colo_helpers_set_model\s!cmyk
781 \orelse\ifconditional\c_colo_convert_gray
782 \colo_helpers_set_model\s!gray
783 \else
784 \colo_helpers_set_model\s!none
785 \fi
786 \orelse\ifconditional\c_colo_convert_gray
787 \colo_helpers_set_model\s!gray
788 \else
789 \colo_helpers_set_model\s!none
790 \fi}
791
792
793
794
795
796
797
798
799
800
801\def\v_colo_dummy_name{color}
802
803\letcsname\??colorattribute \v_colo_dummy_name\endcsname\empty
804\letcsname\??transparencyattribute\v_colo_dummy_name\endcsname\empty
805\letcsname\??colorsetter \v_colo_dummy_name\endcsname\empty
806\letcsname\??transparencysetter \v_colo_dummy_name\endcsname\empty
807
808\letcsname\??colorsetter \endcsname\empty
809\letcsname\??transparencysetter \endcsname\empty
810
811
812
813\def\colo_helpers_direct_activate
814 {\ifempty\currentcolorprefix
815 \expandafter\colo_helpers_direct_activate_nop
816 \else
817 \expandafter\colo_helpers_direct_activate_yes
818 \fi}
819
820\def\colo_helpers_direct_activate_yes#1
821 {\ifcsname\??colorsetter\currentcolorprefix#1\endcsname
822 \lastnamedcs
823 \begincsname\??transparencysetter\currentcolorprefix#1\endcsname
824 \orelse\ifcsname\??colorsetter#1\endcsname
825 \lastnamedcs
826 \begincsname\??transparencysetter#1\endcsname
827 \fi}
828
829\def\colo_helpers_direct_activate_nop#1
830 {\ifcsname\??colorsetter#1\endcsname
831 \lastnamedcs
832 \begincsname\??transparencysetter#1\endcsname
833 \fi}
834
835\def\colo_helpers_activate_dummy
836 {\begincsname\??colorsetter \v_colo_dummy_name\endcsname
837 \begincsname\??transparencysetter\v_colo_dummy_name\endcsname}
838
839
840
841\permanent\protected\def\colo_helpers_activate#1
842 {\cdef\currentcolorname{#1}
843 \ifempty\currentcolorprefix
844 \colo_helpers_activate_nop
845 \else
846 \colo_helpers_activate_yes
847 \fi}
848
849\def\colo_helpers_activate_yes
850 {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
851 \lastnamedcs
852 \begincsname\??transparencysetter\currentcolorprefix\currentcolorname\endcsname
853 \orelse\ifcsname\??colorsetter\currentcolorname\endcsname
854 \lastnamedcs
855 \begincsname\??transparencysetter\currentcolorname\endcsname
856 \fi}
857
858\def\colo_helpers_activate_nop
859 {\ifcsname\??colorsetter\currentcolorname\endcsname
860 \lastnamedcs
861 \begincsname\??transparencysetter\currentcolorname\endcsname
862 \fi}
863
864\def\colo_helpers_activate_yes_only
865 {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
866 \lastnamedcs
867 \orelse\ifcsname\??colorsetter\currentcolorname\endcsname
868 \lastnamedcs
869 \fi}
870
871\def\colo_helpers_activate_nop_only
872 {\ifcsname\??colorsetter\currentcolorname\endcsname
873 \lastnamedcs
874 \fi}
875
876\aliased\let\dousecolorparameter\colo_helpers_activate
877
878\permanent\protected\def\dousecolorhashparameter#1#2
879 {\ifcsname#1#2\endcsname
880 \expandafter\dousecolorparameter\csname#1#2\endcsname
881 \fi}
882
883\permanent\protected\def\dousecurrentcolorparameter
884 {\let\currentcolorname\currentcolorparameter
885 \ifcsname\??colorsetter\currentcolorprefix\currentcolorparameter\endcsname
886 \lastnamedcs
887 \begincsname\??transparencysetter\currentcolorprefix\currentcolorparameter\endcsname
888 \orelse\ifcsname\??colorsetter\currentcolorparameter\endcsname
889 \lastnamedcs
890 \begincsname\??transparencysetter\currentcolorparameter\endcsname
891 \fi}
892
893\permanent\protected\def\deactivatecolor
894 {\let\currentcolorname\s!black
895 \c_attr_color \attributeunsetvalue
896 \c_attr_transparency\attributeunsetvalue}
897
898
899
900
901
902
903\def\colo_basics_allocate#1
904 {\expandafter\newinteger\csname\??colornumber#1\endcsname
905 \clf_synccolorcount{#1}{\??colornumber#1}}
906
907\def\colo_basics_synchronize#1
908 {\ifcsname\??colornumber#1\endcsname\else
909 \colo_basics_allocate{#1}
910 \fi
911 \clf_synccolor{#1}
912
913 \lastnamedcs\csname\??colorattribute#1\endcsname}
914
915\let\colo_basics_inherit\clf_synccolorclone
916
917\newinteger\c_colo_protection
918
919\permanent\protected\def\startprotectedcolors{\advanceby\c_colo_protection\plusone }
920\permanent\protected\def\stopprotectedcolors {\advanceby\c_colo_protection\minusone}
921
922\permanent\tolerant\protected\def\definecolor[#1]#*[#2]
923 {\iftok{#1}{#2}
924
925 \else
926 \clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax
927 \colo_basics_synchronize{#1}
928 \ifcase\c_colo_protection
929 \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}
930 \fi
931 \fi}
932
933\permanent\tolerant\protected\def\defineglobalcolor[#1]#*[#2]
934 {\iftok{#1}{#2}
935
936 \else
937 \clf_defineprocesscolorglobal{#1}{#2}\v_colo_freeze_state\relax
938 \colo_basics_synchronize{#1}
939 \ifcase\c_colo_protection
940 \protected\instance\gdefcsname#1\endcsname{\colo_helpers_activate{#1}}
941 \fi
942 \fi}
943
944\aliased\let\definenamedcolor\definecolor
945
946\def\colo_basics_defined_and_activated#1
947 {\clf_defineprocesscolordummy{#1}
948 \colo_basics_synchronize{\v_colo_dummy_name}
949 \colo_helpers_activate_dummy}
950
951\permanent\tolerant\protected\def\defineprocesscolor[#1]#*[#2]#*[#3]
952 {\ifarguments\or
953 \colo_basics_define_process_wrapup{#1}\empty
954 \or
955 \colo_basics_define_process_wrapup{#1}{#2}
956 \or
957 \colo_basics_define_process_wrapup{#1}{\processcolorcomponents{#2},#3}
958 \fi}
959
960\def\colo_basics_define_process_wrapup#1#2
961 {\clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax
962 \colo_basics_synchronize{#1}
963 \ifcase\c_colo_protection
964 \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}
965 \fi}
966
967\permanent\tolerant\protected\def\definelabcolor[#1]#*[#2]#*[#3]
968 {\clf_definelabcolorlocal{#1}{#2}{#3}
969 \colo_basics_synchronize{#1}
970 \ifcase\c_colo_protection
971 \protected\instance\gdefcsname#1\endcsname{\colo_helpers_activate{#1}}
972 \fi}
973
974
975
976
977
978
979
980
981
982
983
984
985\permanent\tolerant\protected\def\definespotcolor[#1]#*[#2]#*[#3]
986 {\clf_definespotcolorglobal{#1}{#2}{#3}
987 \colo_basics_synchronize{#1}
988 \ifcase\c_colo_protection
989 \protected\instance\gdefcsname#1\endcsname{\colo_helpers_activate{#1}}
990 \fi}
991
992\permanent\tolerant\protected\def\definemultitonecolor[#1]#*[#2]#*[#3]#*[#4]
993 {\clf_definemultitonecolorglobal{#1}{#2}{#3}{#4}
994 \colo_basics_synchronize{#1}
995 \ifcase\c_colo_protection
996 \protected\instance\gdefcsname#1\endcsname{\colo_helpers_activate{#1}}
997 \fi}
998
999
1000
1001\permanent\tolerant\protected\def\definetransparency[#1]#*[#2]
1002 {\clf_definetransparency{#1}{#2}}
1003
1004\permanent\tolerant\protected\def\defineglobaltransparency[#1]#*[#2]
1005 {\clf_definetransparencyglobal{#1}{#2}}
1006
1007
1008
1009
1010
1011
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
1050\permanent\tolerant\protected\def\defineintermediatecolor[#1]#*[#2]#*[#3]
1051 {\colo_basics_define_intermediate_indeed[#1][#2][#3]}
1052
1053\def\colo_basics_define_intermediate_indeed[#1][#2,#3,#4][#5]
1054 {\clf_defineintermediatecolor
1055 {#1}
1056 {#2}
1057 \rawcolorattribute{#3}
1058 \rawcolorattribute{#4}
1059 \rawtransparencyattribute{#3}
1060 \rawtransparencyattribute{#4}
1061 {#5}
1062 \v_colo_freeze_state
1063 \relax
1064 \colo_basics_synchronize{#1}
1065 \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}}
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106\mutable\let\color@ \relax
1107\mutable\let\xcolor@\relax
1108
1109\mutable\protected\def\pgf@context@registercolor#1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\zerocount\thecolorattribute{#1}}}
1110\mutable\protected\def\pgf@context@registergray #1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plustwo \thecolorattribute{#1}}}
1111\mutable\protected\def\pgf@context@registerrgb #1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusthree\thecolorattribute{#1}}}
1112\mutable\protected\def\pgf@context@registercmyk #1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusfour \thecolorattribute{#1}}}
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126\permanent\def\doifelsecolor#1
1127 {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
1128 \expandafter\firstoftwoarguments
1129 \orelse\ifcsname\??colorattribute#1\endcsname
1130 \expandafter\firstoftwoarguments
1131 \else
1132 \expandafter\secondoftwoarguments
1133 \fi}
1134
1135\aliased\let\doifcolorelse\doifelsecolor
1136
1137\permanent\def\doifcolor#1
1138 {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
1139 \expandafter\firstofoneargument
1140 \orelse\ifcsname\??colorattribute#1\endcsname
1141 \expandafter\firstofoneargument
1142 \else
1143 \expandafter\gobbleoneargument
1144 \fi}
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170\mutable\lettonothing\maintextcolor
1171\mutable\def \defaulttextcolor{black}
1172
1173\permanent\protected\def\inheritmaintextcolor
1174 {\ifempty\maintextcolor\else\colo_helpers_activate\maintextcolor\fi}
1175
1176\permanent\protected\def\onlyinheritmaintextcolor
1177 {\ifempty\maintextcolor
1178 \deactivatecolor
1179 \else
1180 \colo_helpers_activate\maintextcolor
1181 \fi}
1182
1183\appendtoks
1184 \deactivatecolor
1185 \inheritmaintextcolor
1186\to \everybeforeoutput
1187
1188\def\colo_helpers_switch_to_maintextcolor#1
1189 {\let\maintextcolor\s!themaintextcolor
1190 \definecolor[\maintextcolor][#1]
1191 \colo_helpers_activate\maintextcolor
1192 \clf_registermaintextcolor\thecolorattribute\maintextcolor\relax}
1193
1194\permanent\protected\def\starttextcolor[#1]
1195 {\ifempty{#1}\else
1196 \colo_helpers_switch_to_maintextcolor{#1}
1197 \fi}
1198
1199\permanent\protected\lettonothing\stoptextcolor
1200
1201\lettonothing\p_colo_textcolor
1202
1203\def\colo_helpers_initialize_maintextcolor
1204 {\edef\p_colo_textcolor{\directcolorsparameter\c!textcolor}
1205 \ifempty\p_colo_textcolor
1206 \colo_helpers_switch_to_maintextcolor\defaulttextcolor
1207 \else
1208 \colo_helpers_switch_to_maintextcolor\p_colo_textcolor
1209 \fi}
1210
1211\appendtoks \colo_helpers_initialize_maintextcolor \to \everyjob
1212\appendtoks \colo_helpers_initialize_maintextcolor \to \everysetupcolors
1213
1214\letcsname\??colorsetter \endcsname\empty \letcsname\??colorattribute \endcsname\!!zerocount
1215\letcsname\??transparencysetter\endcsname\empty \letcsname\??transparencyattribute\endcsname\!!zerocount
1216
1217\def\colo_helpers_inherited_direct_cs#1{\begincsname\??colorsetter #1\endcsname}
1218\def\colo_helpers_inherited_direct_ca#1{\ifcsname \??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi}
1219\def\colo_helpers_inherited_direct_ts#1{\begincsname\??transparencysetter #1\endcsname}
1220\def\colo_helpers_inherited_direct_ta#1{\ifcsname \??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi}
1221
1222\let\colo_defcsname\defcsname
1223\let\colo_endcsname\endcsname
1224
1225\appendtoks
1226 \ifconditional\c_colo_expanded
1227 \let\colo_defcsname\edefcsname
1228 \else
1229 \let\colo_defcsname\defcsname
1230 \fi
1231\to \everysetupcolors
1232
1233\def\colo_palets_define_set#1#2#3
1234 {\ifhastok={#3}
1235 \expandafter\colo_palets_define_assign
1236 \orelse\ifcsname\??colorsetter#3\endcsname
1237
1238 \expandafter\colo_palets_define_inherit
1239 \else
1240
1241 \expandafter\colo_palets_define_undefine
1242 \fi
1243 {#1}{#2}{#3}}
1244
1245\def\colo_palets_define_inherit#1#2#3
1246 {\colo_basics_inherit{#1:#2}{#3}
1247 \colo_defcsname\??colorsetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_cs{#3}}
1248 \colo_defcsname\??colorattribute #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ca{#3}}
1249 \colo_defcsname\??transparencysetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ts{#3}}
1250 \colo_defcsname\??transparencyattribute#1:#2\colo_endcsname{\colo_helpers_inherited_direct_ta{#3}}}
1251
1252\def\colo_palets_define_undefine#1#2#3
1253 {\letcsname\??colorsetter #1:#2\endcsname\undefined
1254 \letcsname\??colorattribute #1:#2\endcsname\undefined
1255 \letcsname\??transparencysetter #1:#2\endcsname\undefined
1256 \letcsname\??transparencyattribute#1:#2\endcsname\undefined}
1257
1258\def\colo_palets_define_assign#1#2#3
1259 {\definecolor[\??colorpalet#1:#2][#3]
1260 \colo_defcsname\??colorsetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_cs{\??colorpalet#1:#2}}
1261 \colo_defcsname\??colorattribute #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ca{\??colorpalet#1:#2}}
1262 \colo_defcsname\??transparencysetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ts{\??colorpalet#1:#2}}
1263 \colo_defcsname\??transparencyattribute#1:#2\colo_endcsname{\colo_helpers_inherited_direct_ta{\??colorpalet#1:#2}}}
1264
1265\defcsname\??colorattribute currentcolor\endcsname{\the\c_attr_color}
1266\defcsname\??transparencyattribute currentcolor\endcsname{\the\c_attr_transparency}
1267
1268\def\colo_helpers_inherited_current_ca#1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi}
1269\def\colo_helpers_inherited_current_cs#1{\ifcsname\??colorsetter \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorsetter #1\endcsname\lastnamedcs\fi}
1270\def\colo_helpers_inherited_current_ta#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi}
1271\def\colo_helpers_inherited_current_ts#1{\ifcsname\??transparencysetter \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\fi}
1272
1273
1274
1275\permanent\protected\def\colordefalc#1#2{\edefcsname\??colorattribute #1\endcsname{#2}
1276 \defcsname \??colorsetter #1\endcsname{\c_attr_color #2 }}
1277\permanent\protected\def\colordefagc#1#2{\xdefcsname\??colorattribute #1\endcsname{#2}
1278 \gdefcsname\??colorsetter #1\endcsname{\c_attr_color #2 }}
1279\permanent\protected\def\colordefalt#1#2{\edefcsname\??transparencyattribute#1\endcsname{#2}
1280 \gdefcsname\??transparencysetter #1\endcsname{\c_attr_transparency#2 }}
1281\permanent\protected\def\colordefagt#1#2{\xdefcsname\??transparencyattribute#1\endcsname{#2}
1282 \gdefcsname\??transparencysetter #1\endcsname{\c_attr_transparency#2 }}
1283
1284\permanent\protected\def\colordefflc#1#2{\defcsname \??colorattribute #1\endcsname{\colo_helpers_inherited_current_ca{#2}}
1285 \defcsname \??colorsetter #1\endcsname{\colo_helpers_inherited_current_cs{#2}}}
1286\permanent\protected\def\colordeffgc#1#2{\gdefcsname\??colorattribute #1\endcsname{\colo_helpers_inherited_current_ca{#2}}
1287 \defcsname \??colorsetter #1\endcsname{\colo_helpers_inherited_current_cs{#2}}}
1288\permanent\protected\def\colordefflt#1#2{\defcsname \??transparencyattribute#1\endcsname{\colo_helpers_inherited_current_ta{#2}}
1289 \defcsname \??transparencysetter #1\endcsname{\colo_helpers_inherited_current_ts{#2}}}
1290\permanent\protected\def\colordeffgt#1#2{\gdefcsname\??transparencyattribute#1\endcsname{\colo_helpers_inherited_current_ta{#2}}
1291 \defcsname \??transparencysetter #1\endcsname{\colo_helpers_inherited_current_ts{#2}}}
1292
1293\permanent\protected\def\colordefrlc #1{\letcsname \??colorattribute #1\endcsname\undefined
1294 \letcsname \??colorsetter #1\endcsname\undefined}
1295\permanent\protected\def\colordefrgc #1{\gletcsname\??colorattribute #1\endcsname\undefined
1296 \gletcsname\??colorsetter #1\endcsname\undefined}
1297\permanent\protected\def\colordefrlt #1{\letcsname \??transparencyattribute#1\endcsname\undefined
1298 \letcsname \??transparencysetter #1\endcsname\undefined}
1299\permanent\protected\def\colordefrgt #1{\gletcsname\??transparencyattribute#1\endcsname\undefined
1300 \gletcsname\??transparencysetter #1\endcsname\undefined}
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321\mutable\let\currentcolorname\s!black
1322\mutable\let\outercolorname \s!black
1323
1324\mutable\let\colorformatseparator\space
1325
1326\permanent\def\MPcolor#1
1327 {\clf_mpcolor
1328 \c_attr_colormodel
1329 \colo_helpers_inherited_current_ca{#1}
1330 \colo_helpers_inherited_current_ta{#1} }
1331
1332\permanent\def\MPcoloronly#1
1333 {\clf_mpcolor
1334 \c_attr_colormodel
1335 \colo_helpers_inherited_current_ca{#1}
1336 \zerocount}
1337
1338\permanent\def\MPtransparency#1
1339 {\clf_mpcolor
1340 \zerocount
1341 \zerocount
1342 \colo_helpers_inherited_current_ta{#1} }
1343
1344\permanent\def\MPoptions#1
1345 {\clf_mpoptions
1346 \c_attr_colormodel
1347 \colo_helpers_inherited_current_ca{#1}
1348 \colo_helpers_inherited_current_ta{#1} }
1349
1350\permanent\def\rawcolormodelattribute {\c_attr_colormodel}
1351\permanent\def\thecolormodelattribute {\the\c_attr_colormodel}
1352
1353\permanent\def\rawcolorattribute #1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\zerocount\fi}
1354\permanent\def\rawtransparencyattribute#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\zerocount\fi}
1355
1356\permanent\def\thecolorattribute #1{\number\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\zerocount\fi}
1357\permanent\def\thetransparencyattribute#1{\number\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\zerocount\fi}
1358
1359\permanent\def\internalspotcolorname #1{\clf_spotcolorname \rawcolorattribute{#1}}
1360\permanent\def\internalspotcolorparent #1{\clf_spotcolorparent\rawcolorattribute{#1}}
1361\permanent\def\internalspotcolorsize #1{\clf_spotcolorvalue \rawcolorattribute{#1}}
1362
1363\permanent\def\colorcomponents #1{\clf_colorcomponents \rawcolorattribute {#1}}
1364\permanent\def\transparencycomponents #1{\clf_transparencycomponents\rawtransparencyattribute{#1}}
1365\permanent\def\processcolorcomponents #1{\clf_processcolorcomponents\rawcolorattribute {#1}}
1366
1367\permanent\def\colorvalue #1{\clf_formatcolor\rawcolorattribute{#1}{\colorformatseparator}}
1368\permanent\def\grayvalue #1{\clf_formatgray \rawcolorattribute{#1}{\colorformatseparator}}
1369
1370\permanent\def\colorluminance #1{\clf_formatluminance \rawcolorattribute{#1} }
1371\permanent\def\colorluminanceratio #1#2{\clf_formatluminanceratio\rawcolorattribute{#1} \rawcolorattribute{#2} }
1372
1373\permanent\def\doifelseblack #1{\clf_doifelseblack\rawcolorattribute{#1}}
1374\permanent\def\doifelsedrawingblack {\clf_doifelsedrawingblack}
1375
1376\aliased\let\doifblackelse \doifelseblack
1377\aliased\let\doifdrawingblackelse \doifelsedrawingblack
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412\permanent\protected\lettonothing\forcecolorhack
1413
1414
1415
1416
1417\definecolor[black][s=0]
1418\definecolor[white][s=1]
1419
1420\definetransparency [none] [0]
1421\definetransparency [normal] [1]
1422\definetransparency [multiply] [2]
1423\definetransparency [screen] [3]
1424\definetransparency [overlay] [4]
1425\definetransparency [softlight] [5]
1426\definetransparency [hardlight] [6]
1427\definetransparency [colordodge] [7]
1428\definetransparency [colorburn] [8]
1429\definetransparency [darken] [9]
1430\definetransparency [lighten] [10]
1431\definetransparency [difference] [11]
1432\definetransparency [exclusion] [12]
1433\definetransparency [hue] [13]
1434\definetransparency [saturation] [14]
1435\definetransparency [color] [15]
1436\definetransparency [luminosity] [16]
1437
1438
1439
1440\definecolor[trace:0][s=.4]
1441\definecolor[trace:1][r=.6]
1442\definecolor[trace:2][g=.6]
1443\definecolor[trace:3][b=.6]
1444\definecolor[trace:4][r=.6,g=.6]
1445\definecolor[trace:5][r=.6,b=.6]
1446\definecolor[trace:6][g=.6,b=.6]
1447\definecolor[trace:7][r=.8,g=.4]
1448\definecolor[trace:8][r=.8,b=.4]
1449\definecolor[trace:9][g=.4,b=.8]
1450
1451\definecolor[trace:w][s=1]
1452\definecolor[trace:z][s=0,t=.5,a=1]
1453\definecolor[trace:r][r=.75,t=.5,a=1]
1454\definecolor[trace:g][g=.75,t=.5,a=1]
1455\definecolor[trace:b][b=.75,t=.5,a=1]
1456
1457
1458
1459\definecolor[trace:c][g=.75,b=.75,t=.5,a=1]
1460\definecolor[trace:m][r=.75,b=.75,t=.5,a=1]
1461\definecolor[trace:y][r=.75,g=.75,t=.5,a=1]
1462\definecolor[trace:s][s=.75,t=.5,a=1]
1463\definecolor[trace:d][s=.25,t=.5,a=1]
1464\definecolor[trace:o][r=1,g=.6,b=.1,t=.5,a=1]
1465
1466\definecolor[trace:dw][s=1]
1467\definecolor[trace:dz][s=0,t=.75,a=1]
1468\definecolor[trace:dr][r=.75,t=.75,a=1]
1469\definecolor[trace:dg][g=.75,t=.75,a=1]
1470\definecolor[trace:db][b=.75,t=.75,a=1]
1471
1472
1473
1474\definecolor[trace:dc][g=.75,b=.75,t=.75,a=1]
1475\definecolor[trace:dm][r=.75,b=.75,t=.75,a=1]
1476\definecolor[trace:dy][r=.75,g=.75,t=.75,a=1]
1477\definecolor[trace:ds][s=.75,t=.75,a=1]
1478\definecolor[trace:dd][s=.25,t=.75,a=1]
1479\definecolor[trace:do][r=1,g=.6,b=.1,t=.75,a=1]
1480
1481\setupcolors
1482 [\c!state=\v!stop,
1483 \c!conversion=\v!yes,
1484 \c!rgb=\v!yes,
1485 \c!cmyk=\v!yes,
1486 \c!spot=\v!yes,
1487 \c!pagecolormodel=\v!none,
1488 \c!expansion=\v!no,
1489 \c!textcolor=,
1490 \c!factor=\v!yes]
1491
1492\setupcolor
1493 [\v!rgb]
1494
1495\protect \endinput
1496 |