The second answer in
is a yellow shaded sphere. How can I turn it to be black and white? Thanks for any help! I have been trying for an hour, changing values randomly but did't achieve anything, since I don't understand the code.
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityThe second answer in
is a yellow shaded sphere. How can I turn it to be black and white? Thanks for any help! I have been trying for an hour, changing values randomly but did't achieve anything, since I don't understand the code.
The colors are set here:
%% currently there is just one number in the stack.
%% we need three corresponding to the RGB values
dup
0.4
You have to put the RGB values you desire to change the color, for example if you set:
dup
0.4
0.5
You get something like pink.
RGB means red, green and blue, the primary colors, in this notation they have value from 0 (= no light) to 1 (= full light), for example:
r g b
0 0 0 = black
1 0 0 = red
0 1 0 = green
0 0 1 = blue
1 1 1 = white
If all the 3 values are equal to a value from 0 to 1, you get the scale of gray.
As you said in a comment, if you put all the rgb equal you lost the shade, I think you can reach you desired result by changing other commands, but don't know them, because they are a simplified form of a subset of the PostScript language, search for \pgfdeclarefunctionalshading
in the Ti_k_Z & PGF Manual and see Section 3.9.4 [here]
(http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf) for more info.
Instead, I suggest to you to use a simpler solution, if you don't like CroCo's one, try something like this (modify the values until you find what you're looking for):
\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\pgfdeclareradialshading{sphere}{\pgfpoint{0.5cm}{0.5cm}}%
{rgb(0cm)=(1,1,1);
rgb(0.9cm)=(0.7,0.7,0.7);
rgb(1cm)=(0.5,0.5,0.5);
rgb(1.05cm)=(0,0,0)}
\begin{document}
\pgfuseshading{sphere}
\end{document}
0.4
to dup
and decrease separately the numbers 0.6
or 0.4
until you are happy in Simon's answer. It makes it gray.
Is this what you're seeking?
\documentclass[border={10pt}]{standalone}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
[
sphereBlack/.style={ball color = black},
sphereYellow/.style={ball color = yellow}
]
\shade[sphereBlack] (0,0) circle (1cm);
\shade[sphereYellow] (3,0) circle (1cm);
\end{tikzpicture}
\end{document}
inner color
and outer color