There is probably no simple and general solution to this, but is it possible in tikz
to write text in the negative color of the background, whatever the background?
To illustrative the problem (but I am not asking for a solution specific to this background):
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\shade[left color=black,right color=red] (0,0) rectangle (4,2);
\node at (2,1) {this text is hard to read};
\end{tikzpicture}
\end{document}
Negative is to be understood in any sense (complementary color, complementary to black), it does not really matter. The idea is to get something readable for any background.
Edit This is a comparison of the different methods suggested.
- First column: original (black text), 400 is not easy to read
- Second column: what I requested: not a good idea at all!
- Third column: white text with black contour: hardly readable when small
- Fourth column: black text on white background with
opacity
: my favorite - Fifth column: white text in black background: I like it too, but slightly prefer the fourth one here because it's lighter.
Best Answer
The short answer is: use
blend modes
(p.340, pgfmanual v3.0.1a) withdifference
mode.But, for better results, you may use outlined text or background with opacity. The following picture shows different tests: