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}{}
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\permanent\def\usedcolorparameterattributes#1
392 {\beginlocalcontrol\begingroup
393 \dousecolorparameter{#1}
394 \normalexpanded{\endgroup\noexpand\endlocalcontrol
395 \noexpand\s!attr \colorattribute \the\c_attr_color
396 \noexpand\s!attr \colormodelattribute \the\c_attr_colormodel
397 \noexpand\s!attr \transparencyattribute \the\c_attr_transparency}}
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\installcorenamespace{paletlist}
459\installcorenamespace{paletsize}
460
461\let\m_colo_palet\relax
462\let\c_colo_palet\relax
463
464\def\colo_palet_allocate#1
465 {\letcsname\??paletlist#1\endcsname\empty
466 \ifcsname\??paletsize#1\endcsname\else
467 \expandafter\newinteger\csname\??paletsize#1\endcsname
468 \fi}
469
470\def\colo_palet_prepare#1
471 {\edef\colo_palet_name{#1}
472 \ifcsname\??paletlist\colo_palet_name\endcsname
473 \csname\??paletsize\colo_palet_name\endcsname\zerocount
474 \else
475 \colo_palet_allocate\colo_palet_name
476 \fi
477
478 \edef\c_colo_palet{\csname\??paletsize\colo_palet_name\endcsname}
479 \edef\m_colo_palet{\begincsname\??paletlist\colo_palet_name\endcsname}}
480
481\def\colo_palet_extend#1
482 {\addtocommalist{#1}\m_colo_palet
483 \letcsname\??paletlist\colo_palet_name\endcsname\m_colo_palet
484
485 \advanceby\c_colo_palet\plusone}
486
487\permanent\protected\def\doifelsecolorpalet#1
488 {\ifcsname\??paletlist#1\endcsname
489 \expandafter\firstoftwoarguments
490 \else
491 \expandafter\secondoftwoarguments
492 \fi}
493
494\mutable\lettonothing\paletlist
495\mutable\let \paletsize\!!zerocount
496
497\permanent\protected\def\getpaletlist[#1]
498 {\edef\paletlist{\begincsname\??paletlist#1\endcsname}}
499
500\permanent\protected\def\getpaletsize[#1]
501 {\ifcsname\??paletsize#1\endcsname
502 \edef\paletsize{\the\lastnamedcs}
503 \else
504 \let\paletsize\!!zerocount
505 \fi}
506
507\permanent\tolerant\protected\def\definepalet[#1]#*[#2]#*[#3]
508 {\ifarguments
509 \expandafter\gobblethreearguments
510 \or
511 \expandafter\gobblethreearguments
512 \or
513 \expandafter\colo_palets_define_a
514 \or
515 \expandafter\colo_palets_define_b
516 \fi{#1}{#2}{#3}}
517
518\protected\def\colo_palets_define_a#1#2#3
519 {\colo_palet_prepare{#1}
520 \ifhastok={#2}
521 \edefcsname\??colorpaletspecification#1\endcsname{#2}
522 \processcommalist[#2]{\colo_palets_define_one{#1}}
523 \orelse\ifcsname\??colorpaletspecification#2\endcsname
524 \normalexpanded{\colo_palets_define_b{#1}{\lastnamedcs}\empty}
525 \fi}
526
527\protected\def\colo_palets_define_b#1#2#3
528 {\colo_palet_prepare{#1}
529 \edefcsname\??colorpaletspecification#1\endcsname{#2}
530 \colo_palet_extend{#2}
531 \colo_palets_define_assign{#1}{#2}{#3}}
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553\def\colo_palets_define_one#1#2
554 {\ifhastok={#2}
555 \colo_palets_define_two{#1}[#2]
556 \else
557 \colo_palets_define_three{#1}{#2}
558 \fi}
559
560\def\colo_palets_define_two#1[#2=#3]
561 {\colo_palet_extend{#2}
562 \colo_palets_define_set{#1}{#2}{#3}}
563
564\def\colo_palets_define_three#1#2
565 {\ifcsname\??colorpaletspecification#2\endcsname
566 \processcommacommand[\lastnamedcs]{\colo_palets_define_one{#1}}
567 \fi}
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584\newtoks\everysetuppalet
585
586
587
588\permanent\tolerant\protected\def\setuppalet[#1]
589 {\cdef\currentcolorpalet{#1}
590 \ifempty\currentcolorpalet
591
592 \lettonothing\currentcolorprefix
593
594 \orelse\ifcsname\??paletlist\currentcolorpalet\endcsname
595 \cdef\currentcolorprefix{#1:}
596
597 \else
598 \colo_helpers_show_message\m!colors7\currentcolorpalet
599 \lettonothing\currentcolorpalet
600 \lettonothing\currentcolorprefix
601
602 \fi
603 \expand\everysetuppalet
604 \colo_helpers_initialize_maintextcolor}
605
606
607
608
609
610
611
612
613
614
615
616
617\fetchmodulecommand \showpalet \f!colo_run
618
619
620
621
622
623
624
625
626\fetchmodulecommand \showcolorcomponents \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\fetchmodulecommand \comparepalet \f!colo_run
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665\fetchmodulecommand \showcolor \f!colo_run
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\fetchmodulecommand \compareluminance \f!colo_run
691
692
693
694
695
696
697
698
699
700\permanent\protected\def\negatecolorcomponent #1{\edef#1{\clf_negatedcolorcomponent{#1}}}
701\permanent \def\negatedcolorcomponent#1{\clf_negatedcolorcomponent{#1}}
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\permanent\protected\def\setcolormodel[#1]
737 {\colo_helpers_set_model{#1}}
738
739\def\colo_helpers_set_model#1
740 {\cdef\currentcolormodel{#1}
741 \clf_setcolormodel{\currentcolormodel}{\m_colo_weight_gray}}
742
743\colo_helpers_set_model\s!all
744
745\def\colo_helpers_set_current_model
746 {\ifconditional\c_colo_enabled
747 \ifconditional\c_colo_rgb_supported
748 \ifconditional\c_colo_cmyk_supported
749 \colo_helpers_set_model\s!all
750 \else
751 \colo_helpers_set_model\s!rgb
752 \fi
753 \orelse\ifconditional\c_colo_cmyk_supported
754 \colo_helpers_set_model\s!cmyk
755 \orelse\ifconditional\c_colo_convert_gray
756 \colo_helpers_set_model\s!gray
757 \else
758 \colo_helpers_set_model\s!none
759 \fi
760 \orelse\ifconditional\c_colo_convert_gray
761 \colo_helpers_set_model\s!gray
762 \else
763 \colo_helpers_set_model\s!none
764 \fi}
765
766
767
768
769
770
771
772
773
774
775\def\v_colo_dummy_name{color}
776
777\letcsname\??colorattribute \v_colo_dummy_name\endcsname\empty
778\letcsname\??transparencyattribute\v_colo_dummy_name\endcsname\empty
779\letcsname\??colorsetter \v_colo_dummy_name\endcsname\empty
780\letcsname\??transparencysetter \v_colo_dummy_name\endcsname\empty
781
782\letcsname\??colorsetter \endcsname\empty
783\letcsname\??transparencysetter \endcsname\empty
784
785
786
787\def\colo_helpers_direct_activate
788 {\ifempty\currentcolorprefix
789 \expandafter\colo_helpers_direct_activate_nop
790 \else
791 \expandafter\colo_helpers_direct_activate_yes
792 \fi}
793
794\def\colo_helpers_direct_activate_yes#1
795 {\ifcsname\??colorsetter\currentcolorprefix#1\endcsname
796 \lastnamedcs
797 \begincsname\??transparencysetter\currentcolorprefix#1\endcsname
798 \orelse\ifcsname\??colorsetter#1\endcsname
799 \lastnamedcs
800 \begincsname\??transparencysetter#1\endcsname
801 \fi}
802
803\def\colo_helpers_direct_activate_nop#1
804 {\ifcsname\??colorsetter#1\endcsname
805 \lastnamedcs
806 \begincsname\??transparencysetter#1\endcsname
807 \fi}
808
809\def\colo_helpers_activate_dummy
810 {\begincsname\??colorsetter \v_colo_dummy_name\endcsname
811 \begincsname\??transparencysetter\v_colo_dummy_name\endcsname}
812
813
814
815\permanent\protected\def\colo_helpers_activate#1
816 {\cdef\currentcolorname{#1}
817 \ifempty\currentcolorprefix
818 \colo_helpers_activate_nop
819 \else
820 \colo_helpers_activate_yes
821 \fi}
822
823\def\colo_helpers_activate_yes
824 {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
825 \lastnamedcs
826 \begincsname\??transparencysetter\currentcolorprefix\currentcolorname\endcsname
827 \orelse\ifcsname\??colorsetter\currentcolorname\endcsname
828 \lastnamedcs
829 \begincsname\??transparencysetter\currentcolorname\endcsname
830 \fi}
831
832\def\colo_helpers_activate_nop
833 {\ifcsname\??colorsetter\currentcolorname\endcsname
834 \lastnamedcs
835 \begincsname\??transparencysetter\currentcolorname\endcsname
836 \fi}
837
838\def\colo_helpers_activate_yes_only
839 {\ifcsname\??colorsetter\currentcolorprefix\currentcolorname\endcsname
840 \lastnamedcs
841 \orelse\ifcsname\??colorsetter\currentcolorname\endcsname
842 \lastnamedcs
843 \fi}
844
845\def\colo_helpers_activate_nop_only
846 {\ifcsname\??colorsetter\currentcolorname\endcsname
847 \lastnamedcs
848 \fi}
849
850\aliased\let\dousecolorparameter\colo_helpers_activate
851
852\permanent\protected\def\dousecolorhashparameter#1#2
853 {\ifcsname#1#2\endcsname
854 \expandafter\dousecolorparameter\csname#1#2\endcsname
855 \fi}
856
857\permanent\protected\def\dousecurrentcolorparameter
858 {\let\currentcolorname\currentcolorparameter
859 \ifcsname\??colorsetter\currentcolorprefix\currentcolorparameter\endcsname
860 \lastnamedcs
861 \begincsname\??transparencysetter\currentcolorprefix\currentcolorparameter\endcsname
862 \orelse\ifcsname\??colorsetter\currentcolorparameter\endcsname
863 \lastnamedcs
864 \begincsname\??transparencysetter\currentcolorparameter\endcsname
865 \fi}
866
867\permanent\protected\def\deactivatecolor
868 {\let\currentcolorname\s!black
869 \c_attr_color \attributeunsetvalue
870 \c_attr_transparency\attributeunsetvalue}
871
872
873
874
875
876
877\def\colo_basics_allocate#1
878 {\expandafter\newinteger\csname\??colornumber#1\endcsname
879 \clf_synccolorcount{#1}{\??colornumber#1}}
880
881\def\colo_basics_synchronize#1
882 {\ifcsname\??colornumber#1\endcsname\else
883 \colo_basics_allocate{#1}
884 \fi
885 \clf_synccolor{#1}
886
887 \lastnamedcs\csname\??colorattribute#1\endcsname}
888
889\let\colo_basics_inherit\clf_synccolorclone
890
891\newinteger\c_colo_protection
892
893\permanent\protected\def\startprotectedcolors{\advanceby\c_colo_protection\plusone }
894\permanent\protected\def\stopprotectedcolors {\advanceby\c_colo_protection\minusone}
895
896\permanent\tolerant\protected\def\definecolor[#1]#*[#2]
897 {\iftok{#1}{#2}
898
899 \else
900 \clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax
901 \colo_basics_synchronize{#1}
902 \ifcase\c_colo_protection
903 \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}
904 \fi
905 \fi}
906
907\permanent\tolerant\protected\def\defineglobalcolor[#1]#*[#2]
908 {\iftok{#1}{#2}
909
910 \else
911 \clf_defineprocesscolorglobal{#1}{#2}\v_colo_freeze_state\relax
912 \colo_basics_synchronize{#1}
913 \ifcase\c_colo_protection
914 \protected\instance\gdefcsname#1\endcsname{\colo_helpers_activate{#1}}
915 \fi
916 \fi}
917
918\aliased\let\definenamedcolor\definecolor
919
920\def\colo_basics_defined_and_activated#1
921 {\clf_defineprocesscolordummy{#1}
922 \colo_basics_synchronize{\v_colo_dummy_name}
923 \colo_helpers_activate_dummy}
924
925\permanent\tolerant\protected\def\defineprocesscolor[#1]#*[#2]#*[#3]
926 {\ifarguments\or
927 \colo_basics_define_process_wrapup{#1}\empty
928 \or
929 \colo_basics_define_process_wrapup{#1}{#2}
930 \or
931 \colo_basics_define_process_wrapup{#1}{\processcolorcomponents{#2},#3}
932 \fi}
933
934\def\colo_basics_define_process_wrapup#1#2
935 {\clf_defineprocesscolorlocal{#1}{#2}\v_colo_freeze_state\relax
936 \colo_basics_synchronize{#1}
937 \ifcase\c_colo_protection
938 \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}
939 \fi}
940
941
942
943
944
945\permanent\tolerant\protected\def\definespotcolor[#1]#*[#2]#*[#3]
946 {\clf_definespotcolorglobal{#1}{#2}{#3}
947 \colo_basics_synchronize{#1}
948 \ifcase\c_colo_protection
949 \protected\instance\gdefcsname#1\endcsname{\colo_helpers_activate{#1}}
950 \fi}
951
952\permanent\tolerant\protected\def\definemultitonecolor[#1]#*[#2]#*[#3]#*[#4]
953 {\clf_definemultitonecolorglobal{#1}{#2}{#3}{#4}
954 \colo_basics_synchronize{#1}
955 \ifcase\c_colo_protection
956 \protected\instance\gdefcsname#1\endcsname{\colo_helpers_activate{#1}}
957 \fi}
958
959
960
961\permanent\tolerant\protected\def\definetransparency[#1]#*[#2]
962 {\clf_definetransparency{#1}{#2}}
963
964\permanent\tolerant\protected\def\defineglobaltransparency[#1]#*[#2]
965 {\clf_definetransparencyglobal{#1}{#2}}
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010\permanent\tolerant\protected\def\defineintermediatecolor[#1]#*[#2]#*[#3]
1011 {\colo_basics_define_intermediate_indeed[#1][#2][#3]}
1012
1013\def\colo_basics_define_intermediate_indeed[#1][#2,#3,#4][#5]
1014 {\clf_defineintermediatecolor
1015 {#1}
1016 {#2}
1017 \rawcolorattribute{#3}
1018 \rawcolorattribute{#4}
1019 \rawtransparencyattribute{#3}
1020 \rawtransparencyattribute{#4}
1021 {#5}
1022 \v_colo_freeze_state
1023 \relax
1024 \colo_basics_synchronize{#1}
1025 \protected\instance\defcsname#1\endcsname{\colo_helpers_activate{#1}}}
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
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066\mutable\let\color@ \relax
1067\mutable\let\xcolor@\relax
1068
1069\mutable\protected\def\pgf@context@registercolor#1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\zerocount\thecolorattribute{#1}}}
1070\mutable\protected\def\pgf@context@registergray #1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plustwo \thecolorattribute{#1}}}
1071\mutable\protected\def\pgf@context@registerrgb #1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusthree\thecolorattribute{#1}}}
1072\mutable\protected\def\pgf@context@registercmyk #1{\edefcsname\string\color@#1\endcsname{\noexpand\xcolor@{}{}\clf_pgfxcolorspec\plusfour \thecolorattribute{#1}}}
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086\permanent\def\doifelsecolor#1
1087 {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
1088 \expandafter\firstoftwoarguments
1089 \orelse\ifcsname\??colorattribute#1\endcsname
1090 \expandafter\firstoftwoarguments
1091 \else
1092 \expandafter\secondoftwoarguments
1093 \fi}
1094
1095\aliased\let\doifcolorelse\doifelsecolor
1096
1097\permanent\def\doifcolor#1
1098 {\ifcsname\??colorattribute\currentcolorprefix#1\endcsname
1099 \expandafter\firstofoneargument
1100 \orelse\ifcsname\??colorattribute#1\endcsname
1101 \expandafter\firstofoneargument
1102 \else
1103 \expandafter\gobbleoneargument
1104 \fi}
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130\mutable\lettonothing\maintextcolor
1131\mutable\def \defaulttextcolor{black}
1132
1133\permanent\protected\def\inheritmaintextcolor
1134 {\ifempty\maintextcolor\else\colo_helpers_activate\maintextcolor\fi}
1135
1136\permanent\protected\def\onlyinheritmaintextcolor
1137 {\ifempty\maintextcolor
1138 \deactivatecolor
1139 \else
1140 \colo_helpers_activate\maintextcolor
1141 \fi}
1142
1143\appendtoks
1144 \deactivatecolor
1145 \inheritmaintextcolor
1146\to \everybeforeoutput
1147
1148\def\colo_helpers_switch_to_maintextcolor#1
1149 {\let\maintextcolor\s!themaintextcolor
1150 \definecolor[\maintextcolor][#1]
1151 \colo_helpers_activate\maintextcolor
1152 \clf_registermaintextcolor\thecolorattribute\maintextcolor\relax}
1153
1154\permanent\protected\def\starttextcolor[#1]
1155 {\ifempty{#1}\else
1156 \colo_helpers_switch_to_maintextcolor{#1}
1157 \fi}
1158
1159\permanent\protected\lettonothing\stoptextcolor
1160
1161\lettonothing\p_colo_textcolor
1162
1163\def\colo_helpers_initialize_maintextcolor
1164 {\edef\p_colo_textcolor{\directcolorsparameter\c!textcolor}
1165 \ifempty\p_colo_textcolor
1166 \colo_helpers_switch_to_maintextcolor\defaulttextcolor
1167 \else
1168 \colo_helpers_switch_to_maintextcolor\p_colo_textcolor
1169 \fi}
1170
1171\appendtoks \colo_helpers_initialize_maintextcolor \to \everyjob
1172\appendtoks \colo_helpers_initialize_maintextcolor \to \everysetupcolors
1173
1174\letcsname\??colorsetter \endcsname\empty \letcsname\??colorattribute \endcsname\!!zerocount
1175\letcsname\??transparencysetter\endcsname\empty \letcsname\??transparencyattribute\endcsname\!!zerocount
1176
1177\def\colo_helpers_inherited_direct_cs#1{\begincsname\??colorsetter #1\endcsname}
1178\def\colo_helpers_inherited_direct_ca#1{\ifcsname \??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi}
1179\def\colo_helpers_inherited_direct_ts#1{\begincsname\??transparencysetter #1\endcsname}
1180\def\colo_helpers_inherited_direct_ta#1{\ifcsname \??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi}
1181
1182\let\colo_defcsname\defcsname
1183\let\colo_endcsname\endcsname
1184
1185\appendtoks
1186 \ifconditional\c_colo_expanded
1187 \let\colo_defcsname\edefcsname
1188 \else
1189 \let\colo_defcsname\defcsname
1190 \fi
1191\to \everysetupcolors
1192
1193\def\colo_palets_define_set#1#2#3
1194 {\ifhastok={#3}
1195 \expandafter\colo_palets_define_assign
1196 \orelse\ifcsname\??colorsetter#3\endcsname
1197
1198 \expandafter\colo_palets_define_inherit
1199 \else
1200
1201 \expandafter\colo_palets_define_undefine
1202 \fi
1203 {#1}{#2}{#3}}
1204
1205\def\colo_palets_define_inherit#1#2#3
1206 {\colo_basics_inherit{#1:#2}{#3}
1207 \colo_defcsname\??colorsetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_cs{#3}}
1208 \colo_defcsname\??colorattribute #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ca{#3}}
1209 \colo_defcsname\??transparencysetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ts{#3}}
1210 \colo_defcsname\??transparencyattribute#1:#2\colo_endcsname{\colo_helpers_inherited_direct_ta{#3}}}
1211
1212\def\colo_palets_define_undefine#1#2#3
1213 {\letcsname\??colorsetter #1:#2\endcsname\undefined
1214 \letcsname\??colorattribute #1:#2\endcsname\undefined
1215 \letcsname\??transparencysetter #1:#2\endcsname\undefined
1216 \letcsname\??transparencyattribute#1:#2\endcsname\undefined}
1217
1218\def\colo_palets_define_assign#1#2#3
1219 {\definecolor[\??colorpalet#1:#2][#3]
1220 \colo_defcsname\??colorsetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_cs{\??colorpalet#1:#2}}
1221 \colo_defcsname\??colorattribute #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ca{\??colorpalet#1:#2}}
1222 \colo_defcsname\??transparencysetter #1:#2\colo_endcsname{\colo_helpers_inherited_direct_ts{\??colorpalet#1:#2}}
1223 \colo_defcsname\??transparencyattribute#1:#2\colo_endcsname{\colo_helpers_inherited_direct_ta{\??colorpalet#1:#2}}}
1224
1225\defcsname\??colorattribute currentcolor\endcsname{\the\c_attr_color}
1226\defcsname\??transparencyattribute currentcolor\endcsname{\the\c_attr_transparency}
1227
1228\def\colo_helpers_inherited_current_ca#1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\!!zerocount\fi}
1229\def\colo_helpers_inherited_current_cs#1{\ifcsname\??colorsetter \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorsetter #1\endcsname\lastnamedcs\fi}
1230\def\colo_helpers_inherited_current_ta#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\!!zerocount\fi}
1231\def\colo_helpers_inherited_current_ts#1{\ifcsname\??transparencysetter \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencysetter #1\endcsname\lastnamedcs\fi}
1232
1233
1234
1235\permanent\protected\def\colordefalc#1#2{\edefcsname\??colorattribute #1\endcsname{#2}
1236 \defcsname \??colorsetter #1\endcsname{\c_attr_color #2 }}
1237\permanent\protected\def\colordefagc#1#2{\xdefcsname\??colorattribute #1\endcsname{#2}
1238 \gdefcsname\??colorsetter #1\endcsname{\c_attr_color #2 }}
1239\permanent\protected\def\colordefalt#1#2{\edefcsname\??transparencyattribute#1\endcsname{#2}
1240 \gdefcsname\??transparencysetter #1\endcsname{\c_attr_transparency#2 }}
1241\permanent\protected\def\colordefagt#1#2{\xdefcsname\??transparencyattribute#1\endcsname{#2}
1242 \gdefcsname\??transparencysetter #1\endcsname{\c_attr_transparency#2 }}
1243
1244\permanent\protected\def\colordefflc#1#2{\defcsname \??colorattribute #1\endcsname{\colo_helpers_inherited_current_ca{#2}}
1245 \defcsname \??colorsetter #1\endcsname{\colo_helpers_inherited_current_cs{#2}}}
1246\permanent\protected\def\colordeffgc#1#2{\gdefcsname\??colorattribute #1\endcsname{\colo_helpers_inherited_current_ca{#2}}
1247 \defcsname \??colorsetter #1\endcsname{\colo_helpers_inherited_current_cs{#2}}}
1248\permanent\protected\def\colordefflt#1#2{\defcsname \??transparencyattribute#1\endcsname{\colo_helpers_inherited_current_ta{#2}}
1249 \defcsname \??transparencysetter #1\endcsname{\colo_helpers_inherited_current_ts{#2}}}
1250\permanent\protected\def\colordeffgt#1#2{\gdefcsname\??transparencyattribute#1\endcsname{\colo_helpers_inherited_current_ta{#2}}
1251 \defcsname \??transparencysetter #1\endcsname{\colo_helpers_inherited_current_ts{#2}}}
1252
1253\permanent\protected\def\colordefrlc #1{\letcsname \??colorattribute #1\endcsname\undefined
1254 \letcsname \??colorsetter #1\endcsname\undefined}
1255\permanent\protected\def\colordefrgc #1{\gletcsname\??colorattribute #1\endcsname\undefined
1256 \gletcsname\??colorsetter #1\endcsname\undefined}
1257\permanent\protected\def\colordefrlt #1{\letcsname \??transparencyattribute#1\endcsname\undefined
1258 \letcsname \??transparencysetter #1\endcsname\undefined}
1259\permanent\protected\def\colordefrgt #1{\gletcsname\??transparencyattribute#1\endcsname\undefined
1260 \gletcsname\??transparencysetter #1\endcsname\undefined}
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281\mutable\let\currentcolorname\s!black
1282\mutable\let\outercolorname \s!black
1283
1284\mutable\let\colorformatseparator\space
1285
1286\permanent\def\MPcolor#1
1287 {\clf_mpcolor
1288 \c_attr_colormodel
1289 \colo_helpers_inherited_current_ca{#1}
1290 \colo_helpers_inherited_current_ta{#1} }
1291
1292\permanent\def\MPcoloronly#1
1293 {\clf_mpcolor
1294 \c_attr_colormodel
1295 \colo_helpers_inherited_current_ca{#1}
1296 \zerocount}
1297
1298\permanent\def\MPtransparency#1
1299 {\clf_mpcolor
1300 \zerocount
1301 \zerocount
1302 \colo_helpers_inherited_current_ta{#1} }
1303
1304\permanent\def\MPoptions#1
1305 {\clf_mpoptions
1306 \c_attr_colormodel
1307 \colo_helpers_inherited_current_ca{#1}
1308 \colo_helpers_inherited_current_ta{#1} }
1309
1310\permanent\def\rawcolormodelattribute {\c_attr_colormodel}
1311\permanent\def\thecolormodelattribute {\the\c_attr_colormodel}
1312
1313\permanent\def\rawcolorattribute #1{\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\zerocount\fi}
1314\permanent\def\rawtransparencyattribute#1{\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\zerocount\fi}
1315
1316\permanent\def\thecolorattribute #1{\number\ifcsname\??colorattribute \currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??colorattribute #1\endcsname\lastnamedcs\else\zerocount\fi}
1317\permanent\def\thetransparencyattribute#1{\number\ifcsname\??transparencyattribute\currentcolorprefix#1\endcsname\lastnamedcs\orelse\ifcsname\??transparencyattribute#1\endcsname\lastnamedcs\else\zerocount\fi}
1318
1319\permanent\def\internalspotcolorname #1{\clf_spotcolorname \rawcolorattribute{#1}}
1320\permanent\def\internalspotcolorparent #1{\clf_spotcolorparent\rawcolorattribute{#1}}
1321\permanent\def\internalspotcolorsize #1{\clf_spotcolorvalue \rawcolorattribute{#1}}
1322
1323\permanent\def\colorcomponents #1{\clf_colorcomponents \rawcolorattribute {#1}}
1324\permanent\def\transparencycomponents #1{\clf_transparencycomponents\rawtransparencyattribute{#1}}
1325\permanent\def\processcolorcomponents #1{\clf_processcolorcomponents\rawcolorattribute {#1}}
1326
1327\permanent\def\colorvalue #1{\clf_formatcolor\rawcolorattribute{#1}{\colorformatseparator}}
1328\permanent\def\grayvalue #1{\clf_formatgray \rawcolorattribute{#1}{\colorformatseparator}}
1329
1330\permanent\def\colorluminance #1{\clf_formatluminance \rawcolorattribute{#1} }
1331\permanent\def\colorluminanceratio #1#2{\clf_formatluminanceratio\rawcolorattribute{#1} \rawcolorattribute{#2} }
1332
1333\permanent\def\doifelseblack #1{\clf_doifelseblack\rawcolorattribute{#1}}
1334\permanent\def\doifelsedrawingblack {\clf_doifelsedrawingblack}
1335
1336\aliased\let\doifblackelse \doifelseblack
1337\aliased\let\doifdrawingblackelse \doifelsedrawingblack
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372\permanent\protected\lettonothing\forcecolorhack
1373
1374
1375
1376
1377\definecolor[black][s=0]
1378\definecolor[white][s=1]
1379
1380\definetransparency [none] [0]
1381\definetransparency [normal] [1]
1382\definetransparency [multiply] [2]
1383\definetransparency [screen] [3]
1384\definetransparency [overlay] [4]
1385\definetransparency [softlight] [5]
1386\definetransparency [hardlight] [6]
1387\definetransparency [colordodge] [7]
1388\definetransparency [colorburn] [8]
1389\definetransparency [darken] [9]
1390\definetransparency [lighten] [10]
1391\definetransparency [difference] [11]
1392\definetransparency [exclusion] [12]
1393\definetransparency [hue] [13]
1394\definetransparency [saturation] [14]
1395\definetransparency [color] [15]
1396\definetransparency [luminosity] [16]
1397
1398
1399
1400\definecolor[trace:0][s=.4]
1401\definecolor[trace:1][r=.6]
1402\definecolor[trace:2][g=.6]
1403\definecolor[trace:3][b=.6]
1404\definecolor[trace:4][r=.6,g=.6]
1405\definecolor[trace:5][r=.6,b=.6]
1406\definecolor[trace:6][g=.6,b=.6]
1407\definecolor[trace:7][r=.8,g=.4]
1408\definecolor[trace:8][r=.8,b=.4]
1409\definecolor[trace:9][g=.4,b=.8]
1410
1411\definecolor[trace:w][s=1]
1412\definecolor[trace:z][s=0,t=.5,a=1]
1413\definecolor[trace:r][r=.75,t=.5,a=1]
1414\definecolor[trace:g][g=.75,t=.5,a=1]
1415\definecolor[trace:b][b=.75,t=.5,a=1]
1416
1417
1418
1419\definecolor[trace:c][g=.75,b=.75,t=.5,a=1]
1420\definecolor[trace:m][r=.75,b=.75,t=.5,a=1]
1421\definecolor[trace:y][r=.75,g=.75,t=.5,a=1]
1422\definecolor[trace:s][s=.75,t=.5,a=1]
1423\definecolor[trace:d][s=.25,t=.5,a=1]
1424\definecolor[trace:o][r=1,g=.6,b=.1,t=.5,a=1]
1425
1426\definecolor[trace:dw][s=1]
1427\definecolor[trace:dz][s=0,t=.75,a=1]
1428\definecolor[trace:dr][r=.75,t=.75,a=1]
1429\definecolor[trace:dg][g=.75,t=.75,a=1]
1430\definecolor[trace:db][b=.75,t=.75,a=1]
1431
1432
1433
1434\definecolor[trace:dc][g=.75,b=.75,t=.75,a=1]
1435\definecolor[trace:dm][r=.75,b=.75,t=.75,a=1]
1436\definecolor[trace:dy][r=.75,g=.75,t=.75,a=1]
1437\definecolor[trace:ds][s=.75,t=.75,a=1]
1438\definecolor[trace:dd][s=.25,t=.75,a=1]
1439\definecolor[trace:do][r=1,g=.6,b=.1,t=.75,a=1]
1440
1441\setupcolors
1442 [\c!state=\v!stop,
1443 \c!conversion=\v!yes,
1444 \c!rgb=\v!yes,
1445 \c!cmyk=\v!yes,
1446 \c!spot=\v!yes,
1447 \c!pagecolormodel=\v!none,
1448 \c!expansion=\v!no,
1449 \c!textcolor=,
1450 \c!factor=\v!yes]
1451
1452\setupcolor
1453 [\v!rgb]
1454
1455\protect \endinput
1456 |