[pstricks] Re: density fill

Denis Girou Denis.Girou at idris.fr
Tue Nov 19 19:04:16 CET 2002


The following message is a courtesy copy of an article
that has been posted to comp.text.tex as well.

>>>>> "les" == abidnego25  <abidnego25 at yahoo.com> writes:

    les> thanks for the reply, but this is not what i want.
    les> i would like to make
    les> circles with given number of dots (uniform random) 
    les> in them. is this possible?

  So, this version must be near of what you want. Adapt it for your precise
needs.

\documentclass[a4paper]{article}

\usepackage{multido}
\usepackage{pstcol}

\input{random.tex}% From Donald Arseneau (CTAN:macros/generic/random.tex)

\setlength{\parindent}{-1cm}

\newcount\NumberDots
\newdimen\DotSize
\newdimen\Hue
\newdimen\XPos
\newdimen\YPos

% Circle with dots at random positions
\def\CircleWithDotsA#1#2{%
% #1=radius of the circle
% #2=number of dots (put on the (-#1,-#1)(#1,#1) square,
%    not on the circle itself!)
\pspicture(-#1,-#1)(#1,#1)
  \setrannum{\NumberDots}{0}{#2}%
  \psclip{\pscircle{#1}}
    \multido{\iDots=1+1}{\NumberDots}{%
      \setrandim{\XPos}{-#1 pt}{#1 pt}%
      \setrandim{\YPos}{-#1 pt}{#1 pt}%
      \psdot(\pointless\XPos,\pointless\YPos)}
  \endpsclip
\endpspicture}

% Circle with dots at random positions, with random dot sizes
\def\CircleWithDotsB#1#2{%
% #1=radius of the circle
% #2=number of dots (put on the (-#1,-#1)(#1,#1) square,
%    not on the circle itself!)
\pspicture(-#1,-#1)(#1,#1)
  \setrannum{\NumberDots}{0}{#2}%
  \psclip{\pscircle{#1}}
    \multido{\iDots=1+1}{\NumberDots}{%
      \setrandim{\XPos}{-#1 pt}{#1 pt}%
      \setrandim{\YPos}{-#1 pt}{#1 pt}%
      \setrandim{\DotSize}{2pt}{15pt}%
      \psdot[dotsize=\DotSize](\pointless\XPos,\pointless\YPos)}
  \endpsclip
\endpspicture}

% Circle with dots at random positions, with random dot sizes
% and random colors
\def\CircleWithDotsC#1#2{%
% #1=radius of the circle
% #2=number of dots (put on the (-#1,-#1)(#1,#1) square,
%    not on the circle itself!)
\pspicture(-#1,-#1)(#1,#1)
  \setrannum{\NumberDots}{0}{#2}%
  \psclip{\pscircle{#1}}
    \multido{\iDots=1+1}{\NumberDots}{%
      \setrandim{\XPos}{-#1 pt}{#1 pt}%
      \setrandim{\YPos}{-#1 pt}{#1 pt}%
      \setrandim{\DotSize}{2pt}{15pt}%
      \setrandim{\Hue}{0pt}{1pt}%
      \definecolor{MyColor}{hsb}{\pointless\Hue,0.6,1}
      \psdot[dotsize=\DotSize,linecolor=MyColor]
            (\pointless\XPos,\pointless\YPos)}
  \endpsclip
\endpspicture}

\pagestyle{empty}

\begin{document}

% To fix the random seed (otherwise the clock is used)
\randomi=123456

\CircleWithDotsA{1}{10}
\CircleWithDotsA{1}{50}
\CircleWithDotsA{1}{100}
\CircleWithDotsA{1}{1000}
\CircleWithDotsA{1}{3000}

{\psset{dotscale=3}\CircleWithDotsA{3}{500}} % Bigger fixed dots

\CircleWithDotsB{2}{10}
\CircleWithDotsB{2}{100}
\CircleWithDotsB{2}{200}

\CircleWithDotsC{2}{10}
\CircleWithDotsC{2}{100}
\CircleWithDotsC{2}{500}

\end{document}


Denis Girou
-- 
--------------------------------------------------------------------------
Institut du Développement et des Ressources en Informatique Scientifique |
Centre National de la Recherche Scientifique                             |
Bâtiment 506 - B.P. 167 - 91403 Orsay Cedex - France                     |
--------------------------------------------------------------------------



More information about the PSTricks mailing list