My code follows:
\documentclass[]{book}
\usepackage[]{tikz}
\usetikzlibrary{positioning}
\input colordvi
\input cmyk-hax
\makeatletter
\definecolor{testcolor}{cmyk}{0,0,0,0.1}
\pgfutil@colorlet{tikz@ball}{testcolor}
\pgfdeclareradialshading[testcolor]{ball}{\pgfqpoint{-10bp}{10bp}}{%
color(0bp)=(testcolor!15!white);
color(9bp)=(testcolor!75!white);
color(18bp)=(testcolor!70!black);
color(25bp)=(testcolor!50!black);
color(50bp)=(black)}
\makeatother
\begin{document}
\hspace*{-1pc}\vbox{
\begin{centering}
\newlength\radius
\pgfmathsetlength{\radius}{0.25cm}
\newcommand\drawballs[2][]{%
\foreach \y [evaluate=\y as \yy using #2+1-\y] in {1,...,#2} {%
\foreach \x in {1,...,\yy} {%
\shade[shading=ball,ball color=white,#1]
({(2*\x-2+\y)*\radius},{sqrt(3)*\y*\radius}) circle (\radius);
};
}%
}
\begin{tikzpicture}
% \drawballs{1}
% \drawballs[xshift=1.5cm]{2}
% \drawballs[xshift=4cm]{3}
% \drawballs[xshift=7cm]{4}
% \drawballs[xshift=10cm]{5}
\drawballs[xshift=2cm]{1}
\drawballs[xshift=3.5cm]{2}
\drawballs[xshift=5.5cm]{3}
\drawballs[xshift=8cm]{4}
\drawballs[xshift=11cm]{5}
\end{tikzpicture}
\end{centering}
}
\end{document}
This code works well and the output generated successfully. But shaded part shows the mixing color of CMYK combination, but my requirement shade variation should show only B/W. Kindly suggest how can achieve this?
\definecolor{testcolor}{gray}{0.9}if I understand your question correctly? – Max Jul 30 '18 at 05:55pgfgradients do not support CMYK. They get converted to RGB, which messes everything up. – David Purton Jul 30 '18 at 13:30pgfplotsto do it. – David Purton Jul 30 '18 at 14:32