Is there a way to tune ball shading in TikZ ?

This only concerns your additional question, e.g. how to get such a "wood like" background:

\documentclass[parskip]{scrartcl}
\usepackage[margin=15mm]{geometry}
\usepackage{tikz}
\usetikzlibrary{calc,spy}

\begin{document}

% parameters for the "wooden rectangle", chosen to be measures of a Go board
\pgfmathsetmacro{\relativefibrethickness}{0.50}
\pgfmathsetmacro{\relativefibrevariation}{0.07}
\pgfmathsetmacro{\numberoffibres}{84}
\pgfmathsetmacro{\fibresteps}{84}
\pgfmathsetmacro{\boardwidth}{20}
\pgfmathsetmacro{\boardheight}{20}
\newcommand{\backgroundcolor}{brown}
\newcommand{\fibrecolor}{brown!90!black}

\begin{tikzpicture}[scale=0.5,spy using outlines={circle, size=7cm, connect spies}]
    %auto generated wood board  
    \filldraw[\backgroundcolor] (0,0) rectangle (\boardwidth,\boardheight);

    \pgfmathsetmacro{\segmentwidth}{\boardwidth/(\numberoffibres+1)}
    \pgfmathsetmacro{\segmentvariation}{\relativefibrethickness/2*\segmentwidth}

    \pgfmathsetmacro{\secondfibre}{2*\segmentwidth}
    \pgfmathsetmacro{\lastfibre}{\numberoffibres*\segmentwidth}

    \pgfmathsetmacro{\stepheight}{\boardheight/\fibresteps}

    \foreach \x in {1,2,...,\numberoffibres}
    {   \fill[\fibrecolor] ($(\x*\segmentwidth-\segmentvariation,0) + (rand*\relativefibrevariation*\relativefibrethickness,0)$) 
        \foreach \y in {1,...,\fibresteps}
        {   -- ($(\x*\segmentwidth-\segmentvariation,\y*\stepheight) + (rand*\relativefibrevariation*\relativefibrethickness,0)$)
        }
        -- ($(\x*\segmentwidth+\segmentvariation,\boardheight)+ (rand*\relativefibrevariation*\relativefibrethickness,0)$) 
        \foreach \y in {\fibresteps,...,0}
        {   -- ($(\x*\segmentwidth+\segmentvariation,\y*\stepheight) + (rand*\relativefibrevariation*\relativefibrethickness,0)$)
        }
        -- cycle;
    }
    \draw[thick] (0,0) rectangle (\boardwidth,\boardheight);

    % manually added stuff, only for Go board look  
    \draw (1,1) grid (19,19);
    \foreach \x in {4,10,16}
    {   \foreach \y in {4,10,16}
        {   \fill (\x,\y) circle (0.1);
        }
    }
    % spy for seeing the structure
    \spy[magnification=10,yellow] on (5.3,5.8) in node at (8,-8);
\end{tikzpicture}

\end{document}

enter image description here


You could use \pgfdeclareradialshading to modify the ball shading.

For example, insert:

\makeatletter
\pgfdeclareradialshading[tikz@ball]{ball}{\pgfqpoint{-10bp}{10bp}}{%
 color(0bp)=(tikz@ball!30!white);
 color(9bp)=(tikz@ball!75!white);
 color(18bp)=(tikz@ball!90!black);
 color(25bp)=(tikz@ball!70!black);
 color(50bp)=(black)}
\makeatother

The "reflection" will be less spotty and more ambient than with the original code:

alt text

Adjust the color values according to your needs.


You can get an effect like the shading on the go stones in the picture with radial shading. I don't know how to get radial shading off-center, so some clipping is needed:

\begin{tikzpicture}
    \begin{scope}
        \fill[black] (0,0) circle (0.5);
        \clip (0,0) circle (0.5);
        \shade[outer color=black, inner color=black!30] (-0.15,0.5) circle (0.7);
    \end{scope}
\end{tikzpicture}

an example
(source: caramdir.at)

The scope is needed in order to have the clipping only applied to the shading.


I had some time to kill and the following is the result:

go board example

This is produced with the following code

\usetikzlibrary{calc,shadows}

\newenvironment{goboard}{%
    \begin{tikzpicture}[
        scale=0.5,
        stone/.style={drop shadow={shadow xshift=0.03, shadow yshift=-0.05}},
        black-stone/.style={black!80},
        black-highlight/.style={outer color=black!80, inner color=black!30},
        black-number/.style={white},
        white-stone/.style={white!70!black},
        white-highlight/.style={outer color=white!70!black, inner color=white},
        white-number/.style={black}]
        \fill[brown!80] (-1,-1) rectangle (19,19);
        \draw[black] (0,0) grid (18,18);
        \draw[thick,black] (0,0) rectangle (18,18);
        \fill (3,3) circle (0.1);
        \fill (3,9) circle (0.1);
        \fill (3,15) circle (0.1);
        \fill (9,3) circle (0.1);
        \fill (9,9) circle (0.1);
        \fill (9,15) circle (0.1);
        \fill (15,3) circle (0.1);
        \fill (15,9) circle (0.1);
        \fill (15,15) circle (0.1);
    }{%
    \end{tikzpicture}
    }

\newcommand\gostone[4][]{%
    \begin{scope}
        \fill[stone,#2-stone] (#3,#4) circle (0.45);
        \clip (#3,#4) circle (0.45);
        \shade[#2-highlight] (-0.15+#3,0.5+#4) circle (0.7);
    \end{scope}
    \node[#2-number] at (#3,#4) {\sffamily\bfseries{#1}};
}

\begin{goboard}
    \gostone[4]{black}{2}{2}
    \gostone{black}{3}{3}
    \gostone[2]{black}{2}{5}
    \gostone[3]{white}{3}{1}
    \gostone[1]{white}{5}{2}
    \gostone[5]{white}{8}{2}
\end{goboard}

The syntax for the goboard environment and \gostone command is modeled after the psgo package.