5

Background

Using ConTeXt to develop a nice theme where users can change the colour scheme, but still get the same "feeling" for the output, primary, secondary, and tertiary colours are defined. For example:

\definecolor[ColourSecondary][h=9A957A]

Each colour can then be "lightened" by setting its transparency:

\definecolor[ColourSecondaryLighter][h=9A957A,a=1,t=.5]
\definecolor[ColourSecondaryLightest][h=9A957A,a=1,t=.3]

This works but is not ideal.

Problem

The ColourSecondary value of 9A957A is repeated for the lighter colours, resulting in triplicated code.

Question

How do you create a transparent variation on an existing colour?

For example:

\definecolor[ColourSecondaryLighter][h=\tohex{ColourSecondary},a=1,t=.5]

The following did not work:

\definecolor[ColourSecondaryLighter][1.0(ColourSecondary),a=1,t=.5]

References

  • It is relatively easy to extend \definecolor so that something like \definecolor[one][two][t=0.5, a=1] works. Why don't you send a feature request to the mailing list? – Aditya Aug 20 '13 at 23:47
  • @Aditya: Is there an issue tracker for ConTeXt? If so, I'd gladly log the issue there. I think Taco mentioned somewhere that he'd prefer them logged rather than e-mailed. – Dave Jarvis Aug 20 '13 at 23:54
  • For something like this, I think that it makes more sense to post on the mailing list because (i) mailing list is more active than the issue tracker, (ii) I think that this should have a quick solution (but I don't know all the internals, so I may be wrong). I think that Taco's comment might have been for LuaTeX rather than ConTeXt. – Aditya Aug 21 '13 at 0:09
5

Use a spot colour instead. Spot colours can be defined using three arguments instead of two arguments, like \definecolor. The first argument is the colour to define. The second argument is the colour to be use as a base. And the third argument takes the same options as \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

screenshot

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.