背景
使用 ConTeXt 开发一个漂亮的主题,用户可以在其中更改配色方案,但仍然对输出获得相同的“感觉”,定义了原色、次色和三色。例如:
\definecolor[ColourSecondary][h=9A957A]
然后可以通过设置透明度来“淡化”每种颜色:
\definecolor[ColourSecondaryLighter][h=9A957A,a=1,t=.5]
\definecolor[ColourSecondaryLightest][h=9A957A,a=1,t=.3]
这可行但并不理想。
问题
对于较浅的颜色,值会重复,从而产生三重代码ColourSecondary
。9A957A
问题
如何在现有颜色上创建透明变化?
例如:
\definecolor[ColourSecondaryLighter][h=\tohex{ColourSecondary},a=1,t=.5]
以下操作无效:
\definecolor[ColourSecondaryLighter][1.0(ColourSecondary),a=1,t=.5]
参考
答案1
用一个专色而是。专色可以使用三个参数而不是两个参数来定义,例如\definecolor
。第一个参数是需要定义的颜色。第二个参数是要用作基础的颜色。第三个参数采用与 相同的选项\definecolor
。
\definecolor [ColourSecondary] [h=9A957A]
\definecolor [ColourSecondaryLighter] [h=9A957A, a=1, t=.5]
\definecolor [ColourSecondaryLightest] [h=9A957A, a=1, t=.3]
\definespotcolor [ColourSecondaryLighterSpot] [ColourSecondary] [a=1, t=.5]
\definespotcolor [ColourSecondaryLightestSpot] [ColourSecondary] [a=1, t=.3]
\setupblackrules [height=1cm, width=5cm]
\starttext
\blackrule[color=ColourSecondary]
%% defined using \definecolor
\dontleavehmode
\blackrule[color=ColourSecondaryLighter]
\blackrule[color=ColourSecondaryLightest]
%% defined using \definespotcolor
\dontleavehmode
\blackrule[color=ColourSecondaryLighterSpot]
\blackrule[color=ColourSecondaryLightestSpot]
\stoptext