Mixing colours for a symbolt Uiਰo6mtH9SKk oHx
3
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?

\\documentclass[a4paper,12pt]{article}
\\usepackage{fontawesome5}
\\begin{document}
\\faVolleyballBall
\\end{document}
symbols color fill
|
show 1 more comment
1 Answer
active
oldest
votes
6
Depends on what you mean precisely by "mixture of colors". You can use a path fading (cf. this answer) to e.g. achieve
\\documentclass{article}
\\usepackage{tikz}
\\usetikzlibrary{fadings,shadings}
\\usepackage{fontawesome5}
\\newcommand{\\ShadeChar}[2][]{%
\\begin{tikzfadingfrompicture}[name=temp]
\\node[transparent!0] {#2};
\\end{tikzfadingfrompicture}%
\\tikz[baseline=(X.base)]{\\node[inner sep=0pt,outer sep=0pt] (X)
{\\phantom{#2}};
\\path[path fading=temp,fit fading=false,overlay,#1] (X.south west) rectangle
(X.north east);}%
}
\\begin{document}
\\ShadeChar[upper left=red,lower right=blue]{\\faVolleyballBall}
\\begin{tikzfadingfrompicture}[name=temp]
\\node[transparent!0] {\\faVolleyballBall};
\\end{tikzfadingfrompicture}%
\\tikz[baseline=(X.base)]{\\node[inner sep=0pt,outer sep=0pt] (X)
{\\phantom{\\faVolleyballBall}};
\\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;}%
\\end{document}

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.
New contributor
Schrödinger's cat is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
-
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 8 hours ago
-
@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 7 hours ago
add a comment |
Schrödinger's catin his/her answer. – ferahfeza 8 hours ago