球體的陰影

球體的陰影

第二個答案在

如何繪製陰影球體?

是一個黃色陰影球體。我怎麼才能把它變成黑白的?謝謝你的幫忙!我已經嘗試了一個小時,隨機更改值但沒有任何成果,因為我不理解程式碼。

答案1

顏色在這裡設定:

%% currently there is just one number in the stack.
%% we need three corresponding to the RGB values
dup
0.4

您必須輸入您想要變更顏色的 RGB 值,例如,如果您設定:

dup 
0.4 
0.5

你會得到類似粉紅色的東西。

RGB 表示紅、綠、藍三原色,在這種表示法中,它們的值從 0(= 無光)到 1(= 全光),例如:

r g b 
0 0 0 = black
1 0 0 = red
0 1 0 = green
0 0 1 = blue
1 1 1 = white

如果所有 3 個值都等於 0 到 1 之間的值,則得到灰階。

正如您在評論中所說,如果您將所有 rgb 等於您失去的陰影,我認為您可以通過更改其他命令來達到您想要的結果,但不知道它們,因為它們是PostScript 語言,\pgfdeclarefunctionalshading在Ti_k_Z & PGF手冊中搜尋並查看[此處]第 3.9.4 節(http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/pdf_reference_1-7.pdf)了解更多。

相反,我建議您使用一種更簡單的解決方案,如果您不喜歡 CroCo 的解決方案,請嘗試這樣的方法(修改值,直到您找到您要查找的內容):

\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}

在此輸入影像描述

答案2

這就是你要找的嗎?

在此輸入影像描述

\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}

相關內容