Assuming we have a symbol like a volleyball symbol. In LaTeX is it possible to have a mixture of colors (I do not know if the technical term is texture) of various types that fill a symbol making it of different colors, shades and opacity?

  • 2
    It is a single glyph from the font, so it is not possible to change its color partially, except you make a lot of tricks to clip the symbol and superpose some others. – Sigur Aug 19 '19 at 20:00
  • @Sigur I'm sorry for the question that may seem trivial but it was my curiosity and I wanted to insert a question. – Sebastiano Aug 19 '19 at 20:05
  • 2
    Can this answer inspire you? : tex.stackexchange.com/a/192990/31034 – ferahfeza Aug 19 '19 at 20:28
  • @ferahfeza Very nice the word "inspire" that you have used :-). The answer of esdd is very good. But how is possible adapt it? – Sebastiano Aug 19 '19 at 20:33
  • @Sebastiano, it is from Google Translate :-). The adaptation is given by Schrödinger's cat in his/her answer. – ferahfeza Aug 19 '19 at 20:42

Depends on what you mean precisely by "mixture of colors". You can use a path fading (cf. this answer) to e.g. achieve

\node[transparent!0] {#2};
\tikz[baseline=(X.base)]{\node[inner sep=0pt,outer sep=0pt] (X)
\path[path fading=temp,fit fading=false,overlay,#1] (X.south west) rectangle
(X.north east);}%
\ShadeChar[upper left=red,lower right=blue]{\faVolleyballBall}

\node[transparent!0] {\faVolleyballBall};
\tikz[baseline=(X.base)]{\node[inner sep=0pt,outer sep=0pt] (X)
\path[path fading=temp,fit fading=false,overlay,fill=red] 
(0:1em) arc(0:120:1em) to[bend left=20] (0,0) to[bend right=20] cycle;
\path[path fading=temp,fit fading=false,overlay,fill=blue]
 (120:1em) arc(120:240:1em) to[bend left=20] (0,0)  to[bend right=20] cycle;
\path[path fading=temp,fit fading=false,overlay,fill=green!70!black] (240:1em) arc(240:360:1em)
to[bend left=20] (0,0)  to[bend right=20] cycle;}%

enter image description here

As you can see in the second example there is some tuning required because this trick only allows you to shade the whole character, and is ignorant about single patches of the character. Other packages like asymptote or pstricks allow you to retrieve the contour paths of glyphs, and to use them for e.g. filling.

|improve this answer|||||
  • Wow, that's nice. Yet you remind me of someone I've known from the way you write codes :-) +1 truly. Then the pieces can be coloured individually. – Sebastiano Aug 19 '19 at 20:35
  • 1
    @Sebastiano That user would probably have shortened the second example to \begin{tikzfadingfrompicture}[name=temp] \node[transparent!0] {\faVolleyballBall}; \end{tikzfadingfrompicture}% \tikz[baseline=(X.base)]{\node[inner sep=0pt,outer sep=0pt] (X) {\phantom{\faVolleyballBall}}; \foreach \X [count=\Y starting from 0] in {red,blue,green!70!black} { \path[path fading=temp,fit fading=false,overlay,fill=\X] (\Y*120:1em) arc(\Y*120:\Y*120+120:1em) to[bend left=20] (0,0) to[bend right=20] cycle;} }. – Schrödinger's cat Aug 19 '19 at 21:51
  • I thought a symbol could only be colored with one color. Your code is excellent: approved. You did great: for mixture I thought that LaTeX didn't color some parts as you did. That's great. – Sebastiano Aug 20 '19 at 8:54

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.